iOS OpenGL ES Extension Support

Supported iOS OpenGL ES ExtensionsThis weekend I was adding improved extension support to the Athena engine for iOS. There is a page on the Apple site that tells what device has what extensions but it hasn’t been updated since iOS 4.2.

So I ran through each version of GLES on a 1st Generate iPod Touch (MBX), an iPhone 4 (SGX) and an iPad 2 (A5), printing the returned string from glGetString( GL_EXTENSIONS ) for each device.

There are a some new extensions in iOS5, some of which are iPad2 specific. But you can see from the image, each newer device supports all the previous extensions.

I haven’t had chance to run it on an iPad1 yet, so it will be interesting to see if there is any difference. I’ve only wrote a rough idea of what version of what SDK is required to use them.

Anything with ‘***’ does not need the extension to work and has an implementation for that version of OpenGL ES.

For more information on each extension, most of them can be viewed here. Some of the newer ones in the EXT namespace are viewable on the what’s new page of the beta for iOS5, though the page calls them by the APPLE namespace still.

iPad 2

iPad2I recently got an iPad 2, and the first thing I did after connecting it to iTunes was to upgrade it to iOS5. After I did, iTunes gave me the error “This device is not registered as part of the iPhone Developer Program”.

This is easily fixed, all I needed to do was log into the developer portal and add the device UDID, however the screen telling me this was preventing me from getting the UDID.

Eventually I managed to retrieve it from the Organiser in XCode. Glad I didn’t brick it in less than 8 hours, I can now play around with airplay once I’ve flashed my AppleTV.

iOS Vector and Matrix Math: Part 2

Continuing on from my previous post iOS Vector and Matrix Math. I have managed to use matrix multiplication to transform a vector.

Vector Transform

Transforms a vector by a matrix

float matrix[16] =
	1.0f, 2.0f, 3.0f, 4.0f,
	7.0f, 6.0f, 9.0f, 10.0f,
	11.0f, 12.0f, 13.0f, 14.0f,
	15.0f, 16.0f, 17.0f, 18.0f
float vectorIn[4] = { 1.0f, 1.0f, 0.0f, 1.0f };
float vectorOut[4];
vDSP_mmul( &vectorIn[0], 1, &matrix[0], 1, &vectorOut[0], 1, 1, 4, 4 );

iOS Vector and Matrix Math

LEGO HazmatContinued on post iOS Vector and Matrix Math: Part 2.

For the past week or two I’ve been trying to reproduce the water effect of PixelJunk Shooter on the iPhone, however I seem to have reached a bottleneck with the collision detection used for repulsion when compressing.

I tried changing from Length to Length Squared, to Manhattan Distance, but it still grinded my framerate to 1FPS.

I decided to see if the Accelerate Framework in the iOS SDK had the vector math added to it yet, and to my surprise it had. It may have been added a while ago and I missed it. So I began to replace my math functions with the vector ones.

The strides are for the single precision functions are the number of floats. So for a stride of 8 bytes, you need to use 2.

float vec[2];
vDSP_vclr( &vec[0], 1, 2 );

This function sets the contents of a vector to zero. The equivalent function would be this

void vDSP_vclr( float * inVec, const int inStride, const unsigned int inCount )
	for( unsigned int idx = 0; idx < inCount; ++idx )
		*inVec = 0.0f;
		inVec += inStride;

I haven’t used the double precision version of the vector library yet so I don’t know if the stride is the count of doubles, or of floats.

I have managed to go from 17 FPS for 650 particles to 30 FPS (I originally had it at 300 particles at 30FPS but it turned out I was profiling in debug). A definite improvement from using the Accelerate library functions for 2d vector math. One of my main issues for getting 1FPS originally was I was island producer was hit testing each particle with itself so it always had the maximum number of particles on each island.

The next couple of pages on this post cover some of the functions (vector and matrix) and their equivalent C++ function.