glVertexArrayAttribFormat
Describes the format of one attribute inside a vertex — without saying which buffer.
Signature
void glVertexArrayAttribFormat(GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);
How it works
The DSA way splits glVertexAttribPointer into three calls. This one says what the attribute looks like: size components of type, starting relativeoffset bytes into each vertex. glVertexArrayAttribBinding then says which binding point it reads from, and glVertexArrayVertexBuffer which buffer sits on that binding point, with the stride.
Because the format is separate from the buffer, the same VAO layout can be pointed at another buffer with one call.
Parameters
The VAO.
Attribute location, as layout(location = N).
Components: 1–4.
Component type, e.g. GL_FLOAT.
Normalize integer types to 0–1 / -1–1.
Offset of this attribute inside ONE vertex — offsetof(Vertex, member).
Tips & pitfalls
Direct State Access (GL 4.5): the object is passed as a parameter, so nothing needs to be bound and no global state is disturbed.
Example
1glVertexArrayAttribFormat(vao, 0, 3, GL_FLOAT, GL_FALSE, offsetof(Vertex, pos));
2glVertexArrayAttribFormat(vao, 1, 2, GL_FLOAT, GL_FALSE, offsetof(Vertex, uv));