title: OpenGL tile rendering: most efficient way?
body: <p>I am creating a tile-based 2D game as a way of learning basic "modern" OpenGL concepts. I'm using shaders with OpenGL 2.1., and am familiar with the rendering pipeline and how to actually draw geometry on-screen. What I'm wondering is the best way to organize a tilemap to render quickly and efficiently. I have thought of several potential methods: </p>
  
  <p>1.) Store the quad representing a single tile (vertices and texture coordinates) in a VBO and render each tile with a separate <code>draw*</code> call, translating it to the correct position onscreen and using <code>uniform2i</code> to give the location in the texture atlas for that particular tile;</p>
  
  <p>2.) Keep a VBO containing every tile onscreen (already-computed screen coordinates and texture atlas coordinates), using <code>BufferSubData</code> to update the tiles every frame but using a single <code>draw*</code> call;</p>
  
  <p>3.) Keep VBOs containing static NxN "chunks" of tiles, drawing however many chunks of tiles are at least partially visible onscreen and translating them each into position.</p>
  
  <p>*I'd like to stay away from the last option if possible unless rendering chunks of 64x64 is not too inefficient. Tiles are loaded into memory in blocks of that size, and even though only about 20x40 tiles are visible onscreen at a time, I would have to render up to four chunks at once. This method would also complicate my code in several other ways.</p>
  
  <p>So, which of these is the most efficient way to render a screen of tiles? Are there any better methods?</p>