is glVertexAttribDivisor() part of a vertex array objects state? can’t seem to find confirmation in the spec, although it seems to be true on this nvidia driver.
I’m just checking because I’m trying to diagnose a very strange flickering bug when using this combination, not in the instanced geometry but in other non-instanced geometry. Interestingly all other geometry drawn with VBO’s but not using vertex array objects (or rather, using the default 0 VAO) flicker, alternating between being drawn in one frame and not drawn in the next frame. In fact, it might not be related to the instanced arrays/vao combination itself, but maybe just the fact the instance render is the only scene object using VAO’s.
here’s my VAO setup code.
glGenVertexArrays(1, &m_model.m_vao);
glBindVertexArray(m_model.m_vao);
glBindBuffer(GL_ARRAY_BUFFER, m_model.m_mesh.m_vbo);
glVertexAttribPointer(SLOT_POS, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex,m_pos));
glVertexAttribPointer(SLOT_NRM, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex,m_nrm));
glVertexAttribPointer(SLOT_UV, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex,m_uv));
glBindBuffer(GL_ARRAY_BUFFER, m_model.m_instance.m_vbo);
glVertexAttribPointer(SLOT_ROW1, 4, GL_FLOAT, GL_FALSE, sizeof(Mat4x3), (void*)(offsetof(Mat4x3,m_row1)));
glVertexAttribPointer(SLOT_ROW2, 4, GL_FLOAT, GL_FALSE, sizeof(Mat4x3), (void*)(offsetof(Mat4x3,m_row2)));
glVertexAttribPointer(SLOT_ROW3, 4, GL_FLOAT, GL_FALSE, sizeof(Mat4x3), (void*)(offsetof(Mat4x3,m_row3)));
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_model.m_mesh.m_ibo);
glEnableVertexAttribArray(SLOT_ROW1);
glEnableVertexAttribArray(SLOT_ROW2);
glEnableVertexAttribArray(SLOT_ROW3);
glEnableVertexAttribArray(SLOT_POS);
glEnableVertexAttribArray(SLOT_NRM);
glEnableVertexAttribArray(SLOT_UV);
glVertexAttribDivisor(SLOT_ROW1, 1);
glVertexAttribDivisor(SLOT_ROW2, 1);
glVertexAttribDivisor(SLOT_ROW3, 1);
glBindVertexArray(0);
as a side note, the display list scene objects don’t flicker - just those drawn with plain old VBO’s, and even immediate mode.