OpenGL: glVertexAttribFormat.attribindex vs GLSL vertex shader location

Viewed 45

Does the attribindex in glVertexAttribFormat correspond with the layout location in my GLSL vertex shader?

i.e. if I write

glVertexAttribFormat(0, 3, GL_FLOAT, GL_FALSE, offsetof(Vertex, position));

That 0 would correspond with this line in my shader?

layout (location = 0) in vec3 inPos;
1 Answers

Yup. Otherwise without a location specifier you have to query the attribute location via glGetAttribLocation() after program linking or set it before program linking via glBindAttribLocation().

Related