PDA

View Full Version : Concept of VBO VAO and IBO..??



mkashif
10-03-2013, 02:36 PM
Salam, Hi guys,, i found many tutorials about how VBO's, and VAO's works, but i don't get the actual concept. Actually i beginner to Opengl in fact I have directly started the modern opengl, now let come to the actual question,

glEnableVertexAttribArray(0), some time they use it for disabling purposes, but some time they use it for indexing VAO, like

glEnableVertexAttribArray(0) => vertices
glEnableVertexAttribArray(1) => normals
glEnableVertexAttribArray(2) => colors,

plz reply for my question. i apologies if i have posted my question in wrong section, thanks, :)

Dark Photon
10-03-2013, 05:43 PM
Vertex attribute arrays are arrays of data you can feed into your vertex shaders, one element from each array at a time.

The "contents" of vertex attribute arrays can be provided to the GPU in either VBOs (GPU arrays), or in compatibility OpenGL, client arrays (CPU arrays). Note that GPU and CPU arrays is not quite correct -- it's actually driver-side and app-side, respectively. But you get the jist.

These vertex attribute arrays are bound in some form to vertex attribute slots, and these slots are enabled/disabled before you issue a batch draw call.

Now you can do these binds and enables (lazily of course) followed by a batch draw every time you need to render the batch. OR (in ordinary OpenGL) you can create a VAO to store off these binds and enables so that later all you do is bind the VAO and then issue your batch draw call. Binding the VAO does all the slot binds and enables internally (VAOs are just a binding speedup). Re VAOs, if you have an NVidia GPU you can use bindless vertex attributes instead of VAOs, which in my experience gives you even better performance.

So briefly:

VBOs - Store the "contents" of vertex attribute or index arrays
VAOs - Store the "bindings" and "enables" associated with vertex attribute slots and/or index list slots

mkashif
10-04-2013, 12:40 AM
thanks for reply,
Then what does this mean?

glEnableVertexAttribArray(1) => enable
glEnableVertexAttribArray(0) => disable

aren't the the 0,1,2,3 are the attributes slot in VAO for each VBO's? => position , color, normals

which attribute is going to enable and disable?

GClements
10-04-2013, 02:18 AM
thanks for reply,
Then what does this mean?

glEnableVertexAttribArray(1) => enable
glEnableVertexAttribArray(0) => disable

aren't the the 0,1,2,3 are the attributes slot in VAO for each VBO's? => position , color, normals

which attribute is going to enable and disable?
The above commands enable the arrays for attributes 0 and 1. To disable an an array, use glDisableVertexAttribArray().

mkashif
10-04-2013, 02:22 AM
Thank you very much. i was confused, now i get it , thanks