# How many VBOs should I use and should I keep a copy of their data?

Firstofall, I am sorry if my question is to broad.

I am developing a tile based game and switched from those gl.Begin calls to using VBOs.

This is kind of working allready, I managed to render a hexagonal polygon with a simple shader applied.

What I am not sure is, how to implement the "whole" tile concept.

Concrete the questions are:

• 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"

• 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?

• How would frustum-culling or mousepicking work then, do i need to keep the VBO-data in memory?

• can you rephrase your second question ? I don't think I get it – concept3d Nov 10 '13 at 9:24

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.

• You got the second question right. Thank you. Though im not sure if I understand you correctly. I want to create a map which is kind of big, for an indutsry simulation. Something like Railroad Tycoon. Lets say i define 3 Materials: Rural, Country and Mountians. This would still mean i got 3 "big" vbos then ?! – CSharpie Nov 10 '13 at 9:51
• Nevermind, I understand now. – CSharpie Nov 10 '13 at 10:07
• I think you also need to take spatial coherency into account. – concept3d Nov 10 '13 at 10:32