vertex array object question

Hi,

I’m trying to implement vertex array objects in some program.

If I understood correctly the specs and the wiki, VAO helps to avoid calling glVertexPointer and such and/or glVertexAttrib for the rendering since it stores them on its own.

So, my first guess is that VAO stores the glEnableVertexAttribArray and similar functions (to my understanding, this is a vao state). Am I right ?

Second, for a single VBO I can bind it several times but with calling one, two or three different calls to VertexAttribPointer (for example glVertexPointer the first time, then glVertexPointer with glNormalPointer the second time, and so on) depending on my program states. How is it possible to use VAO under such conditions ?

Finally, should I (is it possible to) create several VAOs for a single VBO depending on what vertex attrib I need to use ? Can/Should I overwrite glEnableVertexAttribArray (even if stored in VAO) ?

Thanks in advance.

The Wiki page on this subject should clarify things.

OK, thanks for the hint.

I pretty much agree with Dark Photon on VAOs, pretty useless, use rather Rob Barris’ VBO caching.

use rather Rob Barris’ VBO caching.

That has to do with streaming data to buffer objects. It’s completely orthogonal to using VAOs.

In its original form yes, but you can use it as an alternative to VAO and/or bindless. Just load up vertex attributes/indices as they are needed, orphan and reload if the VBO is not large enough.

but you can use it as an alternative to VAO and/or bindless. Just load up vertex attributes/indices as they are needed, orphan and reload if the VBO is not large enough.

Not large enough to what? We’re talking about static data here. Except in the cases of streaming, there’s nothing to “load up”.

And that still doesn’t change the fact that uploading data has nothing to do with whether or not to use VAOs. It’s not like VAOs prevent you from uploading data or streaming or anything. Orphaning a buffer does not invalidate a VAO.

I’ve implemented them in my program. From what I could saw, there’s absolutely no difference at all in the rendering (but certainly my program is really cpu driven).

What I could say is that VAO change a lot the manner of doing things with GL: enabling states without disabling them (talking about EnableVertexAttrib)… or maybe I misunderstood something else about VAO ?

Another thing is that maybe it’s a bit faster, at least, less gl commands are needed to render, but in another side it consumes a lot more of memory: storing all the states in memory whereas without them we just call functions which don’t use memory “at all”.

Actually my guess about VAO is that maybe they would be faster and / or more effective if we use very few VBO and several or many VAO for a single VBO. What makes me think like this is that I think VAO must bind VBO on its own and activate states and pointers to VBO (and desactivate them on VAO switch or on VAO unbind). So maybe if several VAO use the same VBO, the VBO binding will be done only once, for the first one, the same for enable vertex attribs states. Or maybe I’m wrong again here ?