Fixed: Compilation under Mac OS X 10.5

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

View file

@ -26,6 +26,7 @@
# include <windowsx.h>
#elif defined(NL_OS_MAC)
# import "mac/cocoa_window_delegate.h"
# import <OpenGL/OpenGL.h>
#elif defined (NL_OS_UNIX)
# include <GL/gl.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
// to pop up if the mouse hits the top screen border.
// 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:
[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<GfxMode> &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<GfxMode> &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;

View file

@ -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.");

View file

@ -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

View file

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