CHAPTER 5: Textures (^159)
Table 5-5. The Four PVR Formats Generated by PVRTexTool
Format Compression Details
GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 8:1 4 bits/pixel with alpha
GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG (^) 6:1 4 bits/pixel no alpha
GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 16:1 2 bits/pixel with alpha
GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 12:1 2 bits/pixel no alpha
Say you have a 512 ̄512 PNG texture that will consume 1 MB of memory. The least
compression using PVRTexTool will take less than 200 KB. The greatest compression
format, 2 bits/pixel with alpha, would be a mere 64 KB.
PVRTC textures are also readable by GLKTextureLoader() but will fail to load if you
specify GLKTextureLoaderGenerateMipmaps in the option dictionary. However, you can
use PVRTexTool to embed a mipmap chain in the host file for you. Because the
compression is a lossy one, you can see the various resolution files pop in and out when
using the preceding code, more readily than the sharper images.
Note Because PVRTC is hardware specific, Apple has issued a precautionary note to not
necessarily rely on PVRTC support in future devices. This simply means that Apple may at
some point use a different GPU manufacturer that is not likely to support another company’s
format.
More Solar System Goodness
Now we can go back to our solar-system model from the previous chapter and add a
texture to the Earth so that it can really look like the Earth. Examine Planet.m, and swap
out init() for Listing 5-6.
Listing 5-6. Modified sphere generator with texture support added
-(id) init:(GLint)stacks slices:(GLint)slices radius:(GLfloat)radius //1
squash:(GLfloat) squash textureFile:(NSString *)textureFile
{
unsigned int colorIncrment=0;
unsigned int blue=0;
unsigned int red=255;
int numVertices=0;
if(textureFile!=nil)
m_TextureInfo=[self loadTexture:textureFile]; //2