tags:

views:

442

answers:

2

I'm trying to write a game that deals with many circles (well, Triangle Fans, but you get the idea). Each circle will have an x position, a y position, and a mass property. Every circle's mass property will be different. Also, I want to color some groups of circles different, while keeping a transparent circle center, and fading to opaque along the perimeter of the circles.

I was told to use VBOs, and have been Googling all day. I would like a full example on how I would draw these circles and an explanation as to how VBOs work, while keeping that explanation simple.

+1  A: 

I have not implemented VBOs myself yet, but from what I understand, they work similar to Texture Buffer Objects.

What are those? They are those objects that you generate using glGenTextures(). glGenBuffersARB() does similar thing. Same should be with glBindTexture() and glBindBufferARB().

So what are they and what they do? You can actually use glTexture2D() each frame to set up a texture. TBOs serve to reduce traffic between GPU and main memory; instead of sending entire pixel array, you send just the "OpenGL name" (that is, id) of the texture object which you know to be static.

VBOs serve similar purpose. Instead of sending the vertex array over and over, you upload the array once using glBufferData() and then send just the "OpenGL name" of the object. They are great for static objects, and not so great for dynamic objects. In fact, many generic 3D engines such as Ogre3D provide you with a way to specify if a mesh is dynamic or static, quite probably in order to let you decide between VBOs and vertex arrays.

For your purposes, VBOs are not the right answer. You want numerous simple objects that are continuously morphing and changing. By simple, I mean those with less than 200 vertices. Unless you intend to write a very smart and complex vertex shader, VBOs are not for you. You want to use vertex arrays, which you can easily manipulate from main CPU and update them each frame without making special calls to graphics card to reupload the entire VBO onto the graphics card (which may turn out slower than just sending vertex arrays).

Well then: here's a quite good letscallit "man page" from nVidia about VBO API. Examine it!

Ivan Vučica
Thanks! I think I'll look into Vertex Arrays then.
Eddie Ringle
A: 

good vbo tutorial

What you're doing looks like particles, you might want to google "particle rendering" just in case.