I’m doing a 2D turn based RTS game with 32×32 tiles (400-500 tiles per frame). I could use a VBO for this, but I may have to change almost all the VBO data each frame, as the background is a scrolling one and the visible tiles will change every time the map scrolls. Will using VBOs rather than client side vertex arrays still yield a performance benefit here? Also if using VBOs which data format is most efficient (float, or int16, or …)?
Share
If you are simply scrolling, you can use the vertex shader to manipulate the position rather than update the vertices themselves. Pass in a ‘scroll’ value as a uniform to your background and simply add that value to the
x(ory, or whatever applies to your case) value of each vertex.Update:
If you intend to modify the VBO often, you can tell the driver this using the
usageparam ofglBufferData. This page has a good description of how that works: http://www.opengl.org/wiki/Vertex_Buffer_Object, under Accessing VBOs. In your case, it looks like you should specifyGL_DYNAMIC_DRAWtoglBufferDataso that the driver puts your VBO in the best place in memory for your application.