views:

536

answers:

1

What are the necessary steps to update an existing OpenGL ES 1.1 based 2D iPhone game to be compatible w/ the iPhone 4's retina display? I'm still using the Texture2D class that came w/ Apple's CrashLanding (download) sample code.

After reading Apple's documentation, watching the WWDC video (session 134 "Optimize Your iPhone App for the Retina Display"), and looking at Cocos2D sample code I'm still confused.

I believe the required steps include:

  • passing high-res artwork (w/ "@2x" appended) to [UIImage imageNamed:@"image.png"]
  • changing the "contentScaleFactor" from 1.0 to 2.0 (where?)
  • updating the arguments to glOrthof to include the contentScaleFactor
  • adjusting the size of the glViewport

Please note that I'm relatively new to OpenGL.

Thanks for your help!

+6  A: 

You should keep the 320x480 image, and provide the 640x960 image with a different name. Suppose the 320x480 image is called foo.png, then name the 640x960 one [email protected].

The system will then automatically select the higher resolution one on iPhone 4, without any change in code — assuming you were using [UIImage imageNamed:@"foo.png"].

KennyTM
Ok thanks. The additional artwork w/ the @2x naming is being loaded on the iPhone 4 (and not on the 3G... as expected). However the high-res artwork is much larger than the screen on the iPhone 4. I think I need to adjust the contentScaleFactor... I'm just not sure where.
MrDatabase
MyUIView.contentScaleFactor is what you're looking for — set it to 2.0
pop850