The OpenGL Wiki: Vertex Specification states that:
Note: The
GL_ARRAY_BUFFER
binding is NOT part of the VAO's state! I know that's confusing, but that's the way it is.
Below is how I use the VAO, which seems to work as intended. What is wrong here? My understanding of OpenGL (or OpenGL Wiki), my OpenGL driver (OSX 10.9) or the OpenGL Wiki?
// ------ Pseudo-code ------
// setup
[...]
glBindVertexArray(vertexArrayObjectIdx1);
glBindBuffer(GL_ARRAY_BUFFER, vertexBufferId1);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBufferId1);
for each vertex attribute
glEnableVertexAttribArray(...);
glVertexAttribPointer(...);
glBindVertexArray(vertexArrayObjectIdx2);
glBindBuffer(GL_ARRAY_BUFFER, vertexBufferId2);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBufferId2);
for each vertex attribute
glEnableVertexAttribArray(...);
glVertexAttribPointer(...);
// rendering
[...]
glBindVertexArray(vertexArrayObjectIdx1);
glDrawElements(...);
glBindVertexArray(vertexArrayObjectIdx2);
glDrawElements(...);