0

I was trying to add an attribute for material index to each vertex:

...
glVertexAttribPointer(3, 1, GL_INT, GL_FALSE, sizeof(VertexMaterial), (void*)offsetof(VertexMaterial, material_id));
...

But the material_id read in the vertex shader was totally wrong:

layout(location = 3) in int aMaterial;

Then I replaced glVertexAttribPointer with glVertexAttribIPointer:

glVertexAttribIPointer(3, 1, GL_INT, sizeof(VertexMaterial), (void*)offsetof(VertexMaterial, material_id));

I modified nowhere else, but the vertex shader successfully got the right value for material_id this time.

But the OpenGL doc says that both glVertexAttribPointer and glVertexAttribIPointer can accept GL_INT (https://docs.gl/gl4/glVertexAttribPointer): doc

So what's wrong in my code ?

0 Answers0