I have a VBO storing some data in my game. The thing is, the data can change at a rate of about a second. The data is not fixed size, meaning that some objects will sometimes be visible, sometimes invisible and could even have a different polygon count. I'm trying to figure out how I could do that efficiently using VBOs. In immediate mode, I would simply not call the render method of the single objet, and it would simply not appear! And if I needed more polygons, I would just... call glVertex2f more often! I understand why using immediate mode is really bad in performance, but I really can't think of any good way to "build" the VBO.
I thought about using a list, append the vertices to the list and then create the vbo, but this would have, I think, three drawbacks. More CPU intensive, requires more memory copying, and would require me to recreate (I could work this out) the VBO every time, since I don't know the size before building the lists!
Is there a common way of building a VBO for many small objects without using a list?
Some pseudo code:
void GlobalRender()
{
foreach (chunk in chunks)
{
if (chunk.RequiresUpdate)
{
chunk.UpdateVBO(); //In there, that's where I don't know how large I'll need my VBO to be.
}
chunk.Render();
}
}
void UpdateVBO() //The code called above
{
foreach (node in nodes)
{
if (node.Visible)
{
//Emit vertices from here!
}
else
{
//There's nothing here really, just pointing out that there could be no vertices for a single node
}
}
}