OpenGL VBO and/or Vertex Arrays

Started by
3 comments, last by V-man 13 years, 2 months ago
I'm having trouble sorting out the difference between Vertex Arrays and Vertex Buffer Objects in OpenGL. Tutorials on the web seem to use the terms interchangeably, which I think is incorrect?

I have some notes from my programming class that state "[A VBO] is an array of (possibly interleaved) vertex attributes....can be stored in video memory." The notes also say that "[Vertex Array Objects] Despite the name, do not store vertices. Used to store OpenGL state attributes. May contain a reference pointer to a VBO."

As far as I understand, a VBO holds geometry data (Vertex coordinates, Texture coordinates, Vertex colour, Material, etc) and may be stored on the graphics hardware, rather than in main memory. So my question is, what is the function of a Vertex Array Object?

Thanks in advance :)
Advertisement
Vertex arrays is the concept of storing vertices in an array for efficient drawing (includes glDrawElements for drawing, and glVertexAttribPointer to set an attribute array, for example). In old versions of OpenGL, the vertex arrays were stored in system memory and you had to manage the arrays yourself. In later versions, vertex buffer objects were introduced which are buffers managed by OpenGL instead so that you had the possibility to chose better storage places for your arrays (includes glGenBuffer to allocate a buffer object and glBufferData to copy data to the array, for example). So the terms are not the same thing; one refer to the mechanism of drawing your vertices stored in arrays, while the other is a way to manage where the arrays are stored, and they complement each other.

Vertex array objects, on the other hand, is an object that stores vertex array bindings. Instead of setting up each pointer and enabling the arrays all the time, you can just store the binding states in a vertex array object. Each time you bind the vertex array object, thecorresponding vertex array pointers are automatically set and enabled.
guys, you have to be carfull^^
don't mix up Vertex Arrays and Vertex Array Objects(VAO).


The first is the same as vertex Buffer Objects, but instead of storing the data on the server(GPU) it is stored on the client, so all the vertex data has to be send every frame to the GPU.


VAO on the other hand is a new eature of OpenGL3 (also as a extension available under OpenGL2). this is a state object which let you save all the state what u usually have when using Buffer Objects for vertex data.
In a VAO the vertex pointers and their buffers are stored, so instead of setting each vertex pointer it's buffer and enabling their client state u just have to bind the VAO.(Instead of maybe 10 calls to draw one object you only need 2)
Ah I see, Vertex Arrays and Vertex Array Objects are entirely different - that makes a lot more sense!

So what "state" information would be stored in the VAO? Colours, material, texture-coordinate and normal data? Should VBO's be used only to store the coordinate data of vertices?
http://www.opengl.org/wiki/Vertex_Array_Object
opengl.org/wiki/Vertex_Array_Object
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

This topic is closed to new replies.

Advertisement