# When to use a vertex array and when to use a VBO?

I'm trying to learn about vertex arrays and vertex buffer objects, but I don't understand the differences in terms of:

• case-of-use (static geometry like terrains, geometry that changes every frame like a particle system, etc.)
• performance
• portability (old graphics card, consoles, devices like Android or iPhone, etc.)

some clarifications?

Here is a decent writeup about VBOs.

Performance

Here is a good overview of the calling semantics.

Here here is another good overview of performance issues; in it we see that VBOs are more performant than arrays.

The reason we prefer VBOs is that the data is loaded onto the card, and so you don't have to transfer it every frame. Depending on the type of VBO created, you can give the graphics driver hints on the usage (write-many, read-many vs. write-many, never-read, etc).

Usage

VBOs are really good for static geometry like terrain that you don't expect to change, or for instanced geometry.

Vertex arrays are good for data that changes frequently but that also is read by the host machine--so, for directly rendering data that is being manipulated (laser rangefinder data buffers, for example, are where I've used them) frequently. If you can get away with never reading the data on the host device (so, just pushing it out onto the card), VBOs in write-only mode are a good option.

Portability

Client Side Vertex Arrays These are available in OpenGL prior to 3.0, deprecated in 3.0, and gone in 3.1+. OpenGL ES supports them (OpenGL ES 2 does not).

VBOs These are available after OpenGL 1.5. These are the only way to store geometry data in OpenGL ES 2 (and so, WebGL).

• In that PerformanceTuning.pdf, it says that VBOs "Can hurt performance in non-optimal cases"... but it doesn't elaborate. Any idea what those cases are? I have a case where I need to update the geometry every frame, so I'm wondering if a vertex array would be better or worse than a VBO in that case. Thx. – sidewinderguy Apr 25 '12 at 18:07
• read opengl.org/sdk/docs/man/xhtml/glDrawElements.xml and opengl.org/wiki/GlDrawElements - Vertex Arrays AREN'T deprecated nor removed, they are still supported as of OpenGL 4.x; get your facts straight, mate, because what you're spreading is just misinformation – vaxquis Jan 15 '14 at 14:26
• @vaxquis Client side vertex arrays are deprecated. Server side vertex arrays are not. VAOs are different thing and are meant to save state. Nothing was wrong in the post, though could be more accurate if it state client side. But I guess that was implicit. – concept3d Jan 15 '14 at 15:27
• "Client side vertex arrays are deprecated. Server side vertex arrays are not." "Vertex Arrays These are available in OpenGL prior to 3.0, deprecated in 3.0, and gone in 3.1+." "you can prespecify separate arrays of vertices (...) and use them to construct a sequence of primitives with a single call to glDrawElements. Core in version 4.4" - I see contradiction in these statements. – vaxquis Jan 15 '14 at 20:55
• Plus, before saying something "is deprecated", specify the source of such statement, preferably in official document. Pointing from StackExchange to StackOverflow as a proof is NOT the way science works, and defending with "I guess that was implicit" is not an argument. Nobody asked about client/server arrays, the question was about vertex array in the broadest sense, as compared to VBO. Btw, I haven't said anything about VAO, where's that idea from? – vaxquis Jan 15 '14 at 20:59

(I'm adding this here due to the the fact that ChrisE's answer is highly ambiguous, which is unfortunately due to the ambiguity of the original question. However I'm going to assume the OP's question should have been titled "when to use VAOs and when to use VBOs".)

Vertex Buffer Objects (which really aren't dissimilar from other types of Buffer Objects, for example Uniform Buffer Objects) provide a means for uploading vertex data to the graphics hardware.

Vertex Array Objects are used in addition to VBOs in order to improve client-side (CPU-side) performance, by reducing the number of calls needed to rebind individual vertex buffers and re-set vertex attributes every time you want to change to render in a certain way. Instead of doing all that work every frame, you do it once (at initialisation), and then simply rebind the appropriate VAO for each (set of) draw call(s) that use the associated vertex attributes.

In spite of this, using VAOs does not release you from the additional responsibility of having to do glBindBuffer + glBufferData for any data that changes each frame, for instance, game entity positions / rotations / transform matrices. It is only when you have entirely static data that you need only do glBindVertexArray(&vao) -> glDraw*(...) -> glBindVertexArray(0) to render.

• +1 VAO is a terrible and confusing name, and it always reminds me of what a mess openGL has become. – concept3d Dec 22 '14 at 10:04
• I also remember going with a discussion regarding this question (most of it was deleted). Again the problem is with OpenGL's horrible terminology. I also edited Chris answer to be more accurate. – concept3d Dec 22 '14 at 10:10