158 CHAPTER 5: Textures^
chip, while the later ones use the more powerful PowerVR SGX GPU. The advantage of
the later ones is that it can accept highly compressed textures in their own format and
display them on the fly. This can save substantial memory while increasing framerate, by
compressing textures down as small as 1/16th uncompressed size.
Of course, this comes with one main caveat: images must have a square power-of-two
(POT) form. The compression works best on photographic type of images as opposed to
contrasty graphics.
Note Another interesting extra feature is found in the string GL_APPLE_texture_
2D_limited_npot GL. NPOT means “nonpower-of-two.” Remember that more recent
versions of iOS can use NPOT images? So if you have reason to use an NPOT image, check the
extensions beforehand and handle the results accordingly.
Here we’re going to generate and import a PVRTC. First you will have to compress your
existing files down to the PVR format using the a nice little tool that Imagination
Technologies, the manufacturer of the PowerVR graphics chips, used in all iOS devices.
You can fetch it at http://www.imgtec.com. Look for PowerVR Insider Utilities under the
developer’s section. It is called PVRTexTool.
Note Apple also supplies a texture convertor called texturetool. While it is only a command-
line based tool, it is very powerful in its own right and could be used to handle large batch jobs
if you had a lot of files to compress at once.
Do not be alarmed when you launch it! It might look like Windows NT, but there is
nothing wrong with your picture. It actually uses the X11 windowing platform that makes
it usable across many different operation systems.
To convert a texture to PVRTC, simply load it into the editor, and select the Encode
Current Texture button. That will open up a new dialog that will let you select which 3D
platform you want to encode to; in this case, select the OpenGL ES 1.x tab. Select either
the PVRTC 2BPP or PVRTC 4BPP button in the Compressed Formats section, and then
the encode button on the bottom.
That’s it!
Table 5-5 shows the formats generated by the tool. Even though you have a selection of
only two, four are possible depending on whether the source bitmap has alpha or not.
The 2BPP format means two bits-per-pixel while 4BPP means, well you guessed it, four-
bits-per-pixel.
Many other image formats supported as well, and those are covered in Chapter 9 in the
discussion on performance issues.