I have a VAO with VBOs for various vertex attributes: vertex positions, vertex normals, and the element array VBO (all STATIC_DRAW), such that rendering an instance simply requires:
glBindVertexArray(vao);
glDrawElements(GL_TRIANGLES, <count>, <type>, 0);
However, I want to draw multiple instances of an object (I'm restricted to the OS X GL 3.2 core profile BTW) with different vertex texture (s,t) coordinates for each instance. The texcoord VBOs use the STREAM_DRAW hint (although I might get away with DYNAMIC_DRAW).
Is it more efficient to bind the VAO, bind the current texcoord VBO, and set the attribute pointer via glVertexAttribPointer
, finalize the VAO with glBindVertexArray(0)
and draw the new instance with different texture coordinates? Or does the cost of updating a VAO make this a poor approach? What about updating the texcoord VBO with glBufferSubData
in a bound VAO?
I'd really appreciate some feedback before benchmarking separate approaches, since the wrong choice will result in significant refactoring.