Home > Back-end >  OpenGL: glVertexAttribFormat.attribindex vs GLSL vertex shader location
OpenGL: glVertexAttribFormat.attribindex vs GLSL vertex shader location

Time:11-28

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;

CodePudding user response:

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