Re-using VBOs | Several objects

Hi,
I have switched to VBOs some time ago and read several tutorials about them.

After reading them I got some questions:

1.) Do I have to create a Float Buffer (for example) for every object I create? I guess that slows things down. What would be a smart way to combine them then? For example range checking? Like if objects are far away I combine them to one FloatBuffer? Wouldn’t a huge FloatBuffer be slow too?

2.) How do Indexed and Interleaved VBOs exactly work? I have seen that you use an IntBuffer to reuse vertices, but how does that work?

Thanks in advance.

  1. Far away scenery objects are often billboarded, which reduces their model down to a quad or a couple triangles. Furthermore, repeated objects are instanced, which means only having one object. Condensing multiple objects into an indexed buffer the way you might put multiple textures in an atlas is, I suppose doable, but I don’t know if this technique is common or has a name.

  2. An interleaved VBO puts vertices and their attributes in a single buffer so they alternate, as in (vertex,color,texcoord, vertex2,color2,texcoord2, etc), as opposed to separate buffers for each, or (even less common) separate contiguous sections of a buffer. All three of these approaches are able to be indexed – all an indexed buffer means is that you use an extra buffer containing the indexes of the vertices to draw instead of drawing the whole thing. This is handy if you have a lot of repeated vertices, since you can just repeat indexes, so it’s a sort of compression.

  1. No. Why would you need a float buffer for each object? Once you’ve uploaded data to a VBO there’s should be no need to upload it again. I guess this depends on what you’re drawing so please provide us with more info on that… If you want to draw a 3D model at two different places you’d just bind the VBO, set the matrix for the first instance, draw it, set the matrix to the second instance, draw it, e.t.c. You don’t need a float buffer per object, let alone a VBO per object.

  2. Sproingie covered interleaved data, but I’d like to add another thing about indexed vertex data. If you don’t use an index array, your GPU will transform 3 vertices, then build a triangle out of these. However, in a normal 3D model you’ll end up with many duplicate vertices. Indexed vertices allows you to present a set of vertices, and then an index array which builds triangles out of them. This allows you to reuse vertices shared between triangles. Without indices, you need 3 vertices processed for each triangle. With indices you can build more triangles for less vertices. From my experience the average triangle/vertex ratio is over 1.0, meaning that there’s more triangles than vertices. Example: Bob the dwarf. He has only 875 vertices but 1027 faces, meaning that each vertex is on average used more than 3 times. We’re saving so much vertex processing by using indices when rendering 3D models. It’s not really for compression, but for performance.