PDA

View Full Version : Vertex Array Objects (vao)



ITISAGLN
02-22-2014, 05:58 AM
I am using OpenGL 4.3, Core:
In the OpenGL Programming Guide, 8th, Pg120, they have this:

for (i = 0; i < primcount; i++) {
if (count[i] > 0)
glDrawArrays(mode, first[i], count[i]);
}

This means many primitives ('primcount') are attached to one vao, right? Said, another way, there is one and only one bound vao. In the buffer bound to the vao, first[i] is the start offset & count[i] is the number of vertices. So, you just append each primitive's vertex position, color, normal, texture into a buffer sequentially? Keep track of the offset & number of vertices for each primitive and then use the loop.

If this is wrong, and instead each primitive is associated with one vao, they would have to have this:
for (i = 0; i < primcount; i++) {
if (count[i] > 0)
glBindVertexArray(vao[i]);
glDrawArrays(mode, first[i], count[i]);
}

I was able to render the second loop successively but not the first loop.
Any help is appreciated.

tonyo_au
02-23-2014, 03:06 PM
I don't own OpenGL Programming Guide but draw calls only make sense if the matching vertex buffer is bound (via vao) prior to the call.

ITISAGLN
02-24-2014, 05:04 AM
Thanks for responding to my post. ok.