Created
June 7, 2012 18:35
-
-
Save domoritz/2890654 to your computer and use it in GitHub Desktop.
Patch for Open Scene Graph 3.0.1 for Mac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: OpenSceneGraph/trunk/src/osgViewer/DarwinUtils.mm | |
=================================================================== | |
--- a/src/osgViewer/DarwinUtils.mm (revision 12292) | |
+++ b/src/osgViewer/DarwinUtils.mm (revision 12790) | |
@@ -48,4 +48,23 @@ | |
namespace osgDarwin { | |
+// | |
+// Lion replacement for CGDisplayBitsPerPixel(CGDirectDisplayID displayId) | |
+// | |
+size_t displayBitsPerPixel( CGDirectDisplayID displayId ) | |
+{ | |
+ | |
+ CGDisplayModeRef mode = CGDisplayCopyDisplayMode(displayId); | |
+ size_t depth = 0; | |
+ | |
+ CFStringRef pixEnc = CGDisplayModeCopyPixelEncoding(mode); | |
+ if(CFStringCompare(pixEnc, CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) | |
+ depth = 32; | |
+ else if(CFStringCompare(pixEnc, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) | |
+ depth = 16; | |
+ else if(CFStringCompare(pixEnc, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) | |
+ depth = 8; | |
+ | |
+ return depth; | |
+} | |
static inline CGRect toCGRect(NSRect nsRect) | |
@@ -314,5 +333,5 @@ | |
resolution.width = CGDisplayPixelsWide(id); | |
resolution.height = CGDisplayPixelsHigh(id); | |
- resolution.colorDepth = CGDisplayBitsPerPixel(id); | |
+ resolution.colorDepth = displayBitsPerPixel(id); | |
resolution.refreshRate = getDictDouble (CGDisplayCurrentMode(id), kCGDisplayRefreshRate); // Not tested | |
if (resolution.refreshRate<0) resolution.refreshRate = 0; | |
@@ -403,5 +422,5 @@ | |
CGDisplayBestModeForParametersAndRefreshRate( | |
displayid, | |
- CGDisplayBitsPerPixel(displayid), | |
+ displayBitsPerPixel(displayid), | |
width, height, | |
refresh, | |
@@ -433,5 +452,5 @@ | |
CGDisplayBestModeForParametersAndRefreshRate( | |
displayid, | |
- CGDisplayBitsPerPixel(displayid), | |
+ displayBitsPerPixel(displayid), | |
width, height, | |
refreshRate, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment