My Blog

May 6, 2009

How to change frame buffer object pixel format on iPhone OpenGL ES 1.1

Filed under: Uncategorized — michaelneuhold @ 11:13 am

Last night I looked for some cheap performance improvements in OGL ES, and after stumbling over this article I was expecting a quick win… Turns out it took me about 2 FULL HOURS to google the correct way to change the pixel format. I use Xcode’s OpenGL ES Program Template, but it works the same for everything OGL ES1.1 on iPhone. Having it taken me that much precious time, I figured I’d write it down for myself and maybe for others with the same problem:

Set the drawableProperties property of your CAEAGLLayer instance like  this:

eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];

This sets the default format of RGBA8. As of now you seem to have only one other choice: kEAGLColorFormatRGB565

And that means 16bit color depth and omitting the alpha channel. As I understand it, that breaks Alpha Blending, so it may not be a viable option for everyone… It wasn’t for me because I do massive blending with the alpha channel for my sprite engine. Maybe you could make it work using Alpha Testing, although excessive use of alpha testing seems to be discouraged by PowerVR people and some developers for performance reasons.

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Create a free website or blog at WordPress.com.