I am confused with the point in generating/creating a Vertex Array Object (VAO) with:
glGenVertexArrays(GLsizei n, GLuint *arrays);
and
glBindVertexArray(GLuint);
Because I can still create a buffer object, say for vertices, and describe that buffer object with glVertexAttribPointer
and glEnableVertexAttribArray
without ever creating a VAO.
My question is if you do not have to actually create the VAO to describe the data in a buffer object, why would such sources as the OpenGL SuperBible 5ed include a call to create a VAO when creating VBOs? Are they only used for more advanced topics I have yet to discover, am I totally confused?
Also I first encountered this question when reading wikipedias entry on VBOs and their sample code includes no calls to glGenVertexArrays()
but they still describe the data with glVertexAttribPointer()
.Wiki VBO entry --
Example where VAOs are created for what reason?
Performance improvements.
In many cases, setting up your attributes on the host require a high number of API calls, and an important amount of validation inside the implementation.
Doing all those once, and using the VAO allow that work to be amortized.
See, for example, Graham Sellers' analysis for actual data.