With openGL 3 came a few cool features most of these are pretty small and quick to learn, VAOs are among these, I really didn’t want to write a full fledged tutorial about it before, but seeing as I’m changing the format to promote shorter and more article like posts, it seemed like as good as place as any to start.
There hasn’t been that much written about the vertex_array_object extension, also there is some confusion on where to use it and how.
Simply put it couldn’t be simpler, it’s used to make the daily life of using VBOs easier and the code prettier, earlier you had to call these three functions for each buffer to set up rendering, normally that would be at least 3.
Now add a few ifs and other miscellaneous code and setting up a VBO can be quite a hassle, now you still have to write all that code but only once and you can keep it in one place and you can make that code easier still.
Now all you have to do is call this code segment
unsigned int vao;
that’s it you’re done, now all you have to do is set it up once and each time you call glBindVertexArray(vao); those settings will be recalled, simple.
And when your done rendering call glBindVertexArray(0); so that you don’t accidentally overwrite it
So now rendering is a 3 line affair instead of about a page worth of code
glDrawArrays(GL_TRIANGLES ,0, 12);
And now you have learned to use VAOs.