Skip to content
Snippets Groups Projects
Commit 72757afe authored by Maxime Graulich's avatar Maxime Graulich
Browse files

iOS: fix openGL on retina display

parent 5665d2e7
No related branches found
No related tags found
No related merge requests found
...@@ -28,9 +28,24 @@ ...@@ -28,9 +28,24 @@
//The GL view is stored in the nib file. When it's unarchived it's sent -initWithCoder: //The GL view is stored in the nib file. When it's unarchived it's sent -initWithCoder:
- (id)initWithCoder:(NSCoder*)coder - (id)initWithCoder:(NSCoder*)coder
{ {
int w = 320;
int h = 480;
float ver = [[[UIDevice currentDevice] systemVersion] floatValue];
// You can't detect screen resolutions in pre 3.2 devices, but they are all 320x480
if (ver >= 3.2f)
{
UIScreen* mainscr = [UIScreen mainScreen];
w = mainscr.currentMode.size.width;
h = mainscr.currentMode.size.height;
}
if ((self = [super initWithCoder:coder])) { if ((self = [super initWithCoder:coder])) {
// Get the layer // Get the layer
CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
if ((w == 640 && h == 960) || (h == 1536 && w == 2048)) { // Retina display detected
self.contentScaleFactor = 2.0;
eaglLayer.contentsScale=2;
}
eaglLayer.opaque = YES; eaglLayer.opaque = YES;
eaglLayer.drawableProperties = eaglLayer.drawableProperties =
[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:NO], [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:NO],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment