Re: Detect a Retina display
Re: Detect a Retina display
- Subject: Re: Detect a Retina display
- From: Thierry Cantet <email@hidden>
- Date: Thu, 20 Jun 2013 17:11:57 +0200
Hello Richard,
I have tried your solution, however it does not work.
I have these messages when I try to build with the base SDK set to 10.6 :
(Warning)Instance method '-convertRectToBacking:' not found (return
type defaults to 'id')
(Error)No viable conversion from 'id' to 'NSRect' (aka 'CGRect')
Le 20/06/13 16:18, Richard Heard a écrit :
No retina devices can run 10.6, therefore you can safely assume 1.0.
This means you can use a runtime check for the selector, and if its
not available default to a 1.0 multiple
eg:
- (NSRect)backingBounds {
if ([self respondsToSelector:@selector(convertRectToBacking:)]){
return [self convertRectToBacking:self.bounds];
}
return self.bounds;
}
-Richard
On 20/06/2013, at 11:49:18 PM, Thierry Cantet
<email@hidden <mailto:email@hidden>> wrote:
Hello !
I have a quick question concerning Retina displays.
My software uses OpenGL for displaying the pixels. However, on a
Retina screen, OpenGL behaves strangely.
There is a fix (
https://developer.apple.com/library/mac/#documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/CapturingScreenContents/CapturingScreenContents.html#//apple_ref/doc/uid/TP40012302-CH10-SW1
) that requires you to use :
NSRect backingBounds = [self convertRectToBacking:[self bounds]];
GLsizei backingPixelWidth = (GLsizei)(backingBounds.size.width),
backingPixelHeight = (GLsizei)(backingBounds.size.height);
glViewport(0, 0, backingPixelWidth, backingPixelHeight);
inside the drawRect method.
The main issue is, the /convertRectToBacking/ method exists only
since OS X 10.7, and my software still supports OS X 10.6 (so I need
to build it with a 10.6 SDK, and not 10.7).
I could drop the 10.6 support, but that is not an option for now.
I have looked for another way, and I found the /backingScaleFactor/
method (it returns the scale factor, which is 2 for Retina displays,
and 1 for other screens). But then again, this method is available
only from 10.7.
So, my question is, is there any way of detecting a Retina display,
but usable with 10.6 ?
Thanks in advance :)
--
Thierry CANTET
_______________________________________________
Cocoa-dev mailing list (email@hidden
<mailto:email@hidden>)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
<http://lists.apple.com>
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
--
Thierry CANTET
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden