O'Reilly logo

Beginning Android 4 Games Development by Robert Green, Mario Zechner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required