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) 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.