1
votes

So Let's say I have 100 different meshes that all use the same OpenGL shader. Reading OpenGL best practices apparently I should place them into the same vertex buffer object and draw them using glDrawElementsBaseVertex. Now my question is, if I only render a fraction of these meshes every frame, am I wasting resources by having all these meshes in the same vertex buffer object? What are the best practices for batching in this context?

Also are there any guidelines or ways I can determine how much should be placed into a single vertex buffer object?

1

1 Answers

2
votes

if I only render a fraction of these meshes every frame, am I wasting resources by having all these meshes in the same vertex buffer object?

What resources could you possibly be wasting? The mere act of rendering doesn't use resources. And since you're going to render those other meshes sooner or later, it's better to have them in memory than to have to DMA them up.

Of course, this has to be balanced against the question of how much stuff you can fit into memory. It's a memory vs. performance tradeoff, and you have to decide for yourself and your application how appropriate it is to keep data you're not actively using around.

Common techniques for dealing with this include streaming. That is, what data is in memory depends on where you are in the scene. As you move through the world, new data for new areas is loaded in, overwriting data for old areas.

Also are there any guidelines or ways I can determine how much should be placed into a single vertex buffer object?

As much as you possibly can. The general rule of thumb is that the number of buffer objects you have should not vary with the number of objects you render.