Fixed: Compilation under Mac OS X 10.5

This commit is contained in:
kervala 2010-11-02 22:58:15 +01:00
parent b1e5a87c83
commit fcf462067b
4 changed files with 20 additions and 17 deletions

View file

@ -26,6 +26,7 @@
# include <windowsx.h> # include <windowsx.h>
#elif defined(NL_OS_MAC) #elif defined(NL_OS_MAC)
# import "mac/cocoa_window_delegate.h" # import "mac/cocoa_window_delegate.h"
# import <OpenGL/OpenGL.h>
#elif defined (NL_OS_UNIX) #elif defined (NL_OS_UNIX)
# include <GL/gl.h> # include <GL/gl.h>
# include <GL/glx.h> # include <GL/glx.h>
@ -1671,14 +1672,14 @@ bool CDriverGL::setWindowStyle(EWindowStyle windowStyle)
// put the view in fullscreen mode, hiding the dock but enabling the menubar // put the view in fullscreen mode, hiding the dock but enabling the menubar
// to pop up if the mouse hits the top screen border. // to pop up if the mouse hits the top screen border.
// NOTE: withOptions:nil disables <CMD>+<Tab> application switching! // NOTE: withOptions:nil disables <CMD>+<Tab> 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: [containerView() enterFullScreenMode:[NSScreen mainScreen] withOptions:
[NSDictionary dictionaryWithObjectsAndKeys: [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt: [NSNumber numberWithInt:
NSApplicationPresentationHideDock | NSApplicationPresentationHideDock |
NSApplicationPresentationAutoHideMenuBar], NSApplicationPresentationAutoHideMenuBar],
NSFullScreenModeApplicationPresentationOptions, nil]]; NSFullScreenModeApplicationPresentationOptions, nil]];
#endif // AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER #endif
/* /*
TODO check if simply using NSView enterFullScreenMode is a good idea. TODO check if simply using NSView enterFullScreenMode is a good idea.
the context can be set to full screen as well, performance differences? the context can be set to full screen as well, performance differences?
@ -1775,7 +1776,7 @@ bool CDriverGL::setMode(const GfxMode& mode)
return true; 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 /// helper to extract bits per pixel value from screen mode, only 16 or 32 bits
static int bppFromDisplayMode(CGDisplayModeRef mode) static int bppFromDisplayMode(CGDisplayModeRef mode)
@ -1793,7 +1794,7 @@ static int bppFromDisplayMode(CGDisplayModeRef mode)
return 0; 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) long GetDictionaryLong(CFDictionaryRef theDict, const void* key)
{ {
@ -1857,11 +1858,11 @@ bool CDriverGL::getModes(std::vector<GfxMode> &modes)
{ {
CGDirectDisplayID dspy = display[i]; 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); CFArrayRef modeList = CGDisplayCopyAllDisplayModes(dspy, NULL);
#else #else
CFArrayRef modeList = CGDisplayAvailableModes(dspy); CFArrayRef modeList = CGDisplayAvailableModes(dspy);
#endif // AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER #endif
if (modeList == NULL) if (modeList == NULL)
{ {
@ -1871,23 +1872,23 @@ bool CDriverGL::getModes(std::vector<GfxMode> &modes)
for (CFIndex j = 0; j < CFArrayGetCount(modeList); ++j) 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); CGDisplayModeRef mode = (CGDisplayModeRef)CFArrayGetValueAtIndex(modeList, j);
uint8 bpp = bppFromDisplayMode(mode); uint8 bpp = bppFromDisplayMode(mode);
#else #else
CFDictionaryRef mode = (CFDictionaryRef)CFArrayGetValueAtIndex(modeList, j); CFDictionaryRef mode = (CFDictionaryRef)CFArrayGetValueAtIndex(modeList, j);
uint8 bpp = (uint8)GetModeBitsPerPixel(mode); uint8 bpp = (uint8)GetModeBitsPerPixel(mode);
#endif // AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER #endif
if (bpp >= 16) 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 w = CGDisplayModeGetWidth(mode);
uint16 h = CGDisplayModeGetHeight(mode); uint16 h = CGDisplayModeGetHeight(mode);
#else #else
uint16 w = (uint16)GetModeWidth(mode); uint16 w = (uint16)GetModeWidth(mode);
uint16 h = (uint16)GetModeHeight(mode); uint16 h = (uint16)GetModeHeight(mode);
#endif // AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER #endif
// Add this mode // Add this mode
GfxMode mode; GfxMode mode;

View file

@ -237,7 +237,7 @@ bool CCocoaEventEmitter::processMessage(NSEvent* event, CEventServer* server)
server = _server; server = _server;
NSRect viewRect = [_glView frame]; 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.x /= (float)viewRect.size.width;
mousePos.y /= (float)viewRect.size.height; mousePos.y /= (float)viewRect.size.height;
@ -387,14 +387,14 @@ bool CCocoaEventEmitter::processMessage(NSEvent* event, CEventServer* server)
case NSOtherMouseDown:break; case NSOtherMouseDown:break;
case NSOtherMouseUp:break; case NSOtherMouseUp:break;
case NSOtherMouseDragged: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 NSEventTypeGesture:break;
case NSEventTypeMagnify:break; case NSEventTypeMagnify:break;
case NSEventTypeSwipe:break; case NSEventTypeSwipe:break;
case NSEventTypeRotate:break; case NSEventTypeRotate:break;
case NSEventTypeBeginGesture:break; case NSEventTypeBeginGesture:break;
case NSEventTypeEndGesture:break; case NSEventTypeEndGesture:break;
#endif // AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER #endif
default: default:
{ {
nlwarning("Unknown event type. dropping."); nlwarning("Unknown event type. dropping.");

View file

@ -53,9 +53,9 @@ namespace NL3D {
-(void)keyDown:(NSEvent*)event -(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]; [[self inputContext] handleEvent:event];
#endif // AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER #endif
} }
-(void)setDriver:(NL3D::CDriverGL*)driver -(void)setDriver:(NL3D::CDriverGL*)driver

View file

@ -23,8 +23,10 @@ namespace NL3D {
void windowDidMove(NSWindow*, NL3D::CDriverGL*); void windowDidMove(NSWindow*, NL3D::CDriverGL*);
} }
@interface CocoaWindowDelegate : NSObject
@interface CocoaWindowDelegate : NSObject<NSWindowDelegate> #if MAC_OS_X_VERSION_10_6 > MAC_OS_X_VERSION_MAX_ALLOWED
<NSWindowDelegate>
#endif
{ {
NL3D::CDriverGL* _driver; NL3D::CDriverGL* _driver;
} }