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