Jump to content

How to Access POWERVR Hardware Acceleration on Your iPhone

+ 1
  Paul Zirkle's Photo
Posted Nov 17 2009 04:37 PM

On the iPhone, the specific hardware solution that OpenGL ES runs on top of is called POWERVR. The company that makes this chip (Imagination Technologies, or ImgTec for short) has released a supplemental API that you can use to get the most out of its hardware. This API is free to use and available for download from http://www.imgtec.co...powervr-sdk.asp. You can find additional utilities for handling POWERVR at http://www.imgtec.co...r-utilities.asp.

Vectors and matrixes

Conceptually, there is no real difference between using the PVRTVec3 and PVRTMat4 structures versus the simple float[3] and float[16] arrays OpenGL uses. In fact, wherever a float[3] is expected, we can use a PVRTVec3, and wherever a float[16] is expected, a PVRTMat4.

However, the PVRT structs also have overloaded operators, so we can do something such as this:

PVRTVec3 vecB = vecA * matrixA; //vector-matrix multiplication

//or this

PVRTVec3 vecC = vecA.cross(vecB); //cross-product

We will use the PVRT structs for convenience.

Model format

To take advantage of the POWERVR hardware, ImgTec has created the POD model format. It is a lightweight format that simply aligns the vertex, index, and texture data in the configuration expected by the iPhone’s OpenGL ES API.

Source code to use the format is available as part of the PVRT SDK. The class is named CPVRTModelPOD and it supports skeletal animation. To make using the class easier, we have created a Model class to wrap the PowerVR class. You can view the code in Model.h and Model.mm from the Chapter5Example.zip download.

You may notice that we use .mm files whenever we create classes that use the PVRT code. The .mm format tells Xcode to compile code with support for C++ syntax, which is required for PVRT.

3ds Max plug-in

To make the POD format easy to use, ImgTec has provided plug-ins for Maya and 3ds Max (two of the major modeling programs). Simply load a model in one of the editors and use the PVRGeoPOD plug-in to export the file as a .pod file.

If the original model was associated with a texture file, the .pod file will retain the same association.

Texture format

In addition to the POD model format, ImgTec has also created the PVR texture format. You can use the PVRTexTool utility to save textures as any format the POWERVR hardware supports.

The POWERVR hardware extends OpenGL to support decompression of the PVR format on the GPU hardware, making it a very efficient texture solution. For our game, we are using PVRTC4bb (PVRT compressed 4 bits per pixel).

Of course, if you are saving a model texture as a .pvr file, you will have to modify the .pod file to point to the new texture. You can use the PVRShaman utility for that.

iPhone Game Development

Learn more about this topic from iPhone Game Development.

What do you need to know to create a game for the iPhone? Even if you've already built some iPhone applications, developing games using iPhone's gestural interface and limited screen layout requires new skills. Loaded with descriptive examples and clear explanations, iPhone Game Development provides everything from game development basics and iPhone programming fundamentals to guidelines for dealing with special graphics and audio needs, creating in-game physics, and much more.

See what you'll learn


1 Reply

0
  CayaT's Photo
Posted Feb 09 2011 12:01 PM

Hi Paul,

Noob question: I was testing my PVRGeoPOD plugin and tried replacing the ship's pod file with another I exported from 3ds max 2010. When I ran the program on the simulator, the 3D object appeared as a white mask. I think I exported the .max file incorrectly. I noticed that the ship's pod file has a separate texture file. Do I have to make a separate texture file too?
I have attached the PVRGeoPod export parameters used. The new pod file opens up fine using the PVRShaman. I really appreciate any help you can give.
Thanks.

Attached Image