Jump to content
  • Advertisement
Sign in to follow this  
GamerYZ

VBO help!

This topic is 4419 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!