Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update 2D iPhone game to be compatible w/ iPhone 4's retina display?

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!

like image 691
MrDatabase Avatar asked Jul 26 '10 06:07

MrDatabase


1 Answers

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"].

like image 139
kennytm Avatar answered Jan 25 '23 22:01

kennytm