From 92a682bc1b079ad21f71eb154e56d54e7a23b4e7 Mon Sep 17 00:00:00 2001 From: kervala Date: Thu, 14 Oct 2010 20:41:34 +0200 Subject: [PATCH] Changed: Added better check for Mac OS SDK version --- .../src/3d/driver/opengl/mac/cocoa_adapter.mm | 28 ++++++++++--------- .../3d/driver/opengl/mac/cocoa_opengl_view.m | 8 ++++-- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/code/nel/src/3d/driver/opengl/mac/cocoa_adapter.mm b/code/nel/src/3d/driver/opengl/mac/cocoa_adapter.mm index 45f3511bc..a0f2c3e81 100644 --- a/code/nel/src/3d/driver/opengl/mac/cocoa_adapter.mm +++ b/code/nel/src/3d/driver/opengl/mac/cocoa_adapter.mm @@ -32,8 +32,11 @@ #import #import -#ifndef MAC_OS_X_VERSION_10_6 +#if defined(MAC_OS_X_VERSION_10_6) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6) + #define NL_USE_MAC_10_6_API 1 +#endif +#ifndef NL_USE_MAC_10_6_API long GetDictionaryLong(CFDictionaryRef theDict, const void* key) { long value = 0; @@ -49,7 +52,7 @@ long GetDictionaryLong(CFDictionaryRef theDict, const void* key) #define GetModeHeight(mode) GetDictionaryLong((mode), kCGDisplayHeight) #define GetModeBitsPerPixel(mode) GetDictionaryLong((mode), kCGDisplayBitsPerPixel) -#endif // MAC_OS_X_VERSION_10_6 +#endif // NL_USE_MAC_10_6_API namespace NL3D { namespace MAC { @@ -355,14 +358,14 @@ bool setWindowStyle(nlWindow wnd, bool fullscreen) // put the view in fullscreen mode, hiding the dock but enabling the menubar // to pop up if the mouse hits the top screen border. // NOTE: withOptions:nil disables + application switching! -#ifdef MAC_OS_X_VERSION_10_6 +#ifdef NL_USE_MAC_10_6_API [superview enterFullScreenMode:[NSScreen mainScreen] withOptions: [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt: NSApplicationPresentationHideDock | NSApplicationPresentationAutoHideMenuBar], NSFullScreenModeApplicationPresentationOptions, nil]]; -#endif // MAC_OS_X_VERSION_10_6 +#endif // NL_USE_MAC_10_6_API /* TODO check if simply using NSView enterFullScreenMode is a good idea. the context can be set to full screen as well, performance differences? @@ -407,7 +410,7 @@ void getCurrentScreenMode(nlWindow wnd, GfxMode& mode) } } -#ifdef MAC_OS_X_VERSION_10_6 +#ifdef NL_USE_MAC_10_6_API /// helper to extract bits per pixel value from screen mode, only 16 or 32 bits static int bppFromDisplayMode(CGDisplayModeRef mode) { @@ -423,7 +426,7 @@ static int bppFromDisplayMode(CGDisplayModeRef mode) return 0; } -#endif // MAC_OS_X_VERSION_10_6 +#endif // NL_USE_MAC_10_6_API /// get the list of available screen modes bool getModes(std::vector &modes) @@ -445,11 +448,11 @@ bool getModes(std::vector &modes) { CGDirectDisplayID dspy = display[i]; -#ifdef MAC_OS_X_VERSION_10_6 +#ifdef NL_USE_MAC_10_6_API CFArrayRef modeList = CGDisplayCopyAllDisplayModes(dspy, NULL); #else CFArrayRef modeList = CGDisplayAvailableModes(dspy); -#endif +#endif // NL_USE_MAC_10_6_API if (modeList == NULL) { @@ -459,24 +462,23 @@ bool getModes(std::vector &modes) for (CFIndex j = 0; j < CFArrayGetCount(modeList); ++j) { -#ifdef MAC_OS_X_VERSION_10_6 +#ifdef NL_USE_MAC_10_6_API CGDisplayModeRef mode = (CGDisplayModeRef)CFArrayGetValueAtIndex(modeList, j); uint8 bpp = bppFromDisplayMode(mode); #else CFDictionaryRef mode = (CFDictionaryRef)CFArrayGetValueAtIndex(modeList, j); uint8 bpp = (uint8)GetModeBitsPerPixel(mode); -#endif // MAC_OS_X_VERSION_10_6 +#endif // NL_USE_MAC_10_6_API if (bpp >= 16) { -#ifdef MAX_OS_X_VERSION_10_6 +#ifdef NL_USE_MAC_10_6_API uint16 w = CGDisplayModeGetWidth(mode); uint16 h = CGDisplayModeGetHeight(mode); #else uint16 w = (uint16)GetModeWidth(mode); uint16 h = (uint16)GetModeHeight(mode); -#endif // MAC_OS_X_VERSION_10_6 - +#endif // NL_USE_MAC_10_6_API // Add this mode GfxMode mode; diff --git a/code/nel/src/3d/driver/opengl/mac/cocoa_opengl_view.m b/code/nel/src/3d/driver/opengl/mac/cocoa_opengl_view.m index bcfbcf175..1510b2eb8 100644 --- a/code/nel/src/3d/driver/opengl/mac/cocoa_opengl_view.m +++ b/code/nel/src/3d/driver/opengl/mac/cocoa_opengl_view.m @@ -18,6 +18,10 @@ #import "cocoa_opengl_view.h" +#if defined(MAC_OS_X_VERSION_10_6) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6) + #define NL_USE_MAC_10_6_API 1 +#endif + @implementation CocoaOpenGLView -(id)initWithFrame:(NSRect)frame @@ -38,9 +42,9 @@ -(void)keyDown:(NSEvent*)event { -#ifdef MAC_OS_X_VERSION_10_6 +#ifdef NL_USE_MAC_10_6_API [[self inputContext] handleEvent:event]; -#endif // MAC_OS_X_VERSION_10_6 +#endif // NL_USE_MAC_10_6_API } /******************************************************************************/