|
|
|
@ -156,6 +156,7 @@ static OSStatus keyEventHandler( EventHandlerCallRef handlerCallRef, |
|
|
|
|
{ |
|
|
|
|
handleMacKeyChange(keyCode, GLFW_PRESS); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (GetEventParameter(event, |
|
|
|
|
kEventParamKeyUnicodes, |
|
|
|
|
typeUnicodeText, |
|
|
|
@ -166,6 +167,7 @@ static OSStatus keyEventHandler( EventHandlerCallRef handlerCallRef, |
|
|
|
|
{ |
|
|
|
|
_glfwInputChar(keyChar, GLFW_PRESS); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return noErr; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -181,6 +183,7 @@ static OSStatus keyEventHandler( EventHandlerCallRef handlerCallRef, |
|
|
|
|
{ |
|
|
|
|
handleMacKeyChange(keyCode, GLFW_RELEASE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (GetEventParameter(event, |
|
|
|
|
kEventParamKeyUnicodes, |
|
|
|
|
typeUnicodeText, |
|
|
|
@ -191,6 +194,7 @@ static OSStatus keyEventHandler( EventHandlerCallRef handlerCallRef, |
|
|
|
|
{ |
|
|
|
|
_glfwInputChar(keyChar, GLFW_RELEASE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return noErr; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -367,9 +371,8 @@ static OSStatus mouseEventHandler( EventHandlerCallRef handlerCallRef, |
|
|
|
|
{ |
|
|
|
|
_glfwInput.WheelPos += wheelDelta; |
|
|
|
|
if (_glfwWin.mouseWheelCallback) |
|
|
|
|
{ |
|
|
|
|
_glfwWin.mouseWheelCallback(_glfwInput.WheelPos); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return noErr; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -415,14 +418,11 @@ static OSStatus commandHandler( EventHandlerCallRef handlerCallRef, |
|
|
|
|
if (_glfwWin.windowCloseCallback) |
|
|
|
|
{ |
|
|
|
|
if (_glfwWin.windowCloseCallback()) |
|
|
|
|
{ |
|
|
|
|
glfwCloseWindow(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
glfwCloseWindow(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return noErr; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -470,15 +470,12 @@ static OSStatus windowEventHandler( EventHandlerCallRef handlerCallRef, |
|
|
|
|
_glfwWin.width = rect.right; |
|
|
|
|
_glfwWin.height = rect.bottom; |
|
|
|
|
if (_glfwWin.windowSizeCallback) |
|
|
|
|
{ |
|
|
|
|
_glfwWin.windowSizeCallback(_glfwWin.width, _glfwWin.height); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Emulate (force) content invalidation
|
|
|
|
|
if (_glfwWin.windowRefreshCallback) |
|
|
|
|
{ |
|
|
|
|
_glfwWin.windowRefreshCallback(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -488,23 +485,19 @@ static OSStatus windowEventHandler( EventHandlerCallRef handlerCallRef, |
|
|
|
|
if (_glfwWin.windowCloseCallback) |
|
|
|
|
{ |
|
|
|
|
if (_glfwWin.windowCloseCallback()) |
|
|
|
|
{ |
|
|
|
|
glfwCloseWindow(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
glfwCloseWindow(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return noErr; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
case kEventWindowDrawContent: |
|
|
|
|
{ |
|
|
|
|
if (_glfwWin.windowRefreshCallback) |
|
|
|
|
{ |
|
|
|
|
_glfwWin.windowRefreshCallback(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -682,9 +675,7 @@ int _glfwPlatformOpenWindow( int width, int height, |
|
|
|
|
AGLpixelFormatAttributes[numAGLAttrs++] = AGL_CLOSEST_POLICY; |
|
|
|
|
|
|
|
|
|
if (fbconfig->stereo) |
|
|
|
|
{ |
|
|
|
|
AGLpixelFormatAttributes[numAGLAttrs++] = AGL_STEREO; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_setAGLAttribute(AGL_AUX_BUFFERS, fbconfig->auxBuffers); |
|
|
|
|
_setAGLAttribute(AGL_RED_SIZE, fbconfig->redBits); |
|
|
|
@ -747,9 +738,7 @@ int _glfwPlatformOpenWindow( int width, int height, |
|
|
|
|
kWindowStandardHandlerAttribute); |
|
|
|
|
|
|
|
|
|
if (wndconfig->windowNoResize) |
|
|
|
|
{ |
|
|
|
|
windowAttributes |= kWindowLiveResizeAttribute; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
windowAttributes |= (kWindowFullZoomAttribute | |
|
|
|
@ -785,8 +774,8 @@ int _glfwPlatformOpenWindow( int width, int height, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Don't care if we fail here
|
|
|
|
|
(void)SetWindowTitleWithCFString( _glfwWin.window, CFSTR( "GLFW Window" ) ); |
|
|
|
|
(void)RepositionWindow( _glfwWin.window, |
|
|
|
|
SetWindowTitleWithCFString(_glfwWin.window, CFSTR("GLFW Window")); |
|
|
|
|
RepositionWindow(_glfwWin.window, |
|
|
|
|
NULL, |
|
|
|
|
kWindowCenterOnMainScreen); |
|
|
|
|
|
|
|
|
@ -834,9 +823,7 @@ int _glfwPlatformOpenWindow( int width, int height, |
|
|
|
|
CGDisplayIDToOpenGLDisplayMask(kCGDirectMainDisplay)); |
|
|
|
|
|
|
|
|
|
if (fbconfig->stereo) |
|
|
|
|
{ |
|
|
|
|
CGLpixelFormatAttributes[ numCGLAttrs++ ] = kCGLPFAStereo; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (fbconfig->samples > 1) |
|
|
|
|
{ |
|
|
|
@ -892,7 +879,7 @@ int _glfwPlatformOpenWindow( int width, int height, |
|
|
|
|
|
|
|
|
|
// enumerate depth of RGB channels - unlike AGL, CGL works with
|
|
|
|
|
// a single parameter reflecting the full depth of the frame buffer
|
|
|
|
|
(void)CGLDescribePixelFormat( _glfwWin.cglPixelFormat, |
|
|
|
|
CGLDescribePixelFormat(_glfwWin.cglPixelFormat, |
|
|
|
|
0, |
|
|
|
|
kCGLPFAColorSize, |
|
|
|
|
&rgbColorDepth); |
|
|
|
@ -901,8 +888,7 @@ int _glfwPlatformOpenWindow( int width, int height, |
|
|
|
|
cgErr = CGCaptureAllDisplays(); |
|
|
|
|
if (cgErr != kCGErrorSuccess) |
|
|
|
|
{ |
|
|
|
|
fprintf( stderr, |
|
|
|
|
"Failed to capture Core Graphics displays\n"); |
|
|
|
|
fprintf(stderr, "Failed to capture Core Graphics displays\n"); |
|
|
|
|
|
|
|
|
|
_glfwPlatformCloseWindow(); |
|
|
|
|
return GL_FALSE; |
|
|
|
@ -919,8 +905,7 @@ int _glfwPlatformOpenWindow( int width, int height, |
|
|
|
|
NULL); |
|
|
|
|
if (optimalMode == NULL) |
|
|
|
|
{ |
|
|
|
|
fprintf( stderr, |
|
|
|
|
"Failed to retrieve Core Graphics display mode\n"); |
|
|
|
|
fprintf(stderr, "Failed to retrieve Core Graphics display mode\n"); |
|
|
|
|
|
|
|
|
|
_glfwPlatformCloseWindow(); |
|
|
|
|
return GL_FALSE; |
|
|
|
@ -930,8 +915,7 @@ int _glfwPlatformOpenWindow( int width, int height, |
|
|
|
|
cgErr = CGDisplaySwitchToMode(kCGDirectMainDisplay, optimalMode); |
|
|
|
|
if (cgErr != kCGErrorSuccess) |
|
|
|
|
{ |
|
|
|
|
fprintf( stderr, |
|
|
|
|
"Failed to switch to Core Graphics display mode\n"); |
|
|
|
|
fprintf(stderr, "Failed to switch to Core Graphics display mode\n"); |
|
|
|
|
|
|
|
|
|
_glfwPlatformCloseWindow(); |
|
|
|
|
return GL_FALSE; |
|
|
|
@ -1046,7 +1030,7 @@ void _glfwPlatformSetWindowTitle( const char *title ) |
|
|
|
|
title, |
|
|
|
|
kCFStringEncodingISOLatin1); |
|
|
|
|
|
|
|
|
|
(void)SetWindowTitleWithCFString( _glfwWin.window, windowTitle ); |
|
|
|
|
SetWindowTitleWithCFString(_glfwWin.window, windowTitle); |
|
|
|
|
|
|
|
|
|
CFRelease(windowTitle); |
|
|
|
|
} |
|
|
|
@ -1059,10 +1043,8 @@ void _glfwPlatformSetWindowTitle( const char *title ) |
|
|
|
|
void _glfwPlatformSetWindowSize(int width, int height) |
|
|
|
|
{ |
|
|
|
|
if (!_glfwWin.fullscreen) |
|
|
|
|
{ |
|
|
|
|
SizeWindow(_glfwWin.window, width, height, TRUE); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
|
// Set the window position
|
|
|
|
@ -1071,10 +1053,8 @@ void _glfwPlatformSetWindowSize( int width, int height ) |
|
|
|
|
void _glfwPlatformSetWindowPos(int x, int y) |
|
|
|
|
{ |
|
|
|
|
if (!_glfwWin.fullscreen) |
|
|
|
|
{ |
|
|
|
|
MoveWindow(_glfwWin.window, x, y, FALSE); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
|
// Window iconification
|
|
|
|
@ -1083,9 +1063,7 @@ void _glfwPlatformSetWindowPos( int x, int y ) |
|
|
|
|
void _glfwPlatformIconifyWindow(void) |
|
|
|
|
{ |
|
|
|
|
if (!_glfwWin.fullscreen) |
|
|
|
|
{ |
|
|
|
|
(void)CollapseWindow( _glfwWin.window, TRUE ); |
|
|
|
|
} |
|
|
|
|
CollapseWindow(_glfwWin.window, TRUE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
@ -1095,9 +1073,7 @@ void _glfwPlatformIconifyWindow( void ) |
|
|
|
|
void _glfwPlatformRestoreWindow(void) |
|
|
|
|
{ |
|
|
|
|
if (!_glfwWin.fullscreen) |
|
|
|
|
{ |
|
|
|
|
(void)CollapseWindow( _glfwWin.window, FALSE ); |
|
|
|
|
} |
|
|
|
|
CollapseWindow(_glfwWin.window, FALSE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
@ -1107,14 +1083,10 @@ void _glfwPlatformRestoreWindow( void ) |
|
|
|
|
void _glfwPlatformSwapBuffers(void) |
|
|
|
|
{ |
|
|
|
|
if (_glfwWin.fullscreen) |
|
|
|
|
{ |
|
|
|
|
CGLFlushDrawable(_glfwWin.cglContext); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
aglSwapBuffers(_glfwWin.aglContext); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
|
// Set double buffering swap interval
|
|
|
|
@ -1130,14 +1102,14 @@ void _glfwPlatformSwapInterval( int interval ) |
|
|
|
|
if (_glfwWin.fullscreen) |
|
|
|
|
{ |
|
|
|
|
// Don't care if we fail here..
|
|
|
|
|
(void)CGLSetParameter( _glfwWin.cglContext, |
|
|
|
|
CGLSetParameter(_glfwWin.cglContext, |
|
|
|
|
kCGLCPSwapInterval, |
|
|
|
|
(GLint*) &CGLparameter); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
// ..or here
|
|
|
|
|
(void)aglSetInteger( _glfwWin.aglContext, |
|
|
|
|
aglSetInteger(_glfwWin.aglContext, |
|
|
|
|
AGL_SWAP_INTERVAL, |
|
|
|
|
&AGLparameter); |
|
|
|
|
} |
|
|
|
@ -1150,14 +1122,14 @@ void _glfwPlatformSwapInterval( int interval ) |
|
|
|
|
#define _getAGLAttribute(aglAttributeName, variableName) \ |
|
|
|
|
{ \
|
|
|
|
|
GLint aglValue; \
|
|
|
|
|
(void)aglDescribePixelFormat( _glfwWin.aglPixelFormat, aglAttributeName, &aglValue ); \
|
|
|
|
|
aglDescribePixelFormat(_glfwWin.aglPixelFormat, aglAttributeName, &aglValue); \
|
|
|
|
|
variableName = aglValue; \
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#define _getCGLAttribute(cglAttributeName, variableName) \ |
|
|
|
|
{ \
|
|
|
|
|
GLint cglValue; \
|
|
|
|
|
(void)CGLDescribePixelFormat( _glfwWin.cglPixelFormat, 0, cglAttributeName, &cglValue ); \
|
|
|
|
|
CGLDescribePixelFormat(_glfwWin.cglPixelFormat, 0, cglAttributeName, &cglValue); \
|
|
|
|
|
variableName = cglValue; \
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1179,19 +1151,15 @@ void _glfwPlatformRefreshWindowParams( void ) |
|
|
|
|
|
|
|
|
|
// Enumerate depth of RGB channels - unlike AGL, CGL works with
|
|
|
|
|
// a single parameter reflecting the full depth of the frame buffer
|
|
|
|
|
(void)CGLDescribePixelFormat( _glfwWin.cglPixelFormat, |
|
|
|
|
CGLDescribePixelFormat(_glfwWin.cglPixelFormat, |
|
|
|
|
0, |
|
|
|
|
kCGLPFAColorSize, |
|
|
|
|
&rgbColorDepth); |
|
|
|
|
|
|
|
|
|
if (rgbColorDepth == 24 || rgbColorDepth == 32) |
|
|
|
|
{ |
|
|
|
|
rgbChannelDepth = 8; |
|
|
|
|
} |
|
|
|
|
if (rgbColorDepth == 16) |
|
|
|
|
{ |
|
|
|
|
rgbChannelDepth = 5; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_glfwWin.redBits = rgbChannelDepth; |
|
|
|
|
_glfwWin.greenBits = rgbChannelDepth; |
|
|
|
@ -1202,9 +1170,7 @@ void _glfwPlatformRefreshWindowParams( void ) |
|
|
|
|
// so this might end up giving completely knackered results...
|
|
|
|
|
_getCGLAttribute(kCGLPFAColorSize, rgbaAccumDepth); |
|
|
|
|
if (rgbaAccumDepth == 32) |
|
|
|
|
{ |
|
|
|
|
rgbaAccumDepth = 8; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_glfwWin.accumRedBits = rgbaAccumDepth; |
|
|
|
|
_glfwWin.accumGreenBits = rgbaAccumDepth; |
|
|
|
|