Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How many VBOs do I use?

Tags:

opengl

vbo

So I understand how to use a Vertex Buffer Object, and that it offers a large performance increase over immediate mode drawing. I will be drawing a lot of 2D quads (sprites), and I am wanting to know if I am supposed to create a VBO for each one, or create one VBO to hold all of the data?

like image 255
LunchMarble Avatar asked Dec 28 '11 21:12

LunchMarble


People also ask

How do you use VBO?

Creating a VBO requires 3 steps; Generate a new buffer object with glGenBuffers(). Bind the buffer object with glBindBuffer(). Copy vertex data to the buffer object with glBufferData().

What is the difference between Vao and VBO?

A VBO is a buffer of memory which the gpu can access. That's all it is. A VAO is an object that stores vertex bindings. This means that when you call glVertexAttribPointer and friends to describe your vertex format that format information gets stored into the currently bound VAO.

What does a VAO do?

A Vertex Array Object (VAO) is an object which contains one or more Vertex Buffer Objects and is designed to store the information for a complete rendered object. In our example this is a diamond consisting of four vertices as well as a color for each vertex.

How VBO enhances the performance in real time rendering?

VBOs are intended to enhance the capabilities of OpenGL by providing many of the benefits of immediate mode, display lists and vertex arrays, while avoiding some of the limitations. They allow data to be grouped and stored efficiently like vertex arrays to promote efficient data transfer.


2 Answers

You shouldn't use a new VBO for each sprite/quad. So putting them all in a single VBO would be the better solution in your case.

But in general i don't think this can be answered in one sentence.

Creating a new VBO for each Quad won't give you a real performance increase. If you do so, a lot of time will be wasted with glBindBuffer calls for switching the VBOs. However if you create VBOs that hold too much data you can run into other problems.

Small VBOs:

  • Are often easier to handle in your program code. You can use a new VBO for each Object you render. This way you can manage your objects very easy in your world
  • If VBOs are too small (only a few triangles) you don't gain much benefit. A lot of time will be lost with switching buffers (and maybe switching shaders/textures) between buffers

Large VBOs:

  • You can render tons of objects with a single drawArrays() call for best performance.
  • Depending on your data its possible that you create overhead for managing a lot of objects in a single VBO (what if you want to move one of these objects and rotate another object?).
  • If your VBOs are too large its possible that they can't be moved into VRAM

The following links can help you:

Vertex Specification Best Practices

like image 101
micha Avatar answered Sep 28 '22 15:09

micha


Use one (or a small number of) VBO(s) to hold all/most of your geometry.

Generally the fewer API calls it takes to render your scene, the better.

like image 39
genpfault Avatar answered Sep 28 '22 16:09

genpfault