As someone who is just getting his feet wet in parts of OpenGL that don’t lie between glBegin() and glEnd(), I’m curious what the most efficient method of rendering a square grid of tiles would be. Currently, I figure out which tiles are actually visible on screen, then loop through them all, binding the appropriate texture, applying a translation, then calling glDrawArrays(). This, as is becoming incredibly obvious to me, is very slow.
I’ve seen that I should probably be dynamically building a texture atlas instead of rebinding textures all the time, and then using texcoords to pick my texture.
I’m curious what method I should use to render only tiles that are visible on-screen at any given time. If I was always rendering the entire thing, I’d just make a VBO with every possible vertex and another buffer with the proper indices, and just render that each frame. Would it be reasonably efficient to deal with a moving camera by still making a VBO with every possible vertex and then a changing index buffer as the camera moves around? Or am I approaching this the wrong way? Would it be reasonable to have a texcoord buffer changing each frame, or would it be smarter (if slightly more of a memory hog) to keep the texcoords for the entire world in memory along with the vertices? (Also, are all these options possible? I haven’t spent enough time perusing the buffer objects documentation to know.)