What are Vertex Array Objects?

“Vertex Array Object” is brought to you by the OpenGL ARB Subcommittee for Silly Names.

Think of it as a geometry object. (As an old time SGI Performer programmer, I call them geosets.) The instance variables/members of the object are your vertex pointer, normal pointer, color pointer, attrib N pointer, …

When a VAO is first bound, you assign these members by calling

glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer...;
glEnableClientState(GL_NORMAL_ARRAY); glNormalPointer...;

and so on. Which attributes are enabled and the pointers you supply are stored in the VAO.

After that when you bind the VAO again, all the those attributes and pointers also become current. So one glBindVertexArray call is equivalent to all the code previously needed to set up all the attributes. It’s handy for passing geometry around between functions or methods without having to create your own structs or objects.

(One time setup, multiple use is the easiest way to use VAOs, but you can also change attributes just by binding it and doing more enable/pointer calls. VAOs are not constants.)

More info in response to Patrick’s questions:

The default for a newly created VAO is that it’s empty (AFAIK). No geometry at all, not even vertexes, so if you try to draw it, you’ll get an OpenGL error. This is reasonably sane, as in “initialize everything to False/NULL/zero”.

You only need to glEnableClientState when you set things up. The VAO remembers the enable/disable state for each pointer.

Yes the VAO will store glEnableVertexAttribArray and glVertexAttrib. The old vertex, normal, color, … arrays are the same as attribute arrays, vertex == #0 and so on.

Leave a Comment