Shai UI
Shai UI

Reputation: 51978

iPhone & iPad: Is an OpenGL ES Universal App a pain to write for multiple devices?

I've had experience writing a cocoa touch app as a universal app (for ipad, iphone) and it wasn't too hard. I only needed to use different .xib for each device but atleast it was the same binary.

Is it possible to have a universal opengl es app as well? Is it difficult given I have to have the resolution different for each devices (iphone 3gs, iphone 4, ipad)? So most probably my code would be different for each device???

Upvotes: 3

Views: 958

Answers (2)

Brad Larson
Brad Larson

Reputation: 170317

While difficulty is a subjective measure, I would argue that it is a simpler process to develop an OpenGL-ES-centric application for the various devices than one based on more standard user interface elements. Where an iPad version of a standard iPhone application may require a completely different interface layout, if you are doing fullscreen OpenGL ES drawing, you just simply need to have the rendering layer scale to the appropriate screen size.

For example, take a look at the code to my Molecules application (it's available under a BSD license). It is a universal iPhone / iPad application and shares a lot of code between the two interfaces. In fact, almost none of the OpenGL ES portion changes based on the platform.

When it comes to something like the Retina displays, you just need to add one little bit of code in your CAEAGLLayer-hosting view's initialization to account for the new scale factor:

if ([self respondsToSelector:@selector(setContentScaleFactor:)])
{
    self.contentScaleFactor = [[UIScreen mainScreen] scale];
}

Nothing else needs to change, and your OpenGL ES content will now render at the higher resolution.

Probably the biggest issue you will encounter is that by going to the higher-resolution displays you may find yourself being fill rate limited where you weren't before on the older iPhones. If you see the Renderer Utilization getting near 100% in the OpenGL ES instrument, that's what is happening. For the Retina displays, you may then want to not render at the full 2X scale factor, but something a little lower.

Upvotes: 6

westsider
westsider

Reputation: 4985

I can't speak to your particulars, but I have a universal app and it uses OpenGL-ES. For my purposes, glViewport() call takes care of things.

Upvotes: 0

Related Questions