Retina Resolution

iOS Snow GlobeWhile working on an app to release at Christmas, I realised that I hadn’t been using the correct resolution when I took a screen and it was still the ordinary non-retina size.

At first I thought it was something to do with multisampling, but it turns out that the EAGL layer does not automagically resize itself to the correct size when using the iPhone4.

To get it to do this, you just need to set the contentScaleFactor on the UIView that holds the EAGLView.

//eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
//                                [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking,
//                                kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat,
//                                nil];
if( [[UIScreen mainScreen] respondsToSelector:@selector(scale)] )
	self.contentScaleFactor = [[UIScreen mainScreen] scale];

The scale factor can be gotten from the UIScreen, however the scale factor doesn’t exist on older SDKs, so if you want to maintain backwards compatibility, wrap it in a respondsToSelector.