PDA

View Full Version : how to Use VBO the right way?



jmanuelexe
07-13-2012, 09:13 PM
Hello, I have a question on which case to use VBO

I read some tutorial and learn how to make it work, but I have some doubts, on when and how to use VBO for example.

1-I am assuming for a mesh that uses skeletal or vertex animation is not convenient because of all vertices are calculate very frequently, right?
2-do I have to create a VBO for every mesh in the world(terrain, builds, trees, etc) will everything fits is there a way I can know how much memory I have left to see when I can use more VBO's or do I have to re-use the existing one and override the data?

Nick Wiggill
07-14-2012, 04:24 AM
Yes, you can use VBOs for animation. Use GL_DYNAMIC_DRAW or GL_STREAM_DRAW. When data changes, write it using glBufferSubData or glMapBuffer. However you may wish to animate in a simpler way, such as by having every frame of animation stored in a large contiguous VBO, in to which you would offset.

The only time you can combine objects' meshes into a single, larger mesh is when you know they will not translate / rotate / scale in relation to one another. This is because any transformations you apply to one vertex in the subset you intend to draw, will cause all other vertices to be thus transformed, as well. So a house might be combined into a terrain mesh, but a person certainly could not be combined into that same mesh, since they use different transformation matrices.

jmanuelexe
07-16-2012, 08:07 AM
so do you think VBO with GL_DYNAMIC_DRAW or GL_STREAM_DRAW will still be faster than VA even when it will be constantly copying the mesh data, is it ok to create a VBO for every object on the scene?