28 static constexpr std::uint8_t format_scale_lut[] =
224 glCreateVertexArrays(1, &m_gl_named_array);
226 for (
const auto& attribute: m_attributes)
229 glEnableVertexArrayAttrib(m_gl_named_array,
static_cast<GLuint
>(attribute.location));
232 glVertexArrayAttribBinding
235 static_cast<GLuint
>(attribute.location),
236 static_cast<GLuint
>(attribute.binding)
239 const auto format_index = std::to_underlying(attribute.format);
242 const auto format_scale = format_scale_lut[format_index];
246 switch (gl_base_format)
250 case GL_DEPTH_COMPONENT:
251 case GL_STENCIL_INDEX:
257 case GL_DEPTH_STENCIL:
269 case GL_BGRA_INTEGER:
271 case GL_RGBA_INTEGER:
280 if (gl_size == 0 || gl_type == 0)
282 throw std::invalid_argument(
"Vertex input attribute has unsupported format.");
285 if (format_scale > 0 || gl_type == GL_FLOAT || gl_type == GL_HALF_FLOAT)
287 glVertexArrayAttribFormat
290 static_cast<GLuint
>(attribute.location),
294 static_cast<GLuint
>(attribute.offset)
297 else if (gl_type == GL_DOUBLE)
299 glVertexArrayAttribLFormat
302 static_cast<GLuint
>(attribute.location),
305 static_cast<GLuint
>(attribute.offset)
310 glVertexArrayAttribIFormat
313 static_cast<GLuint
>(attribute.location),
316 static_cast<GLuint
>(attribute.offset)
324 glCreateVertexArrays(1, &m_gl_named_array);
329 glDeleteVertexArrays(1, &m_gl_named_array);
~vertex_array()
Destructs a vertex array.
constexpr const std::vector< vertex_input_attribute > & attributes() const noexcept
Returns the vertex array's vertex input attributes.
vertex_array()
Constructs a vertex array.
Graphics library interface.
constexpr GLenum gl_format_lut[][3]
Maps gl::format to OpenGL internal format, base format, and pixel type.