Using The DSA Ext with opengl , API calls to guide opengl to the buffer format are :

glVertexArrayAttribFormat(  GLuint vaobj,
GLuint attribindex,
GLint size,
GLenum type,
GLboolean normalized,
GLuint relativeoffset);

and another one is :

glVertexArrayVertexBuffer(  GLuint vaobj,
GLuint bindingindex,
GLuint buffer,
GLintptr offset,
GLsizei stride);

my question is what's the difference between relativeOffset and the offset in both function calls ? when i set one the results are ok but when you set both your layout will be incorrected and thus the results are wrong.


1 Answer 1


The offset in glVertexArrayVertexBuffer is the common offset for all attributes bound to that buffer. It's where the vbo data starts.

The offset in glVertexArrayAttribFormat is added to that common offset for that attribute.

This allows you to interleave attributes using a single vbo binding point. and change the vbo binding for those attributes in a single call.

To make an example:

struct Vertex {
    vec3 pos;
    vec3 normal;

glVertexAttribFormat(posAttrLoc, 3, GL_FLOAT, false, offsetof(Vertex, pos));
glVertexAttribBinding(posAttrLoc, vertexBindingPoint);

glVertexAttribFormat(normalAttrLoc, 3, GL_FLOAT, false, offsetof(Vertex, normal));
glVertexAttribBinding(normalAttrLoc, vertexBindingPoint);

then to bind the buffer you pass the offset to where you put in where the data was uploaded to, this is 0 in the basic case.

glBindVertexBuffer(vertexBindingPoint, mesh.vbo, mesh.vboOffset, sizeof(Vertex));
  • $\begingroup$ so when data is tightly packed and there is no interleaving , like a situation where pos data is first and then the whole normals are , the offset bcomes one . $\endgroup$ Aug 22, 2018 at 11:15
  • 1
    $\begingroup$ @mahdimahzuni then you'd use separate binding points for each attribute, the offset in glVertexAttribFormat become 0 and the offset in glBindVertexBuffer is where each attribute begins. $\endgroup$ Aug 22, 2018 at 11:20
  • $\begingroup$ tnx superb explanation, performance wise is it bad to use two binding points or are they similar ? $\endgroup$ Aug 22, 2018 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.