PDA

View Full Version : vertex array object question



_arts_
02-03-2011, 01:11 PM
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.

Alfonse Reinheart
02-03-2011, 02:03 PM
The Wiki page (http://www.opengl.org/wiki/Vertex_Array_Object) on this subject should clarify things.

_arts_
02-03-2011, 04:42 PM
OK, thanks for the hint.

ugluk
02-03-2011, 07:06 PM
I pretty much agree with Dark Photon on VAOs, pretty useless, use rather Rob Barris' VBO caching.

Alfonse Reinheart
02-03-2011, 07:11 PM
use rather Rob Barris' VBO caching.

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

ugluk
02-03-2011, 11:17 PM
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.

Alfonse Reinheart
02-04-2011, 01:33 AM
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.

_arts_
02-04-2011, 03:30 AM
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 ?