Texture Regions, Sprites, and Batches: Hiding OpenGL ES

Your code so far, for the cannon example, is made up of a lot of boilerplate, some of which can be reduced. One such area is the definition of the Vertices instances. It's tedious to have seven lines of code just to define a single textured rectangle. Another area you could improve is the manual calculation of texture coordinates for images in a texture atlas. Finally, there's a lot of highly-repetitive code involved when you want to render your 2D rectangles. There is also a better way of rendering many objects than having one draw call per object. You can solve all these issues by introducing a few new concepts:

  • Texture regions: You worked with texture regions in the last example. A texture ...

Get Beginning Android 4 Games Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.