From 72757afe1b63dfabe70be6a83baa8b46aab6d99c Mon Sep 17 00:00:00 2001 From: Maxime Graulich <maxime.graulich@gmail.com> Date: Thu, 20 Mar 2014 10:36:11 +0000 Subject: [PATCH] iOS: fix openGL on retina display --- contrib/mobile/iOS/Onelab/EAGLView.mm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/contrib/mobile/iOS/Onelab/EAGLView.mm b/contrib/mobile/iOS/Onelab/EAGLView.mm index 62b72b02bc..31f2ecd152 100644 --- a/contrib/mobile/iOS/Onelab/EAGLView.mm +++ b/contrib/mobile/iOS/Onelab/EAGLView.mm @@ -28,9 +28,24 @@ //The GL view is stored in the nib file. When it's unarchived it's sent -initWithCoder: - (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])) { // Get the 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.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:NO], -- GitLab