I've just done some reading about VAO's and it looks like they can be a decent improvement on my current rendering routine. Currently all of my rendering is done using simple interleaved VBO's with indices (position, normal, uv). My model class has a vector of VBO's (each one relates to a specific sub object in my model format) and i was thinking i could just use a single VAO to describe all of them? I'm not sure however if a VAO can be used for multiple VBO's though.
Currently my drawing routine looks like (don't have code with me):
void drawModel(Model* model)
{
for (int i = 0; i < model->getVBOList(); i++)
{
VBO vbo = model->getVBOList();
If i had a vertex array object bound to all of these VBO's would it be possible to simply draw them all by binding the VAO and calling drawElements again?
That's what VAO's are for, yes. They store all vertex array bindings in one object, so as long as the bindings (pointers, enabled attributes, attribute locations and such) remain the same, you only need to bind the VAO and draw.
One more question, should i still be using glDrawElements()? The parameter takes the size of my index buffer, but i'm going to be drawing multiple VBO's each with their own index buffer?
You still have to use glDrawElements, it is not stored in the VAO. The element buffer object is a binding stored in the VAO though, so you don't have to rebind the index buffer every time.
The parameter you're talking about is not the size of the index buffer, but how many indices you want to draw. There is a distict difference between the meaning of the two, especially if the index buffer stores more indices than you want to draw in one single draw call.
The index count parameter is the number of indices to draw from the currently bound index array, not the total amount from all index arrays you have ever bound. Besides, there is only one index array that can be bound anyway, so your for-loop is overwriting the binding each loop, and then you're trying to draw more than what it contains.
You need one VAO per object in your code. And by object, I mean whatever goes in one iteration of your for-loop. Likewise, you need a for-loop to loop over all VAOs.