What would a 2D game be without a map; more precisely a tile map. A tile map is a full-size map composed of small quad polygons or tiles mapped with a piece of image. These tiles are made so that they can be pasted beside, repeatedly. We are now going to implement a tile map to draw a background. The rendering technique is inspired from the Android game Replica Island (see http://replicaisland.net). It is based on vertex and index buffer to batch tile rendering in a few OpenGL calls (thus minimizing state changes).
Tip
Tiled map editor
Tiled is an open source program available on Windows, Linux, and Mac OS X to create your own custom tile maps with a friendly editor. Tiled exports XML-based files with the TMX extension. Download it from http://www.mapeditor.org/.
Let's now implement our own tile map. The final application should look like the following: