Is it better to create 1 VBO for a single tile and render it n-Times in every different position, or render one huge VBO that represents
the whole "world"
Less VBOs are usually better for performance (less draw calls) but are also harder to manage.
1 VBO per tile seems an overkill to me especially if you have a lot of tiles. 1 VBO to represent the whole world might or might not be ideal (usually it's not). You may want to use multiple VBOs especially for tiles that do not share the same material and texture. So I would say render tiles in one VBO when they:
- Share the same material.
- Tiles with spatial coherency which makes other operations such as
transformation and frustum culling tiles much more intuitive).
Depending on the answer above, what is the best way to draw a
"linegrid". Overlay with the same vbo using the respecting
polygon.mode, or is there a way to let the shader to this?
If I understand your question correctly just use the same VBO in a different draw call with different polygon mode supposedly glPolygonMode(GL_FRONT, GL_LINE)
and revert to the original Polygon mode after that. As a note you might need to use Polygon offset to avoid Z-Fighting problems.
How would frustum-culling or mouse picking work then, do i need to keep the
VBO-data in memory?
You usually test against a bounding volume before testing the actual mesh you can store the bounding volume in world space or local space and do your intersection test accordingly.
If you want to test the actual mesh you can map your buffer using glmapBuffer
and glUnmapBuffer
to get pointer to your actual mesh data once it's stored on the gpu memory, or you can keep a copy of your mesh data in your main memory.