From f6cb0a730b1abe6eb336b9b846691cc749a1527b Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 2 Nov 2010 22:58:15 +0100 Subject: [PATCH] Fixed: Compilation under Mac OS X 10.5 --- .../3d/driver/opengl/driver_opengl_window.cpp | 21 ++++++++++--------- .../driver/opengl/mac/cocoa_event_emitter.cpp | 6 +++--- .../3d/driver/opengl/mac/cocoa_opengl_view.m | 4 ++-- .../driver/opengl/mac/cocoa_window_delegate.h | 6 ++++-- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp index 1f7bf1e9b..047ad6999 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -26,6 +26,7 @@ # include #elif defined(NL_OS_MAC) # import "mac/cocoa_window_delegate.h" +# import #elif defined (NL_OS_UNIX) # include # include @@ -1671,14 +1672,14 @@ bool CDriverGL::setWindowStyle(EWindowStyle windowStyle) // 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 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#if MAC_OS_X_VERSION_10_6 > MAC_OS_X_VERSION_MAX_ALLOWED [containerView() enterFullScreenMode:[NSScreen mainScreen] withOptions: [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt: NSApplicationPresentationHideDock | NSApplicationPresentationAutoHideMenuBar], NSFullScreenModeApplicationPresentationOptions, nil]]; -#endif // AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#endif /* TODO check if simply using NSView enterFullScreenMode is a good idea. the context can be set to full screen as well, performance differences? @@ -1775,7 +1776,7 @@ bool CDriverGL::setMode(const GfxMode& mode) return true; } -#if defined(NL_OS_MAC) && defined(AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER) +#if defined(NL_OS_MAC) && (MAC_OS_X_VERSION_10_6 > MAC_OS_X_VERSION_MAX_ALLOWED) /// helper to extract bits per pixel value from screen mode, only 16 or 32 bits static int bppFromDisplayMode(CGDisplayModeRef mode) @@ -1793,7 +1794,7 @@ static int bppFromDisplayMode(CGDisplayModeRef mode) return 0; } -#elif defined(NL_OS_MAC) && !defined(AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER) +#elif defined(NL_OS_MAC) && (MAC_OS_X_VERSION_10_6 < MAC_OS_X_VERSION_MAX_ALLOWED) long GetDictionaryLong(CFDictionaryRef theDict, const void* key) { @@ -1857,11 +1858,11 @@ bool CDriverGL::getModes(std::vector &modes) { CGDirectDisplayID dspy = display[i]; -#ifdef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#if MAC_OS_X_VERSION_10_6 > MAC_OS_X_VERSION_MAX_ALLOWED CFArrayRef modeList = CGDisplayCopyAllDisplayModes(dspy, NULL); #else CFArrayRef modeList = CGDisplayAvailableModes(dspy); -#endif // AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#endif if (modeList == NULL) { @@ -1871,23 +1872,23 @@ bool CDriverGL::getModes(std::vector &modes) for (CFIndex j = 0; j < CFArrayGetCount(modeList); ++j) { -#ifdef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#if MAC_OS_X_VERSION_10_6 > MAC_OS_X_VERSION_MAX_ALLOWED CGDisplayModeRef mode = (CGDisplayModeRef)CFArrayGetValueAtIndex(modeList, j); uint8 bpp = bppFromDisplayMode(mode); #else CFDictionaryRef mode = (CFDictionaryRef)CFArrayGetValueAtIndex(modeList, j); uint8 bpp = (uint8)GetModeBitsPerPixel(mode); -#endif // AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#endif if (bpp >= 16) { -#ifdef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#if MAC_OS_X_VERSION_10_6 > MAC_OS_X_VERSION_MAX_ALLOWED uint16 w = CGDisplayModeGetWidth(mode); uint16 h = CGDisplayModeGetHeight(mode); #else uint16 w = (uint16)GetModeWidth(mode); uint16 h = (uint16)GetModeHeight(mode); -#endif // AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#endif // Add this mode GfxMode mode; diff --git a/code/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.cpp b/code/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.cpp index 482474de5..c2a74647e 100644 --- a/code/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.cpp +++ b/code/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.cpp @@ -237,7 +237,7 @@ bool CCocoaEventEmitter::processMessage(NSEvent* event, CEventServer* server) server = _server; NSRect viewRect = [_glView frame]; - CGPoint mousePos = [_glView convertPoint:event.locationInWindow fromView:nil]; + NSPoint mousePos = [_glView convertPoint:event.locationInWindow fromView:nil]; mousePos.x /= (float)viewRect.size.width; mousePos.y /= (float)viewRect.size.height; @@ -387,14 +387,14 @@ bool CCocoaEventEmitter::processMessage(NSEvent* event, CEventServer* server) case NSOtherMouseDown:break; case NSOtherMouseUp:break; case NSOtherMouseDragged:break; -#ifdef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#if MAC_OS_X_VERSION_10_6 > MAC_OS_X_VERSION_MAX_ALLOWED case NSEventTypeGesture:break; case NSEventTypeMagnify:break; case NSEventTypeSwipe:break; case NSEventTypeRotate:break; case NSEventTypeBeginGesture:break; case NSEventTypeEndGesture:break; -#endif // AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#endif default: { nlwarning("Unknown event type. dropping."); 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 ab014f5c3..f6d08659b 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 @@ -53,9 +53,9 @@ namespace NL3D { -(void)keyDown:(NSEvent*)event { -#ifdef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#if MAC_OS_X_VERSION_10_6 > MAC_OS_X_VERSION_MAX_ALLOWED [[self inputContext] handleEvent:event]; -#endif // AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#endif } -(void)setDriver:(NL3D::CDriverGL*)driver diff --git a/code/nel/src/3d/driver/opengl/mac/cocoa_window_delegate.h b/code/nel/src/3d/driver/opengl/mac/cocoa_window_delegate.h index c439c363d..6aa8207d1 100644 --- a/code/nel/src/3d/driver/opengl/mac/cocoa_window_delegate.h +++ b/code/nel/src/3d/driver/opengl/mac/cocoa_window_delegate.h @@ -23,8 +23,10 @@ namespace NL3D { void windowDidMove(NSWindow*, NL3D::CDriverGL*); } - -@interface CocoaWindowDelegate : NSObject +@interface CocoaWindowDelegate : NSObject +#if MAC_OS_X_VERSION_10_6 > MAC_OS_X_VERSION_MAX_ALLOWED + +#endif { NL3D::CDriverGL* _driver; }