Vertex Buffer Objects in OpenGL 2.1

(I pointed out 2.1, because my laptop will not go past this version. Perhaps I would have done it anyway with 3x and after introducing shaders as mandatory?).

Thanks to Wikipedia: http://en.wikipedia.org/wiki/Vertex_Buffer_Object I'm starting to understand how simple the use of VBO can be (am I still not sure about IBO?). Until now, I realized that the main reason for using them is the performance increase obtained due to the fact that the data is now stored in video memory.

What I would like to know is how I should use them in a practical context. For example, all I saw was setting up one Vertex buffer object and drawing one triangle or one cube, etc. What if I want to draw 2 or more? Have I created a new VBO for every object I want to draw? Or am I magically joining some static VBO that I install at an early stage?

+7
source share
2 answers

It depends, since the question is rather wide.

Using one VBO for vertex attributes, and for indices for each model / object / object / grid, is a direct approach. You can save all models in one VBO, so you do not need to bind buffers too often, but this leads to other problems when these models are not static. In addition, you can use several VBOs for each object, possibly one for dynamic data, one for static data or one for geometry data (position ...) and one for data related to the material (texCoords ...).

Using one VBO per object can have its (no) advantages, and using one huge VBO may not be such a good idea. It depends only on the specific application and how well these concepts fit into it. But for starters, a straightforward approach with one VBO per-object is not so bad. Just don't use one VBO per triangle;)

+5
source

It should be very simple - just add more data to VBO.

So, for example, if you want to display 3 triangles instead of 1, make sure you send 9 vertices to glBufferData . Then, to display all of them, use the glDrawArrays(GL_TRIANGLES, 0, 9); call glDrawArrays(GL_TRIANGLES, 0, 9); It really should be that simple.

However, the question about IBOs is that they really are not very different from VBOs, and I really would be used to using them. This is a really practical way to use VBOs. Since several triangles are usually designed to cover the same surface (for example, a cube requires twelve triangles), using only VBO causes many repetitions when specifying these vertices. Using the index buffer is still more efficient since any repetition is removed from the VBO. I found this one that gives a brief example of the transition from VBO to VBO / IBO only, and also gives a good explanation of the changes.

+2
source

All Articles