Before we can move ahead with this, there are two things you need. The first, is a source image that will be mapped onto. You can pull the one from the NeHe Lesson 6 C++ project, or you can use your own image. If you use your own image, it must be sized so that both directions are equal and are a power of 2, which means the image should be 2x2, 4x4, 8x8, 16x16, 32x32, 64x64, 128x128, 256x256, 512x512, or 1024x1024 pixels (which is the largest size texture supported on the iPhone).
There's a command-line tool that will create PVRTC images for you from source PNG files. That tool is located at the following location:
To make life easier, you might want to add /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ to your path variable. I use tcsh as my shell, so adding that to my path was just a matter of adding /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ to my .cshrc file (~/.cshrc). Here's what that line in my .cshrc file looks like:
set path= ( /usr/X11/bin /opt/local /opt/local/bin ~/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin /Users/jeff/bin /Developer/Tools /opt/local/bin /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ )If you're a bash person, then you would do this in your bash profile, located at ~/.bash_profile, and the syntax is a touch different:
export PATH="/opt/local:/opt/local/bin/:Users/jeff/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/Users/jeff/bin:/Developer/Tools:/opt/local/bin:/usr/local/pgsql/bin:/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/"What that will do is allow you to use texturetool from the command line without having to type the full path, just as if texturetool were sitting in your /bin directory.
Now, in Terminal, navigate to where your source PNG image file is using the cd command, then generate your PVRTC file with the texture tool, like so (in my case, the source file is NeHe.png:
texturetool -e PVRTC -o NeHe.pvr4 NeHe.pngRunning this will generate a file with a .pvr4 extension. You will not be able to view this image file in Preview.app, or the vast majority of other image editing or viewing programs (so make sure this conversion is the last step), but trust me, it's an image file. Save this file for the next lesson, lesson 06.
It may take a few days before I get Lesson 06 ported, though. The fact that our cube is made up of triangles, rather than quads is going to mean some trial and error with the texture coordinates.