
Unsigned int vaoID // Our Vertex Array Object I am calling these vaoID and vboID and am using these as private variables in our class. Our two variables are going to both be arrays of unsigned int’s and they are both going to be of length 1, so we have one VAO and one VBO. Void createSquare(void) // Method for creating our squares Vertex Array Object In that mindset, I am going to call the method createSquare. The method will be take no parameters and will return nothing, but inside of it we will be creating our VAO and VBO to draw a square. Open up opengl_3.h and inside of it we are going to create two variables and one method. The best part is we don’t have to do too much to get the output for this tutorial, which is a square on the screen. While I understand you may not have done the terrain tutorial which introduces VBO’s, I’m going to be starting from the basics and I will still be explaining everything as I go. OpenGL takes care of everything behind the scenes, and we get all the advantages that come with VBO’s and VAO’s. It just means that instead of a bunch of glVertex calls, we store all our vertices in an array and then place that into a VBO and then into a VAO. The best part, is that this isn’t too difficult to set up. This then means our application doesn’t have to transfer data to and from the graphics card and we get extreme increases in performance. This is how Direct3D works as it doesn’t have the immediate mode which OpenGL had up until OpenGL 3.x. What a VAO is, is a way to store object information straight on the graphics card, instead of sending vertices through to the graphics card as we need them.

The same goes for all types of data you usually send through as a VBO, including data for normals or anything that you need on a per-vertex rate.

With this ability, we can now store vertex data and colour data in separate VBO’s, but in the same VAO. VAO’s are Vertex Array Objects and allow you to store multiple VBO’s in one VAO. We could use VBO’s which I introduced in one of the terrain tutorials, or we could use a new feature in OpenGL 3+, known as VAO’s. What this means is we need a new way of transferring data to the graphics card to render our geometry. It also means no more calls to glVertex or glColor. With the removal of OpenGL states and the fixed function mode, we no longer have any glEnable calls, which means no glEnable(GL_TRIANGLES), or similar calls.
