VBO help!

Started by
3 comments, last by GamerYZ 18 years ago
I'm trying to create a render engine that use VBO to store all the vert data for a Cell-shaded game. I plan to calculate the lighting for all the static objects in the world before creating the VBO, but I can't figure out what's the best way to do this for dynamic objects that can move around the world. I tried to look for tutorials on creating and drawing dynamic VBO using GL_DYNAMIC_DRAW_ARB, but nothing came up. Can anyone help me?
Advertisement
The VBO extention itself has a few samples in it, you might want to take a look at it if you haven't already.

Also, you only mention "move around the world". In this case, your objects are actually static (the vertex data in the VBO wouldn't change) -- only the modelview matrix used to position them changes. If you really need to change the vertices within your VBO, it's as simple as mapping the buffer into memory and updating what you need.
By "moving" I mean character animation, and moving around the lights in the world so different shading value needs to be calculated for the verts. Sorry I wasn't very clear on that.
In that case:

1) Map your VBO into system memory with glMapBuffer.
2) Update the vertex and color data as desired.
3) Unmap the VBO with glUnmapBuffer.
4) Draw primitives using the VBO.
5) Repeat for next frame.

One thing to keep in mind is that a mapped VBO cannot be drawn from. If you have performance problems, you might want to double-buffer your VBOs, drawing from one while you update the other.

Good luck!
Nice, thank you very much!

This topic is closed to new replies.

Advertisement