Pro OpenGL ES for iOS

(singke) #1

296 CHAPTER 9: Performance ’n’ Stuff^


needed to, just to ensure the behavior is easily predictable. But for commercial,
performance-intensive apps, try to remove any redundant calls in the release build.
Also, batch your drawing calls as much as possible.

Textures

A few of the texture optimization tricks have already been addressed, such as
mipmapping in Chapter 5 and making use of PVRTC textures. Others are just plain
common sense: textures take a whopping lot of memory. Make them as small as
possible and reuse them if needed. Also, set any image parameters ahead of loading
them, because they act as a hint to tell OpenGL how to optimize the information before
shipping up to the hardware.
Draw the opaque textures first, and avoid having a translucent OpenGL ES screen.
As a fairly simple example of how texturing can affect frame rates, the previous VBO
example gained about a 25-percent increase when I dumped the texture altogether.

Sprite Sheets


Sprite sheets (or texture atlases or font atlases) were briefly referenced in Chapter 8
when covering displaying text in an OpenGL environment. Figure 9-4 illustrates what a
sprite sheet looks like when used for rendering text to the screen.

Figure 9-4. Sprite sheet for 24-point Copperplate

This particular image was created using a free tool called LabelAtlasCreator. Besides the
image file, it will generate a handy plist that contains all of the placement details that are
easy to convert to texture space. Another one is the Java-based Hiero that can do fonts
with gradients. However, it is very slow. Perhaps the most robust one is ‘‘Angelcode-
Bitmap Font Generator,’’ for Microsoft Windows only, but it seems to be pretty popular.
The latter two tools generate a font metrics file in the .font format. It’s much less handy
than a .plist, but there are some free parsers floating about to handle it.
Free download pdf