In this post, we'll be creating the 2 VBOs that will allow us to pass our vertex data as well as the indices describing the shape directly to the GPU's memory. VBOs will make drawing much faster since you won't need to pass that data every time you want to draw. What you still need to do is bind those buffers and "describe" the data so that OpenGL can understand how to use it as an attribute in your shader program.
We'll also be creating a VAO, which will store the set of bindings. So, instead of binding the first VBO and describing it, as well as binding the second one and describing it, we'll just bind the VAO, and everything else will be done for us inside OpenGL.
First, add these 3 variables in your private interface:
Here's the code to create the VBOs and VAOs:
Now, there's one last thing you can do in the ViewDidLoad method, which is set up the Projection transformation matrix, and the ModelView transformation matrix's initial state (if you want anything to move, you'll have to modify for sure). This will be your first time using GLKit (Yay!). To do that, first add these two variables in your private interface:
As noted by Youpitou, GLKMatrix4MakePerspective takes the fovy in radians, and I used 45 degrees instead. If you want to get pi/4, then you should use GLKMathDegreesToRadians(45.0f) instead.
With the ModelView matrix, I position the object relative to the viewer. We call it the eye coordinate space. The Projection matrix will distort the objects to make them appear smaller as they are further away from the viewer (to imitate reality).