I am currently working on a little OpenGL project. At the moment I am trying to find a good solution for rendering multiple objects. I have set up a terrain with its own buffers, which works just fine. Now I am at a stages where I want to fill this terrain with game-objects (tree, rock, ...) I already programmed the .obj loader for 3D models. But now the question: Is it good to have for each game-object its own buffers(vertices-buffer, indices-buffer, ...) and enable these each draw-call ? For me it seems a bit weird having like 100+ buffers in the v-ram and enable these after each other. Is this the way buffer should be used? Or should I combine these (small) buffer to a few (big) ones ?
1 Answer
The prevalent advise is fewer big buffers are better. Ideally one buffer big enough to hold everything. This also allows you to use 1 VAO per vertex layout. Along with persistently mapped buffers, it makes for a powerful GPU memory management in your application.
However, it does burden you with extra work to ensure your data is aligned correctly, that you don't overwrite data that's currently in use and that you calculate the correct offsets for things such as starting element and vertex.
However, using 1 or 2 buffers per object with a VAO to tie it all together is probably easier for small applications, which don't need the efficiency or out-right performance.