Search code examples
openglcolorsvbovertex-buffer

OpenGL: Lots of small VBO's okay or not?


I have a lot of objects but I want one of these objects (the one the mouse is hovering over) to "glow" (rapidly change colors).

So one way to do this is have each object have its own VBO. I will not have a color array. Then I will have like, a thousand VBO's each with about 20 quads... and if it's the selected object I will call glColor3f(blah,blah,blah) before it, else it will be the default color.

Another way is to have them all in one big VBO. I will have a color array. Then I will do something like, glBufferSubDataARB into the color array very frequently to make one object glow.

Which way is better and why? Also suggest another way if both ways are bad.


Solution

  • You know something? Just forget about the color array. A color array makes no sense, because you don't have a different color per vertex, but for entire groups of objects.

    Put all the vertex data into a single VBO, without any color data.

    Then loop through the colors (or object groups), for each one you'll call glColor3f and glDrawArrays, where the first and count parameters match the number of vertices belonging to objects of that color.

    When you move from the fixed-function pipeline to shaders someday, you'll just replace glColor3f by glUniform3f.