You might give an example of what youâre talking about. Linking multiple VBOs to the same VAO how? As separate vertex attributes? (Iâm trying to fit the âcall once the Drawâ part of your question into this.)
Sorry, I figured out that my question was badly posed.
Lets say that I have a VAO and two VBOs.
I have already done glGenBuffers and glGenVertexArray and filled the VBOs with my correct vertex data.
Now I have the current scenario:
Does the last bind, for VBO2, overwrite the previous bind , i.e. the VBO1, to the VAO?
In this case I can actually have only one VBO linked to the VAO. Is it correct?
Yes, exactly. Thatâs what happens. The GL_ARRAY_BUFFER context buffer binding point is left pointing to VBO2 at the end of this code.
Also note: you havenât changed VAO contents here. Binding something to GL_ARRAY_BUFFER is just a stopping off point to latching it to a vertex attribute binding (in the VAO) via glVertexAttribPointer(). And that latter binding is stored in the VAO.
No. See my last paragraph above.
A VAO tracks the:
vertex attribute array state and
index array state
needed to issue a draw call.
With recent hardware, you have at least 16 vertex attribute arrays, and each one can specify a buffer object which contains its values. Also, if youâre using indexed draw calls (e.g. glDrawElements), then the VAO can also track which buffer object contains its index values.
So if your driver supports 16 vertex attributes, then a VAO will track 17 different buffer object bindings.
Of course, while you could set the buffer object bindings for all enabled vertex attributes (and the index list) in a VAO to different buffer objects, the more common case (for static vertex attribute data at least) is to set the buffer object bindings for all enabled vertex attributes to the same buffer object and interleave the vertex attribute data. As far as the index list, it may be stored in the same buffer object which contains the vertex attribute arrays or a different one.
In terms of updating VAO state, vertex attribute buffer bindings are set with glVertexAttribPointer, and index list (aka element array) buffer bindings are set with glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, ... ).