Reputation: 151
So I recently learned about VAO (Vertex Array Object), and so far they seem pretty awesome, but I have a problem I cant seem to solve. I have a bunch of models, their vertex-states are stored in separate VAOs, so a single call to
glBindVertexArray(VAO);
is all that is needed to begin draw an instance of this. The problem lies in that I have to bind an additional VAO, one containing the data for a
glDrawElementsInstanced();
call. So it contains data like offset, UV-offset, color-overlay etc. When I bind this, the previous one seem to unbind itself, which makes sense in OpenGL I guess, but I'm not sure what to do to have both active?
The idea is to draw all static objects that shares the same model without uploading any data per-frame. Is this a wrong approach entirely?
Upvotes: 0
Views: 706
Reputation: 64283
When I bind this, the previous one seem to unbind itself, which makes sense in OpenGL I guess, but I'm not sure what to do to have both active?
Of course it unbinds. That is how OpenGL works. It is a state machine, and you want to have two states active at the same time.
The idea is to draw all static objects that shares the same model without uploading any data per-frame.
If they do not change, then do not change them. You just have to bind and activate the vertex components (as explained here).
Upvotes: 3