Bladeren bron

Added fadein/fadeout on entering or leaving fullscreen mode on OSX. Removed deprecated Carbon code.

Lasse Öörni 14 jaren geleden
bovenliggende
commit
0d06cafd51

+ 0 - 43
ThirdParty/GLFW/lib/carbon/carbon_enable.c

@@ -1,43 +0,0 @@
-//========================================================================
-// GLFW - An OpenGL framework
-// Platform:    Carbon/AGL/CGL
-// API Version: 2.7
-// WWW:         http://www.glfw.org/
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2003      Keith Bauer
-// Copyright (c) 2003-2010 Camilla Berglund <[email protected]>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-void _glfwPlatformEnableSystemKeys( void )
-{
-    // Nothing to do; event handling code checks the status of
-    // _glfwWin.sysKeysDisabled to ensure this behavior.
-}
-
-void _glfwPlatformDisableSystemKeys( void )
-{
-    // Nothing to do; event handling code checks the status of
-    // _glfwWin.sysKeysDisabled to ensure this behavior.
-}
-

+ 0 - 127
ThirdParty/GLFW/lib/carbon/carbon_fullscreen.c

@@ -1,127 +0,0 @@
-//========================================================================
-// GLFW - An OpenGL framework
-// Platform:    Carbon/AGL/CGL
-// API Version: 2.7
-// WWW:         http://www.glfw.org/
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2003      Keith Bauer
-// Copyright (c) 2003-2010 Camilla Berglund <[email protected]>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#include "internal.h"
-
-//========================================================================
-// _glfwVideoModesEqual() - Compares two video modes
-//========================================================================
-
-static int _glfwVideoModesEqual( GLFWvidmode* first,
-                                 GLFWvidmode* second )
-{
-    if( first->Width != second->Width )
-	return 0;
-		
-    if( first->Height != second->Height )
-	return 0;
-		
-    if( first->RedBits + first->GreenBits + first->BlueBits !=
-      second->RedBits + second->GreenBits + second->BlueBits )
-	return 0;
-	
-    return 1;
-}
-                            
-//========================================================================
-// _glfwCGToGLFWVideoMode() - Converts a CG mode to a GLFW mode
-//========================================================================
-
-static void _glfwCGToGLFWVideoMode( CFDictionaryRef cgMode,
-                                    GLFWvidmode* glfwMode )
-{
-    int bitsPerSample;
-
-    CFNumberGetValue( CFDictionaryGetValue( cgMode, kCGDisplayWidth ),
-                     kCFNumberIntType,
-                     &(glfwMode->Width) );
-    CFNumberGetValue( CFDictionaryGetValue( cgMode, kCGDisplayHeight ),
-                     kCFNumberIntType,
-                     &(glfwMode->Height) );
-
-    CFNumberGetValue( CFDictionaryGetValue( cgMode, kCGDisplayBitsPerSample ),
-                     kCFNumberIntType,
-                     &bitsPerSample );
-
-    glfwMode->RedBits = bitsPerSample;
-    glfwMode->GreenBits = bitsPerSample;
-    glfwMode->BlueBits = bitsPerSample;
-}
-
-//========================================================================
-// _glfwPlatformGetVideoModes() - Get a list of available video modes
-//========================================================================
-
-int _glfwPlatformGetVideoModes( GLFWvidmode *list, int maxcount )
-{
-    int i, j, maxModes, numModes;
-    GLFWvidmode mode;
-    CFArrayRef availableModes = CGDisplayAvailableModes( kCGDirectMainDisplay );
-    CFIndex numberOfAvailableModes = CFArrayGetCount( availableModes );
-
-    numModes = 0;
-    maxModes = ( numberOfAvailableModes < maxcount ?
-                 numberOfAvailableModes :
-                 maxcount );
-
-    for( i = 0; i < maxModes; ++i )
-    {
-        _glfwCGToGLFWVideoMode( CFArrayGetValueAtIndex( availableModes, i ),
-                                &mode );
-
-        // Is it a valid mode? (only list depths >= 15 bpp)
-	if( mode.RedBits + mode.GreenBits + mode.BlueBits < 15 )
-	    continue;
-			
-        // Check for duplicate of current mode in target list
-      	for( j = 0; j < numModes; ++j )
-      	{
-      	    if( _glfwVideoModesEqual( &mode, &(list[j]) ) )
-      		break;
-      	}
-      	
-      	// If empty list or no match found
-      	if( numModes == 0 || j == numModes )
-      	    list[numModes++] = mode;
-    }
-
-    return numModes;
-}
-
-//========================================================================
-// glfwGetDesktopMode() - Get the desktop video mode
-//========================================================================
-
-void _glfwPlatformGetDesktopMode( GLFWvidmode *mode )
-{
-    _glfwCGToGLFWVideoMode( _glfwDesktopVideoMode, mode );
-}
-

+ 0 - 53
ThirdParty/GLFW/lib/carbon/carbon_glext.c

@@ -1,53 +0,0 @@
-//========================================================================
-// GLFW - An OpenGL framework
-// Platform:    Carbon/AGL/CGL
-// API Version: 2.7
-// WWW:         http://www.glfw.org/
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2003      Keith Bauer
-// Copyright (c) 2003-2010 Camilla Berglund <[email protected]>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#include "internal.h"
-
-int _glfwPlatformExtensionSupported( const char *extension )
-{
-    // There are no AGL, CGL or NSGL extensions.
-    return GL_FALSE;
-}
-
-void * _glfwPlatformGetProcAddress( const char *procname )
-{
-    CFStringRef symbolName = CFStringCreateWithCString( kCFAllocatorDefault,
-                                                        procname,
-                                                        kCFStringEncodingASCII );
-
-    void *symbol = CFBundleGetFunctionPointerForName( _glfwLibrary.Libs.OpenGLFramework,
-                                                      symbolName );
-
-    CFRelease( symbolName );
-
-    return symbol;
-}
-

+ 0 - 181
ThirdParty/GLFW/lib/carbon/carbon_init.c

@@ -1,181 +0,0 @@
-//========================================================================
-// GLFW - An OpenGL framework
-// Platform:    Carbon/AGL/CGL
-// API Version: 2.7
-// WWW:         http://www.glfw.org/
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2003      Keith Bauer
-// Copyright (c) 2003-2010 Camilla Berglund <[email protected]>
-// Copyright (c) 2006-2007 Robin Leffmann
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#include "internal.h"
-
-#include <unistd.h>
-
-//========================================================================
-// Global variables
-//========================================================================
-
-// KCHR resource pointer for keycode translation
-void *KCHRPtr;
-
-
-//========================================================================
-// Terminate GLFW when exiting application
-//========================================================================
-
-static void glfw_atexit( void )
-{
-    glfwTerminate();
-}
-
-
-//========================================================================
-// _glfwInitThreads() - Initialize GLFW thread package
-//========================================================================
-
-static void _glfwInitThreads( void )
-{
-    // Initialize critical section handle
-    (void) pthread_mutex_init( &_glfwThrd.CriticalSection, NULL );
-
-    // The first thread (the main thread) has ID 0
-    _glfwThrd.NextID = 0;
-
-    // Fill out information about the main thread (this thread)
-    _glfwThrd.First.ID       = _glfwThrd.NextID ++;
-    _glfwThrd.First.Function = NULL;
-    _glfwThrd.First.PosixID  = pthread_self();
-    _glfwThrd.First.Previous = NULL;
-    _glfwThrd.First.Next     = NULL;
-}
-
-#define NO_BUNDLE_MESSAGE \
-    "Working in unbundled mode.  " \
-    "You should build a .app wrapper for your Mac OS X applications.\n"
-
-#define UNBUNDLED \
-    fprintf(stderr, NO_BUNDLE_MESSAGE); \
-    _glfwLibrary.Unbundled = 1; \
-    return
-
-void _glfwChangeToResourcesDirectory( void )
-{
-    CFBundleRef mainBundle = CFBundleGetMainBundle();
-    if( mainBundle == NULL )
-    {
-        UNBUNDLED;
-    }
-
-    CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL( mainBundle );
-    char resourcesPath[ _GLFW_MAX_PATH_LENGTH ];
-
-    CFStringRef lastComponent = CFURLCopyLastPathComponent( resourcesURL );
-    if( kCFCompareEqualTo != CFStringCompare(
-            CFSTR( "Resources" ),
-            lastComponent,
-            0 ) )
-    {
-        UNBUNDLED;
-    }
-
-    CFRelease( lastComponent );
-
-    if( !CFURLGetFileSystemRepresentation( resourcesURL,
-                                           TRUE,
-                                           (UInt8*)resourcesPath,
-                                           _GLFW_MAX_PATH_LENGTH ) )
-    {
-        CFRelease( resourcesURL );
-        UNBUNDLED;
-    }
-
-    CFRelease( resourcesURL );
-
-    if( chdir( resourcesPath ) != 0 )
-    {
-        UNBUNDLED;
-    }
-}
-
-int _glfwPlatformInit( void )
-{
-    struct timeval tv;
-    UInt32 nullDummy = 0;
-
-    _glfwWin.window = NULL;
-    _glfwWin.aglContext = NULL;
-    _glfwWin.cglContext = NULL;
-    _glfwWin.windowUPP = NULL;
-
-    _glfwInput.Modifiers = 0;
-
-    _glfwLibrary.Unbundled = 0;
-
-    _glfwLibrary.Libs.OpenGLFramework =
-        CFBundleGetBundleWithIdentifier( CFSTR( "com.apple.opengl" ) );
-    if( _glfwLibrary.Libs.OpenGLFramework == NULL )
-    {
-        fprintf( stderr, "glfwInit failing because you aren't linked to OpenGL\n" );
-        return GL_FALSE;
-    }
-
-    _glfwDesktopVideoMode = CGDisplayCurrentMode( kCGDirectMainDisplay );
-    if( _glfwDesktopVideoMode == NULL )
-    {
-        fprintf( stderr, "glfwInit failing because it kind find the desktop display mode\n" );
-        return GL_FALSE;
-    }
-
-    // Install atexit routine
-    atexit( glfw_atexit );
-
-    _glfwInitThreads();
-
-    _glfwChangeToResourcesDirectory();
-
-    // Ugly hack to reduce the nasty jump that occurs at the first non-
-    // sys keypress, caused by OS X loading certain meta scripts used
-    // for lexical- and raw keycode translation - instead of letting
-    // this happen while our application is running, we do some blunt
-    // function calls in advance just to get the script caching out of
-    // the way BEFORE our window/screen is opened. These calls might
-    // generate err return codes, but we don't care in this case.
-    // NOTE: KCHRPtr is declared globally, because we need it later on.
-    KCHRPtr = (void *)GetScriptVariable( smCurrentScript, smKCHRCache );
-    KeyTranslate( KCHRPtr, 0, &nullDummy );
-    UppercaseText( (char *)&nullDummy, 0, smSystemScript );
-
-    gettimeofday( &tv, NULL );
-    _glfwLibrary.Timer.t0 = tv.tv_sec + (double) tv.tv_usec / 1000000.0;
-
-    return GL_TRUE;
-}
-
-int _glfwPlatformTerminate( void )
-{
-    return GL_TRUE;
-}
-

+ 0 - 51
ThirdParty/GLFW/lib/carbon/carbon_joystick.c

@@ -1,51 +0,0 @@
-//========================================================================
-// GLFW - An OpenGL framework
-// Platform:    Carbon/AGL/CGL
-// API Version: 2.7
-// WWW:         http://www.glfw.org/
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2003      Keith Bauer
-// Copyright (c) 2003-2010 Camilla Berglund <[email protected]>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#include "internal.h"
-
-// TO DO: use HID manager to implement joystick support.
-
-int _glfwPlatformGetJoystickParam( int joy, int param )
-{
-    // GL_FALSE == 0
-    return 0;
-}
-
-int _glfwPlatformGetJoystickPos( int joy, float *pos, int numaxes )
-{
-    return 0;
-}
-
-int _glfwPlatformGetJoystickButtons( int joy, unsigned char *buttons, int numbuttons )
-{
-    return 0;
-}
-

+ 0 - 415
ThirdParty/GLFW/lib/carbon/carbon_thread.c

@@ -1,415 +0,0 @@
-//========================================================================
-// GLFW - An OpenGL framework
-// Platform:    Carbon/AGL/CGL
-// API Version: 2.7
-// WWW:         http://www.glfw.org/
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2003      Keith Bauer
-// Copyright (c) 2003-2010 Camilla Berglund <[email protected]>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#include "internal.h"
-
-
-
-//************************************************************************
-//****                  GLFW internal functions                       ****
-//************************************************************************
-
-//========================================================================
-// _glfwNewThread() - This is simply a "wrapper" for calling the user
-// thread function.
-//========================================================================
-
-void * _glfwNewThread( void * arg )
-{
-    GLFWthreadfun threadfun;
-    _GLFWthread   *t;
-
-    // Get pointer to thread information for current thread
-    t = _glfwGetThreadPointer( glfwGetThreadID() );
-    if( t == NULL )
-    {
-        return 0;
-    }
-
-    // Get user thread function pointer
-    threadfun = t->Function;
-
-    // Call the user thread function
-    threadfun( arg );
-
-    // Remove thread from thread list
-    ENTER_THREAD_CRITICAL_SECTION
-        _glfwRemoveThread( t );
-    LEAVE_THREAD_CRITICAL_SECTION
-
-    // When the thread function returns, the thread will die...
-    return NULL;
-}
-
-
-
-//************************************************************************
-//****               Platform implementation functions                ****
-//************************************************************************
-
-//========================================================================
-// _glfwPlatformCreateThread() - Create a new thread
-//========================================================================
-
-GLFWthread _glfwPlatformCreateThread( GLFWthreadfun fun, void *arg )
-{
-    GLFWthread  ID;
-    _GLFWthread *t;
-    int         result;
-
-    // Enter critical section
-    ENTER_THREAD_CRITICAL_SECTION
-
-    // Create a new thread information memory area
-    t = (_GLFWthread *) malloc( sizeof(_GLFWthread) );
-    if( t == NULL )
-    {
-        // Leave critical section
-        LEAVE_THREAD_CRITICAL_SECTION
-        return -1;
-    }
-
-    // Get a new unique thread id
-    ID = _glfwThrd.NextID ++;
-
-    // Store thread information in the thread list
-    t->Function = fun;
-    t->ID       = ID;
-
-    // Create thread
-    result = pthread_create(
-                            &t->PosixID,      // Thread handle
-                            NULL,             // Default thread attributes
-                            _glfwNewThread,   // Thread function (a wrapper function)
-                            (void *)arg       // Argument to thread is user argument
-                            );
-
-    // Did the thread creation fail?
-    if( result != 0 )
-    {
-        free( (void *) t );
-        LEAVE_THREAD_CRITICAL_SECTION
-        return -1;
-    }
-
-    // Append thread to thread list
-    _glfwAppendThread( t );
-
-    // Leave critical section
-    LEAVE_THREAD_CRITICAL_SECTION
-
-    // Return the GLFW thread ID
-    return ID;
-}
-
-
-//========================================================================
-// _glfwPlatformDestroyThread() - Kill a thread. NOTE: THIS IS A VERY
-// DANGEROUS OPERATION, AND SHOULD NOT BE USED EXCEPT IN EXTREME
-// SITUATIONS!
-//========================================================================
-
-void _glfwPlatformDestroyThread( GLFWthread ID )
-{
-    _GLFWthread *t;
-
-    // Enter critical section
-    ENTER_THREAD_CRITICAL_SECTION
-
-    // Get thread information pointer
-    t = _glfwGetThreadPointer( ID );
-    if( t == NULL )
-    {
-        LEAVE_THREAD_CRITICAL_SECTION
-        return;
-    }
-
-    // Simply murder the process, no mercy!
-    pthread_kill( t->PosixID, SIGKILL );
-
-    // Remove thread from thread list
-    _glfwRemoveThread( t );
-
-    // Leave critical section
-    LEAVE_THREAD_CRITICAL_SECTION
-}
-
-
-//========================================================================
-// _glfwPlatformWaitThread() - Wait for a thread to die
-//========================================================================
-
-int _glfwPlatformWaitThread( GLFWthread ID, int waitmode )
-{
-    pthread_t   thread;
-    _GLFWthread *t;
-
-    // Enter critical section
-    ENTER_THREAD_CRITICAL_SECTION
-
-    // Get thread information pointer
-    t = _glfwGetThreadPointer( ID );
-
-    // Is the thread already dead?
-    if( t == NULL )
-    {
-        LEAVE_THREAD_CRITICAL_SECTION
-        return GL_TRUE;
-    }
-
-    // If got this far, the thread is alive => polling returns FALSE
-    if( waitmode == GLFW_NOWAIT )
-    {
-        LEAVE_THREAD_CRITICAL_SECTION
-        return GL_FALSE;
-    }
-
-    // Get thread handle
-    thread = t->PosixID;
-
-    // Leave critical section
-    LEAVE_THREAD_CRITICAL_SECTION
-
-    // Wait for thread to die
-    (void) pthread_join( thread, NULL );
-
-    return GL_TRUE;
-}
-
-
-//========================================================================
-// _glfwPlatformGetThreadID() - Return the thread ID for the current
-// thread
-//========================================================================
-
-GLFWthread _glfwPlatformGetThreadID( void )
-{
-    _GLFWthread *t;
-    GLFWthread  ID = -1;
-    pthread_t   posixID;
-
-    // Get current thread ID
-    posixID = pthread_self();
-
-    // Enter critical section
-    ENTER_THREAD_CRITICAL_SECTION
-
-    // Loop through entire list of threads to find the matching POSIX
-    // thread ID
-    for( t = &_glfwThrd.First; t != NULL; t = t->Next )
-    {
-        if( t->PosixID == posixID )
-        {
-            ID = t->ID;
-            break;
-        }
-    }
-
-    // Leave critical section
-    LEAVE_THREAD_CRITICAL_SECTION
-
-    // Return the found GLFW thread identifier
-    return ID;
-}
-
-
-//========================================================================
-// _glfwPlatformCreateMutex() - Create a mutual exclusion object
-//========================================================================
-
-GLFWmutex _glfwPlatformCreateMutex( void )
-{
-    pthread_mutex_t *mutex;
-
-    // Allocate memory for mutex
-    mutex = (pthread_mutex_t *) malloc( sizeof( pthread_mutex_t ) );
-    if( !mutex )
-    {
-        return NULL;
-    }
-
-    // Initialise a mutex object
-    (void) pthread_mutex_init( mutex, NULL );
-
-    // Cast to GLFWmutex and return
-    return (GLFWmutex) mutex;
-}
-
-
-//========================================================================
-// _glfwPlatformDestroyMutex() - Destroy a mutual exclusion object
-//========================================================================
-
-void _glfwPlatformDestroyMutex( GLFWmutex mutex )
-{
-    // Destroy the mutex object
-    pthread_mutex_destroy( (pthread_mutex_t *) mutex );
-
-    // Free memory for mutex object
-    free( (void *) mutex );
-}
-
-
-//========================================================================
-// _glfwPlatformLockMutex() - Request access to a mutex
-//========================================================================
-
-void _glfwPlatformLockMutex( GLFWmutex mutex )
-{
-    // Wait for mutex to be released
-    (void) pthread_mutex_lock( (pthread_mutex_t *) mutex );
-}
-
-
-//========================================================================
-// _glfwPlatformUnlockMutex() - Release a mutex
-//========================================================================
-
-void _glfwPlatformUnlockMutex( GLFWmutex mutex )
-{
-    // Release mutex
-    pthread_mutex_unlock( (pthread_mutex_t *) mutex );
-}
-
-
-//========================================================================
-// _glfwPlatformCreateCond() - Create a new condition variable object
-//========================================================================
-
-GLFWcond _glfwPlatformCreateCond( void )
-{
-    pthread_cond_t *cond;
-
-    // Allocate memory for condition variable
-    cond = (pthread_cond_t *) malloc( sizeof(pthread_cond_t) );
-    if( !cond )
-    {
-        return NULL;
-    }
-
-    // Initialise condition variable
-    (void) pthread_cond_init( cond, NULL );
-
-    // Cast to GLFWcond and return
-    return (GLFWcond) cond;
-}
-
-
-//========================================================================
-// _glfwPlatformDestroyCond() - Destroy a condition variable object
-//========================================================================
-
-void _glfwPlatformDestroyCond( GLFWcond cond )
-{
-    // Destroy the condition variable object
-    (void) pthread_cond_destroy( (pthread_cond_t *) cond );
-
-    // Free memory for condition variable object
-    free( (void *) cond );
-}
-
-
-//========================================================================
-// _glfwPlatformWaitCond() - Wait for a condition to be raised
-//========================================================================
-
-void _glfwPlatformWaitCond( GLFWcond cond, GLFWmutex mutex,
-                            double timeout )
-{
-    struct timeval  currenttime;
-    struct timespec wait;
-    long dt_sec, dt_usec;
-
-    // Select infinite or timed wait
-    if( timeout >= GLFW_INFINITY )
-    {
-        // Wait for condition (infinite wait)
-        (void) pthread_cond_wait( (pthread_cond_t *) cond,
-                                  (pthread_mutex_t *) mutex );
-    }
-    else
-    {
-        // Set timeout time, relatvie to current time
-        gettimeofday( &currenttime, NULL );
-        dt_sec  = (long) timeout;
-        dt_usec = (long) ((timeout - (double)dt_sec) * 1000000.0);
-        wait.tv_nsec = (currenttime.tv_usec + dt_usec) * 1000L;
-        if( wait.tv_nsec > 1000000000L )
-        {
-            wait.tv_nsec -= 1000000000L;
-            dt_sec ++;
-        }
-        wait.tv_sec  = currenttime.tv_sec + dt_sec;
-
-        // Wait for condition (timed wait)
-        (void) pthread_cond_timedwait( (pthread_cond_t *) cond,
-                                       (pthread_mutex_t *) mutex, &wait );
-    }
-}
-
-
-//========================================================================
-// _glfwPlatformSignalCond() - Signal a condition to one waiting thread
-//========================================================================
-
-void _glfwPlatformSignalCond( GLFWcond cond )
-{
-    // Signal condition
-    (void) pthread_cond_signal( (pthread_cond_t *) cond );
-}
-
-
-//========================================================================
-// _glfwPlatformBroadcastCond() - Broadcast a condition to all waiting
-// threads
-//========================================================================
-
-void _glfwPlatformBroadcastCond( GLFWcond cond )
-{
-    // Broadcast condition
-    (void) pthread_cond_broadcast( (pthread_cond_t *) cond );
-}
-
-
-//========================================================================
-// _glfwPlatformGetNumberOfProcessors() - Return the number of processors
-// in the system.
-//========================================================================
-
-int _glfwPlatformGetNumberOfProcessors( void )
-{
-    int n;
-
-    // Get number of processors online
-    _glfw_numprocessors( n );
-    return n;
-}
-

+ 0 - 113
ThirdParty/GLFW/lib/carbon/carbon_time.c

@@ -1,113 +0,0 @@
-//========================================================================
-// GLFW - An OpenGL framework
-// Platform:    Carbon/AGL/CGL
-// API Version: 2.7
-// WWW:         http://www.glfw.org/
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2003      Keith Bauer
-// Copyright (c) 2003-2010 Camilla Berglund <[email protected]>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#include "internal.h"
-
-//************************************************************************
-//****               Platform implementation functions                ****
-//************************************************************************
-
-//========================================================================
-// Return timer value in seconds
-//========================================================================
-
-double _glfwPlatformGetTime( void )
-{
-    struct timeval  tv;
-
-    gettimeofday( &tv, NULL );
-    return tv.tv_sec + (double) tv.tv_usec / 1000000.0 - _glfwLibrary.Timer.t0;
-}
-
-
-//========================================================================
-// Set timer value in seconds
-//========================================================================
-
-void _glfwPlatformSetTime( double time )
-{
-    struct timeval  tv;
-
-    gettimeofday( &tv, NULL );
-    _glfwLibrary.Timer.t0 = tv.tv_sec + (double) tv.tv_usec / 1000000.0 - time;
-}
-
-
-//========================================================================
-// Put a thread to sleep for a specified amount of time
-//========================================================================
-
-void _glfwPlatformSleep( double time )
-{
-    if( time == 0.0 )
-    {
-	sched_yield();
-	return;
-    }
-
-    struct timeval  currenttime;
-    struct timespec wait;
-    pthread_mutex_t mutex;
-    pthread_cond_t  cond;
-    long dt_sec, dt_usec;
-
-    // Not all pthread implementations have a pthread_sleep() function. We
-    // do it the portable way, using a timed wait for a condition that we
-    // will never signal. NOTE: The unistd functions sleep/usleep suspends
-    // the entire PROCESS, not a signle thread, which is why we can not
-    // use them to implement glfwSleep.
-
-    // Set timeout time, relatvie to current time
-    gettimeofday( &currenttime, NULL );
-    dt_sec  = (long) time;
-    dt_usec = (long) ((time - (double)dt_sec) * 1000000.0);
-    wait.tv_nsec = (currenttime.tv_usec + dt_usec) * 1000L;
-    if( wait.tv_nsec > 1000000000L )
-    {
-        wait.tv_nsec -= 1000000000L;
-        dt_sec ++;
-    }
-    wait.tv_sec  = currenttime.tv_sec + dt_sec;
-
-    // Initialize condition and mutex objects
-    pthread_mutex_init( &mutex, NULL );
-    pthread_cond_init( &cond, NULL );
-
-    // Do a timed wait
-    pthread_mutex_lock( &mutex );
-    pthread_cond_timedwait( &cond, &mutex, &wait );
-    pthread_mutex_unlock( &mutex );
-
-    // Destroy condition and mutex objects
-    pthread_mutex_destroy( &mutex );
-    pthread_cond_destroy( &cond );
-}
-

+ 0 - 1309
ThirdParty/GLFW/lib/carbon/carbon_window.c

@@ -1,1309 +0,0 @@
-//========================================================================
-// GLFW - An OpenGL framework
-// Platform:    Carbon/AGL/CGL
-// API Version: 2.7
-// WWW:         http://www.glfw.org/
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2003      Keith Bauer
-// Copyright (c) 2003-2010 Camilla Berglund <[email protected]>
-// Copyright (c) 2006-2007 Robin Leffmann
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#include "internal.h"
-
-#define _glfwTestModifier( modifierMask, glfwKey ) \
-if ( changed & modifierMask ) \
-{ \
-    _glfwInputKey( glfwKey, (modifiers & modifierMask ? GLFW_PRESS : GLFW_RELEASE) ); \
-}
-
-//************************************************************************
-//****                  GLFW internal functions                       ****
-//************************************************************************
-
-static void handleMacModifierChange( UInt32 modifiers )
-{
-    UInt32 changed = modifiers ^ _glfwInput.Modifiers;
-
-    // The right *key variants below never actually occur
-    // There also isn't even a broken right command key constant
-    _glfwTestModifier( shiftKey,        GLFW_KEY_LSHIFT );
-    _glfwTestModifier( rightShiftKey,   GLFW_KEY_RSHIFT );
-    _glfwTestModifier( controlKey,      GLFW_KEY_LCTRL );
-    _glfwTestModifier( rightControlKey, GLFW_KEY_RCTRL );
-    _glfwTestModifier( optionKey,       GLFW_KEY_LALT );
-    _glfwTestModifier( rightOptionKey,  GLFW_KEY_RALT );
-    _glfwTestModifier( cmdKey,          GLFW_KEY_LSUPER );
-
-    _glfwInput.Modifiers = modifiers;
-}
-
-static void handleMacKeyChange( UInt32 keyCode, int action )
-{
-    switch ( keyCode )
-    {
-        case MAC_KEY_ENTER:       _glfwInputKey( GLFW_KEY_ENTER,       action); break;
-        case MAC_KEY_RETURN:      _glfwInputKey( GLFW_KEY_KP_ENTER,    action); break;
-        case MAC_KEY_ESC:         _glfwInputKey( GLFW_KEY_ESC,         action); break;
-        case MAC_KEY_F1:          _glfwInputKey( GLFW_KEY_F1,          action); break;
-        case MAC_KEY_F2:          _glfwInputKey( GLFW_KEY_F2,          action); break;
-        case MAC_KEY_F3:          _glfwInputKey( GLFW_KEY_F3,          action); break;
-        case MAC_KEY_F4:          _glfwInputKey( GLFW_KEY_F4,          action); break;
-        case MAC_KEY_F5:          _glfwInputKey( GLFW_KEY_F5,          action); break;
-        case MAC_KEY_F6:          _glfwInputKey( GLFW_KEY_F6,          action); break;
-        case MAC_KEY_F7:          _glfwInputKey( GLFW_KEY_F7,          action); break;
-        case MAC_KEY_F8:          _glfwInputKey( GLFW_KEY_F8,          action); break;
-        case MAC_KEY_F9:          _glfwInputKey( GLFW_KEY_F9,          action); break;
-        case MAC_KEY_F10:         _glfwInputKey( GLFW_KEY_F10,         action); break;
-        case MAC_KEY_F11:         _glfwInputKey( GLFW_KEY_F11,         action); break;
-        case MAC_KEY_F12:         _glfwInputKey( GLFW_KEY_F12,         action); break;
-        case MAC_KEY_F13:         _glfwInputKey( GLFW_KEY_F13,         action); break;
-        case MAC_KEY_F14:         _glfwInputKey( GLFW_KEY_F14,         action); break;
-        case MAC_KEY_F15:         _glfwInputKey( GLFW_KEY_F15,         action); break;
-        case MAC_KEY_UP:          _glfwInputKey( GLFW_KEY_UP,          action); break;
-        case MAC_KEY_DOWN:        _glfwInputKey( GLFW_KEY_DOWN,        action); break;
-        case MAC_KEY_LEFT:        _glfwInputKey( GLFW_KEY_LEFT,        action); break;
-        case MAC_KEY_RIGHT:       _glfwInputKey( GLFW_KEY_RIGHT,       action); break;
-        case MAC_KEY_TAB:         _glfwInputKey( GLFW_KEY_TAB,         action); break;
-        case MAC_KEY_BACKSPACE:   _glfwInputKey( GLFW_KEY_BACKSPACE,   action); break;
-        case MAC_KEY_HELP:        _glfwInputKey( GLFW_KEY_INSERT,      action); break;
-        case MAC_KEY_DEL:         _glfwInputKey( GLFW_KEY_DEL,         action); break;
-        case MAC_KEY_PAGEUP:      _glfwInputKey( GLFW_KEY_PAGEUP,      action); break;
-        case MAC_KEY_PAGEDOWN:    _glfwInputKey( GLFW_KEY_PAGEDOWN,    action); break;
-        case MAC_KEY_HOME:        _glfwInputKey( GLFW_KEY_HOME,        action); break;
-        case MAC_KEY_END:         _glfwInputKey( GLFW_KEY_END,         action); break;
-        case MAC_KEY_KP_0:        _glfwInputKey( GLFW_KEY_KP_0,        action); break;
-        case MAC_KEY_KP_1:        _glfwInputKey( GLFW_KEY_KP_1,        action); break;
-        case MAC_KEY_KP_2:        _glfwInputKey( GLFW_KEY_KP_2,        action); break;
-        case MAC_KEY_KP_3:        _glfwInputKey( GLFW_KEY_KP_3,        action); break;
-        case MAC_KEY_KP_4:        _glfwInputKey( GLFW_KEY_KP_4,        action); break;
-        case MAC_KEY_KP_5:        _glfwInputKey( GLFW_KEY_KP_5,        action); break;
-        case MAC_KEY_KP_6:        _glfwInputKey( GLFW_KEY_KP_6,        action); break;
-        case MAC_KEY_KP_7:        _glfwInputKey( GLFW_KEY_KP_7,        action); break;
-        case MAC_KEY_KP_8:        _glfwInputKey( GLFW_KEY_KP_8,        action); break;
-        case MAC_KEY_KP_9:        _glfwInputKey( GLFW_KEY_KP_9,        action); break;
-        case MAC_KEY_KP_DIVIDE:   _glfwInputKey( GLFW_KEY_KP_DIVIDE,   action); break;
-        case MAC_KEY_KP_MULTIPLY: _glfwInputKey( GLFW_KEY_KP_MULTIPLY, action); break;
-        case MAC_KEY_KP_SUBTRACT: _glfwInputKey( GLFW_KEY_KP_SUBTRACT, action); break;
-        case MAC_KEY_KP_ADD:      _glfwInputKey( GLFW_KEY_KP_ADD,      action); break;
-        case MAC_KEY_KP_DECIMAL:  _glfwInputKey( GLFW_KEY_KP_DECIMAL,  action); break;
-        case MAC_KEY_KP_EQUAL:    _glfwInputKey( GLFW_KEY_KP_EQUAL,    action); break;
-        case MAC_KEY_KP_ENTER:    _glfwInputKey( GLFW_KEY_KP_ENTER,    action); break;
-        case MAC_KEY_NUMLOCK:     _glfwInputKey( GLFW_KEY_KP_NUM_LOCK, action); break;
-        default:
-        {
-            extern void *KCHRPtr;
-            UInt32 state = 0;
-            char charCode = (char)KeyTranslate( KCHRPtr, keyCode, &state );
-            UppercaseText( &charCode, 1, smSystemScript );
-            _glfwInputKey( (unsigned char)charCode, action );
-        }
-        break;
-    }
-}
-
-// The set of event class/kind combinations supported by keyEventHandler
-// This is used by installEventHandlers below
-static const EventTypeSpec GLFW_KEY_EVENT_TYPES[] =
-{
-    { kEventClassKeyboard, kEventRawKeyDown },
-    { kEventClassKeyboard, kEventRawKeyUp },
-    { kEventClassKeyboard, kEventRawKeyRepeat },
-    { kEventClassKeyboard, kEventRawKeyModifiersChanged }
-};
-
-static OSStatus keyEventHandler( EventHandlerCallRef handlerCallRef,
-                                 EventRef event,
-                                 void *userData )
-{
-    UInt32 keyCode;
-    short int keyChar;
-    UInt32 modifiers;
-
-    switch( GetEventKind( event ) )
-    {
-        case kEventRawKeyRepeat:
-        case kEventRawKeyDown:
-        {
-            if( GetEventParameter( event,
-                                   kEventParamKeyCode,
-                                   typeUInt32,
-                                   NULL,
-                                   sizeof( UInt32 ),
-                                   NULL,
-                                   &keyCode ) == noErr )
-            {
-                handleMacKeyChange( keyCode, GLFW_PRESS );
-            }
-            if( GetEventParameter( event,
-                                   kEventParamKeyUnicodes,
-                                   typeUnicodeText,
-                                   NULL,
-                                   sizeof(keyChar),
-                                   NULL,
-                                   &keyChar) == noErr )
-            {
-                _glfwInputChar( keyChar, GLFW_PRESS );
-            }
-            return noErr;
-        }
-
-        case kEventRawKeyUp:
-        {
-            if( GetEventParameter( event,
-                                   kEventParamKeyCode,
-                                   typeUInt32,
-                                   NULL,
-                                   sizeof( UInt32 ),
-                                   NULL,
-                                   &keyCode ) == noErr )
-            {
-                handleMacKeyChange( keyCode, GLFW_RELEASE );
-            }
-            if( GetEventParameter( event,
-                                   kEventParamKeyUnicodes,
-                                   typeUnicodeText,
-                                   NULL,
-                                   sizeof(keyChar),
-                                   NULL,
-                                   &keyChar) == noErr )
-            {
-                _glfwInputChar( keyChar, GLFW_RELEASE );
-            }
-            return noErr;
-        }
-
-        case kEventRawKeyModifiersChanged:
-        {
-            if( GetEventParameter( event,
-                                   kEventParamKeyModifiers,
-                                   typeUInt32,
-                                   NULL,
-                                   sizeof( UInt32 ),
-                                   NULL,
-                                   &modifiers ) == noErr )
-            {
-                handleMacModifierChange( modifiers );
-                return noErr;
-            }
-        }
-        break;
-    }
-
-    return eventNotHandledErr;
-}
-
-// The set of event class/kind combinations supported by mouseEventHandler
-// This is used by installEventHandlers below
-static const EventTypeSpec GLFW_MOUSE_EVENT_TYPES[] =
-{
-    { kEventClassMouse, kEventMouseDown },
-    { kEventClassMouse, kEventMouseUp },
-    { kEventClassMouse, kEventMouseMoved },
-    { kEventClassMouse, kEventMouseDragged },
-    { kEventClassMouse, kEventMouseWheelMoved },
-};
-
-static OSStatus mouseEventHandler( EventHandlerCallRef handlerCallRef,
-                                   EventRef event,
-                                   void *userData )
-{
-    switch( GetEventKind( event ) )
-    {
-        case kEventMouseDown:
-        {
-            WindowRef window;
-            EventRecord oldStyleMacEvent;
-            ConvertEventRefToEventRecord( event, &oldStyleMacEvent );
-            if( FindWindow ( oldStyleMacEvent.where, &window ) == inMenuBar )
-            {
-                MenuSelect( oldStyleMacEvent.where );
-                HiliteMenu(0);
-                return noErr;
-            }
-            else
-            {
-                EventMouseButton button;
-                if( GetEventParameter( event,
-                                       kEventParamMouseButton,
-                                       typeMouseButton,
-                                       NULL,
-                                       sizeof( EventMouseButton ),
-                                       NULL,
-                                       &button ) == noErr )
-                {
-                    button -= kEventMouseButtonPrimary;
-                    if( button <= GLFW_MOUSE_BUTTON_LAST )
-                    {
-                        _glfwInputMouseClick( button + GLFW_MOUSE_BUTTON_LEFT,
-                                              GLFW_PRESS );
-                    }
-                    return noErr;
-                }
-            }
-            break;
-        }
-
-        case kEventMouseUp:
-        {
-            EventMouseButton button;
-            if( GetEventParameter( event,
-                                   kEventParamMouseButton,
-                                   typeMouseButton,
-                                   NULL,
-                                   sizeof( EventMouseButton ),
-                                   NULL,
-                                   &button ) == noErr )
-            {
-                button -= kEventMouseButtonPrimary;
-                if( button <= GLFW_MOUSE_BUTTON_LAST )
-                {
-                    _glfwInputMouseClick( button + GLFW_MOUSE_BUTTON_LEFT,
-                                          GLFW_RELEASE );
-                }
-                return noErr;
-            }
-            break;
-        }
-
-        case kEventMouseMoved:
-        case kEventMouseDragged:
-        {
-            HIPoint mouseLocation;
-            if( _glfwWin.mouseLock )
-            {
-                if( GetEventParameter( event,
-                                       kEventParamMouseDelta,
-                                       typeHIPoint,
-                                       NULL,
-                                       sizeof( HIPoint ),
-                                       NULL,
-                                       &mouseLocation ) != noErr )
-                {
-                    break;
-                }
-
-                _glfwInput.MousePosX += mouseLocation.x;
-                _glfwInput.MousePosY += mouseLocation.y;
-            }
-            else
-            {
-                if( GetEventParameter( event,
-                                       kEventParamMouseLocation,
-                                       typeHIPoint,
-                                       NULL,
-                                       sizeof( HIPoint ),
-                                       NULL,
-                                       &mouseLocation ) != noErr )
-                {
-                    break;
-                }
-
-                _glfwInput.MousePosX = mouseLocation.x;
-                _glfwInput.MousePosY = mouseLocation.y;
-
-                if( !_glfwWin.fullscreen )
-                {
-                    Rect content;
-                    GetWindowBounds( _glfwWin.window,
-                                     kWindowContentRgn,
-                                     &content );
-
-                    _glfwInput.MousePosX -= content.left;
-                    _glfwInput.MousePosY -= content.top;
-                }
-            }
-
-            if( _glfwWin.mousePosCallback )
-            {
-                _glfwWin.mousePosCallback( _glfwInput.MousePosX,
-                                           _glfwInput.MousePosY );
-            }
-
-            break;
-        }
-
-        case kEventMouseWheelMoved:
-        {
-            EventMouseWheelAxis axis;
-            if( GetEventParameter( event,
-                                   kEventParamMouseWheelAxis,
-                                   typeMouseWheelAxis,
-                                   NULL,
-                                   sizeof( EventMouseWheelAxis ),
-                                   NULL,
-                                   &axis) == noErr )
-            {
-                long wheelDelta;
-                if( axis == kEventMouseWheelAxisY &&
-                    GetEventParameter( event,
-                                       kEventParamMouseWheelDelta,
-                                       typeLongInteger,
-                                       NULL,
-                                       sizeof( long ),
-                                       NULL,
-                                       &wheelDelta ) == noErr )
-                {
-                    _glfwInput.WheelPos += wheelDelta;
-                    if( _glfwWin.mouseWheelCallback )
-                    {
-                        _glfwWin.mouseWheelCallback( _glfwInput.WheelPos );
-                    }
-                    return noErr;
-                }
-            }
-            break;
-        }
-    }
-
-    return eventNotHandledErr;
-}
-
-// The set of event class/kind combinations supported by commandHandler
-// This is used by installEventHandlers below
-static const EventTypeSpec GLFW_COMMAND_EVENT_TYPES[] =
-{
-    { kEventClassCommand, kEventCommandProcess }
-};
-
-static OSStatus commandHandler( EventHandlerCallRef handlerCallRef,
-                                EventRef event,
-                                void *userData )
-{
-    if( _glfwWin.sysKeysDisabled )
-    {
-        // TODO: Give adequate UI feedback that this is the case
-        return eventNotHandledErr;
-    }
-
-    HICommand command;
-    if( GetEventParameter( event,
-                           kEventParamDirectObject,
-                           typeHICommand,
-                           NULL,
-                           sizeof( HICommand ),
-                           NULL,
-                           &command ) == noErr )
-    {
-        switch( command.commandID )
-        {
-            case kHICommandClose:
-            case kHICommandQuit:
-            {
-                // Check if the program wants us to close the window
-                if( _glfwWin.windowCloseCallback )
-                {
-                    if( _glfwWin.windowCloseCallback() )
-                    {
-                        glfwCloseWindow();
-                    }
-                }
-                else
-                {
-                    glfwCloseWindow();
-                }
-                return noErr;
-            }
-        }
-    }
-
-    return eventNotHandledErr;
-}
-
-// The set of event class/kind combinations supported by windowEventHandler
-// This is used by installEventHandlers below
-static const EventTypeSpec GLFW_WINDOW_EVENT_TYPES[] =
-{
-  { kEventClassWindow, kEventWindowBoundsChanged },
-  { kEventClassWindow, kEventWindowClose },
-  { kEventClassWindow, kEventWindowDrawContent },
-  { kEventClassWindow, kEventWindowActivated },
-  { kEventClassWindow, kEventWindowDeactivated },
-};
-
-static OSStatus windowEventHandler( EventHandlerCallRef handlerCallRef,
-                                    EventRef event,
-                                    void *userData )
-{
-    switch( GetEventKind(event) )
-    {
-        case kEventWindowBoundsChanged:
-        {
-            WindowRef window;
-            GetEventParameter( event,
-                               kEventParamDirectObject,
-                               typeWindowRef,
-                               NULL,
-                               sizeof(WindowRef),
-                               NULL,
-                               &window );
-
-            Rect rect;
-            GetWindowPortBounds( window, &rect );
-
-            if( _glfwWin.width != rect.right ||
-                _glfwWin.height != rect.bottom )
-            {
-                aglUpdateContext( _glfwWin.aglContext );
-
-                _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;
-        }
-
-        case kEventWindowClose:
-        {
-            // Check if the client wants us to close the window
-            if( _glfwWin.windowCloseCallback )
-            {
-                if( _glfwWin.windowCloseCallback() )
-                {
-                        glfwCloseWindow();
-                }
-            }
-            else
-            {
-                glfwCloseWindow();
-            }
-            return noErr;
-        }
-
-        case kEventWindowDrawContent:
-        {
-            if( _glfwWin.windowRefreshCallback )
-            {
-                _glfwWin.windowRefreshCallback();
-            }
-            break;
-        }
-
-        case kEventWindowActivated:
-        {
-            _glfwWin.active = GL_TRUE;
-            break;
-        }
-
-        case kEventWindowDeactivated:
-        {
-            _glfwWin.active = GL_FALSE;
-            _glfwInputDeactivation();
-            break;
-        }
-    }
-
-    return eventNotHandledErr;
-}
-
-static int installEventHandlers( void )
-{
-    OSStatus error;
-
-    _glfwWin.mouseUPP = NewEventHandlerUPP( mouseEventHandler );
-
-    error = InstallEventHandler( GetApplicationEventTarget(),
-                                 _glfwWin.mouseUPP,
-                                 GetEventTypeCount( GLFW_MOUSE_EVENT_TYPES ),
-                                 GLFW_MOUSE_EVENT_TYPES,
-                                 NULL,
-                                 NULL );
-    if( error != noErr )
-    {
-        fprintf( stderr, "Failed to install Carbon application mouse event handler\n" );
-        return GL_FALSE;
-    }
-
-    _glfwWin.commandUPP = NewEventHandlerUPP( commandHandler );
-
-    error = InstallEventHandler( GetApplicationEventTarget(),
-                                 _glfwWin.commandUPP,
-                                 GetEventTypeCount( GLFW_COMMAND_EVENT_TYPES ),
-                                 GLFW_COMMAND_EVENT_TYPES,
-                                 NULL,
-                                 NULL );
-    if( error != noErr )
-    {
-        fprintf( stderr, "Failed to install Carbon application command event handler\n" );
-        return GL_FALSE;
-    }
-
-    _glfwWin.keyboardUPP = NewEventHandlerUPP( keyEventHandler );
-
-    error = InstallEventHandler( GetApplicationEventTarget(),
-                                 _glfwWin.keyboardUPP,
-                                 GetEventTypeCount( GLFW_KEY_EVENT_TYPES ),
-                                 GLFW_KEY_EVENT_TYPES,
-                                 NULL,
-                                 NULL );
-    if( error != noErr )
-    {
-        fprintf( stderr, "Failed to install Carbon application key event handler\n" );
-        return GL_FALSE;
-    }
-
-    return GL_TRUE;
-}
-
-//************************************************************************
-//****               Platform implementation functions                ****
-//************************************************************************
-
-#define _setAGLAttribute( aglAttributeName, AGLparameter ) \
-if ( AGLparameter != 0 ) \
-{ \
-    AGLpixelFormatAttributes[numAGLAttrs++] = aglAttributeName; \
-    AGLpixelFormatAttributes[numAGLAttrs++] = AGLparameter; \
-}
-
-#define _setCGLAttribute( cglAttributeName, CGLparameter ) \
-if ( CGLparameter != 0 ) \
-{ \
-    CGLpixelFormatAttributes[ numCGLAttrs++ ] = cglAttributeName; \
-    CGLpixelFormatAttributes[ numCGLAttrs++ ] = CGLparameter; \
-}
-
-//========================================================================
-// Here is where the window is created, and
-// the OpenGL rendering context is created
-//========================================================================
-
-int  _glfwPlatformOpenWindow( int width, int height,
-                              const _GLFWwndconfig *wndconfig,
-                              const _GLFWfbconfig *fbconfig )
-{
-    OSStatus error;
-    unsigned int windowAttributes;
-    ProcessSerialNumber psn;
-
-    // TODO: Break up this function!
-
-    _glfwWin.windowUPP      = NULL;
-    _glfwWin.mouseUPP       = NULL;
-    _glfwWin.keyboardUPP    = NULL;
-    _glfwWin.commandUPP     = NULL;
-    _glfwWin.window         = NULL;
-    _glfwWin.aglContext     = NULL;
-    _glfwWin.aglPixelFormat = NULL;
-    _glfwWin.cglContext     = NULL;
-    _glfwWin.cglPixelFormat = NULL;
-
-    _glfwWin.refreshRate = wndconfig->refreshRate;
-
-    // Fail if OpenGL 3.0 or above was requested
-    if( wndconfig->glMajor > 2 )
-    {
-        fprintf( stderr, "OpenGL 3.0+ is not yet supported on Mac OS X\n" );
-
-        _glfwPlatformCloseWindow();
-        return GL_FALSE;
-    }
-
-    if( _glfwLibrary.Unbundled )
-    {
-        if( GetCurrentProcess( &psn ) != noErr )
-        {
-            fprintf( stderr, "Failed to get the process serial number\n" );
-
-            _glfwPlatformCloseWindow();
-            return GL_FALSE;
-        }
-
-        if( TransformProcessType( &psn, kProcessTransformToForegroundApplication ) != noErr )
-        {
-            fprintf( stderr, "Failed to become a foreground application\n" );
-
-            _glfwPlatformCloseWindow();
-            return GL_FALSE;
-        }
-
-        if( wndconfig->mode == GLFW_FULLSCREEN )
-        {
-            if( SetFrontProcess( &psn ) != noErr )
-            {
-                fprintf( stderr, "Failed to become the front process\n" );
-
-                _glfwPlatformCloseWindow();
-                return GL_FALSE;
-            }
-        }
-    }
-
-    if( !installEventHandlers() )
-    {
-        fprintf( stderr,
-                 "Failed to install Carbon application event handlers\n" );
-
-        _glfwPlatformTerminate();
-        return GL_FALSE;
-    }
-
-    // Windowed or fullscreen; AGL or CGL? Quite the mess...
-    // AGL appears to be the only choice for attaching OpenGL contexts to
-    // Carbon windows, but it leaves the user no control over fullscreen
-    // mode stretching. Solution: AGL for windowed, CGL for fullscreen.
-    if( wndconfig->mode == GLFW_WINDOW )
-    {
-        // create AGL pixel format attribute list
-        GLint AGLpixelFormatAttributes[256];
-        int numAGLAttrs = 0;
-
-        AGLpixelFormatAttributes[numAGLAttrs++] = AGL_RGBA;
-        AGLpixelFormatAttributes[numAGLAttrs++] = AGL_DOUBLEBUFFER;
-        AGLpixelFormatAttributes[numAGLAttrs++] = AGL_CLOSEST_POLICY;
-
-        if( fbconfig->stereo )
-        {
-            AGLpixelFormatAttributes[numAGLAttrs++] = AGL_STEREO;
-        }
-
-        _setAGLAttribute( AGL_AUX_BUFFERS,      fbconfig->auxBuffers);
-        _setAGLAttribute( AGL_RED_SIZE,         fbconfig->redBits );
-        _setAGLAttribute( AGL_GREEN_SIZE,       fbconfig->greenBits );
-        _setAGLAttribute( AGL_BLUE_SIZE,        fbconfig->blueBits );
-        _setAGLAttribute( AGL_ALPHA_SIZE,       fbconfig->alphaBits );
-        _setAGLAttribute( AGL_DEPTH_SIZE,       fbconfig->depthBits );
-        _setAGLAttribute( AGL_STENCIL_SIZE,     fbconfig->stencilBits );
-        _setAGLAttribute( AGL_ACCUM_RED_SIZE,   fbconfig->accumRedBits );
-        _setAGLAttribute( AGL_ACCUM_GREEN_SIZE, fbconfig->accumGreenBits );
-        _setAGLAttribute( AGL_ACCUM_BLUE_SIZE,  fbconfig->accumBlueBits );
-        _setAGLAttribute( AGL_ACCUM_ALPHA_SIZE, fbconfig->accumAlphaBits );
-
-        if( fbconfig->samples > 1 )
-        {
-            _setAGLAttribute( AGL_SAMPLE_BUFFERS_ARB, 1 );
-            _setAGLAttribute( AGL_SAMPLES_ARB, fbconfig->samples );
-            AGLpixelFormatAttributes[numAGLAttrs++] = AGL_NO_RECOVERY;
-        }
-
-        AGLpixelFormatAttributes[numAGLAttrs++] = AGL_NONE;
-
-        // create pixel format descriptor
-        AGLDevice mainMonitor = GetMainDevice();
-        _glfwWin.aglPixelFormat = aglChoosePixelFormat( &mainMonitor,
-                                                        1,
-                                                        AGLpixelFormatAttributes );
-        if( _glfwWin.aglPixelFormat == NULL )
-        {
-            fprintf( stderr,
-                     "Failed to choose AGL pixel format: %s\n",
-                     aglErrorString( aglGetError() ) );
-
-            _glfwPlatformCloseWindow();
-            return GL_FALSE;
-        }
-
-        // create AGL context
-        _glfwWin.aglContext = aglCreateContext( _glfwWin.aglPixelFormat, NULL );
-
-        if( _glfwWin.aglContext == NULL )
-        {
-            fprintf( stderr,
-                     "Failed to create AGL context: %s\n",
-                     aglErrorString( aglGetError() ) );
-
-            _glfwPlatformCloseWindow();
-            return GL_FALSE;
-        }
-
-        // create window
-        Rect windowContentBounds;
-        windowContentBounds.left = 0;
-        windowContentBounds.top = 0;
-        windowContentBounds.right = width;
-        windowContentBounds.bottom = height;
-
-        windowAttributes = ( kWindowCloseBoxAttribute |
-                             kWindowCollapseBoxAttribute |
-                             kWindowStandardHandlerAttribute );
-
-        if( wndconfig->windowNoResize )
-        {
-            windowAttributes |= kWindowLiveResizeAttribute;
-        }
-        else
-        {
-            windowAttributes |= ( kWindowFullZoomAttribute |
-                                  kWindowResizableAttribute );
-        }
-
-        error = CreateNewWindow( kDocumentWindowClass,
-                                 windowAttributes,
-                                 &windowContentBounds,
-                                 &( _glfwWin.window ) );
-        if( ( error != noErr ) || ( _glfwWin.window == NULL ) )
-        {
-            fprintf( stderr, "Failed to create Carbon window\n" );
-
-            _glfwPlatformCloseWindow();
-            return GL_FALSE;
-        }
-
-        _glfwWin.windowUPP = NewEventHandlerUPP( windowEventHandler );
-
-        error = InstallWindowEventHandler( _glfwWin.window,
-                                           _glfwWin.windowUPP,
-                                           GetEventTypeCount( GLFW_WINDOW_EVENT_TYPES ),
-                                           GLFW_WINDOW_EVENT_TYPES,
-                                           NULL,
-                                           NULL );
-        if( error != noErr )
-        {
-            fprintf( stderr, "Failed to install Carbon window event handler\n" );
-
-            _glfwPlatformCloseWindow();
-            return GL_FALSE;
-        }
-
-        // Don't care if we fail here
-        (void)SetWindowTitleWithCFString( _glfwWin.window, CFSTR( "GLFW Window" ) );
-        (void)RepositionWindow( _glfwWin.window,
-                                NULL,
-                                kWindowCenterOnMainScreen );
-
-        if( !aglSetDrawable( _glfwWin.aglContext,
-                             GetWindowPort( _glfwWin.window ) ) )
-        {
-            fprintf( stderr,
-                     "Failed to set the AGL context as the Carbon window drawable: %s\n",
-                     aglErrorString( aglGetError() ) );
-
-            _glfwPlatformCloseWindow();
-            return GL_FALSE;
-        }
-
-        // Make OpenGL context current
-        if( !aglSetCurrentContext( _glfwWin.aglContext ) )
-        {
-            fprintf( stderr,
-                     "Failed to make AGL context current: %s\n",
-                     aglErrorString( aglGetError() ) );
-
-            _glfwPlatformCloseWindow();
-            return GL_FALSE;
-        }
-
-        ShowWindow( _glfwWin.window );
-    }
-    else
-    {
-        CGDisplayErr cgErr;
-        CGLError cglErr;
-
-        CFDictionaryRef optimalMode;
-
-        GLint numCGLvs = 0;
-
-        CGLPixelFormatAttribute CGLpixelFormatAttributes[64];
-        int numCGLAttrs = 0;
-
-        // variables for enumerating color depths
-        GLint rgbColorDepth;
-
-        // CGL pixel format attributes
-        _setCGLAttribute( kCGLPFADisplayMask,
-                          CGDisplayIDToOpenGLDisplayMask( kCGDirectMainDisplay ) );
-
-        if( fbconfig->stereo )
-        {
-            CGLpixelFormatAttributes[ numCGLAttrs++ ] = kCGLPFAStereo;
-        }
-
-        if( fbconfig->samples > 1 )
-        {
-            _setCGLAttribute( kCGLPFASamples,       (CGLPixelFormatAttribute)fbconfig->samples );
-            _setCGLAttribute( kCGLPFASampleBuffers, (CGLPixelFormatAttribute)1 );
-            CGLpixelFormatAttributes[ numCGLAttrs++ ] = kCGLPFANoRecovery;
-        }
-
-        CGLpixelFormatAttributes[ numCGLAttrs++ ] = kCGLPFAFullScreen;
-        CGLpixelFormatAttributes[ numCGLAttrs++ ] = kCGLPFADoubleBuffer;
-        CGLpixelFormatAttributes[ numCGLAttrs++ ] = kCGLPFAAccelerated;
-        CGLpixelFormatAttributes[ numCGLAttrs++ ] = kCGLPFANoRecovery;
-        CGLpixelFormatAttributes[ numCGLAttrs++ ] = kCGLPFAMinimumPolicy;
-
-        _setCGLAttribute( kCGLPFAAccumSize,
-                          (CGLPixelFormatAttribute)( fbconfig->accumRedBits \
-                                                   + fbconfig->accumGreenBits \
-                                                   + fbconfig->accumBlueBits \
-                                                   + fbconfig->accumAlphaBits ) );
-
-        _setCGLAttribute( kCGLPFAAlphaSize,   (CGLPixelFormatAttribute)fbconfig->alphaBits );
-        _setCGLAttribute( kCGLPFADepthSize,   (CGLPixelFormatAttribute)fbconfig->depthBits );
-        _setCGLAttribute( kCGLPFAStencilSize, (CGLPixelFormatAttribute)fbconfig->stencilBits );
-        _setCGLAttribute( kCGLPFAAuxBuffers,  (CGLPixelFormatAttribute)fbconfig->auxBuffers );
-
-        CGLpixelFormatAttributes[ numCGLAttrs++ ] = (CGLPixelFormatAttribute)NULL;
-
-        // create a suitable pixel format with above attributes..
-        cglErr = CGLChoosePixelFormat( CGLpixelFormatAttributes,
-                                       &_glfwWin.cglPixelFormat,
-                                       &numCGLvs );
-        if( cglErr != kCGLNoError )
-        {
-            fprintf( stderr,
-                     "Failed to choose CGL pixel format: %s\n",
-                     CGLErrorString( cglErr ) );
-
-            _glfwPlatformCloseWindow();
-            return GL_FALSE;
-        }
-
-        // ..and create a rendering context using that pixel format
-        cglErr = CGLCreateContext( _glfwWin.cglPixelFormat, NULL, &_glfwWin.cglContext );
-        if( cglErr != kCGLNoError )
-        {
-            fprintf( stderr,
-                     "Failed to create CGL context: %s\n",
-                     CGLErrorString( cglErr ) );
-
-            _glfwPlatformCloseWindow();
-            return GL_FALSE;
-        }
-
-        // 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,
-                                      0,
-                                      kCGLPFAColorSize,
-                                      &rgbColorDepth );
-
-        // capture the display for our application
-        cgErr = CGCaptureAllDisplays();
-        if( cgErr != kCGErrorSuccess )
-        {
-            fprintf( stderr,
-                     "Failed to capture Core Graphics displays\n");
-
-            _glfwPlatformCloseWindow();
-            return GL_FALSE;
-        }
-
-        // find closest matching NON-STRETCHED display mode..
-        optimalMode = CGDisplayBestModeForParametersAndRefreshRateWithProperty(
-                            kCGDirectMainDisplay,
-                            rgbColorDepth,
-                            width,
-                            height,
-                            wndconfig->refreshRate,
-                            NULL,
-                            NULL );
-        if( optimalMode == NULL )
-        {
-            fprintf( stderr,
-                     "Failed to retrieve Core Graphics display mode\n");
-
-            _glfwPlatformCloseWindow();
-            return GL_FALSE;
-        }
-
-        // ..and switch to that mode
-        cgErr = CGDisplaySwitchToMode( kCGDirectMainDisplay, optimalMode );
-        if( cgErr != kCGErrorSuccess )
-        {
-            fprintf( stderr,
-                     "Failed to switch to Core Graphics display mode\n");
-
-            _glfwPlatformCloseWindow();
-            return GL_FALSE;
-        }
-
-        // switch to our OpenGL context, and bring it up fullscreen
-        cglErr = CGLSetCurrentContext( _glfwWin.cglContext );
-        if( cglErr != kCGLNoError )
-        {
-            fprintf( stderr,
-                     "Failed to make CGL context current: %s\n",
-                     CGLErrorString( cglErr ) );
-
-            _glfwPlatformCloseWindow();
-            return GL_FALSE;
-        }
-
-        cglErr = CGLSetFullScreen( _glfwWin.cglContext );
-        if( cglErr != kCGLNoError )
-        {
-            fprintf( stderr,
-                     "Failed to set CGL fullscreen mode: %s\n",
-                     CGLErrorString( cglErr ) );
-
-            _glfwPlatformCloseWindow();
-            return GL_FALSE;
-        }
-    }
-
-    return GL_TRUE;
-}
-
-//========================================================================
-// Properly kill the window/video display
-//========================================================================
-
-void _glfwPlatformCloseWindow( void )
-{
-    if( _glfwWin.mouseUPP != NULL )
-    {
-        DisposeEventHandlerUPP( _glfwWin.mouseUPP );
-        _glfwWin.mouseUPP = NULL;
-    }
-    if( _glfwWin.commandUPP != NULL )
-    {
-        DisposeEventHandlerUPP( _glfwWin.commandUPP );
-        _glfwWin.commandUPP = NULL;
-    }
-    if( _glfwWin.keyboardUPP != NULL )
-    {
-        DisposeEventHandlerUPP( _glfwWin.keyboardUPP );
-        _glfwWin.keyboardUPP = NULL;
-    }
-    if( _glfwWin.windowUPP != NULL )
-    {
-        DisposeEventHandlerUPP( _glfwWin.windowUPP );
-        _glfwWin.windowUPP = NULL;
-    }
-
-    if( _glfwWin.fullscreen )
-    {
-        if( _glfwWin.cglContext != NULL )
-        {
-            CGLSetCurrentContext( NULL );
-            CGLClearDrawable( _glfwWin.cglContext );
-            CGLDestroyContext( _glfwWin.cglContext );
-            CGReleaseAllDisplays();
-            _glfwWin.cglContext = NULL;
-        }
-
-        if( _glfwWin.cglPixelFormat != NULL )
-        {
-            CGLDestroyPixelFormat( _glfwWin.cglPixelFormat );
-            _glfwWin.cglPixelFormat = NULL;
-        }
-    }
-    else
-    {
-        if( _glfwWin.aglContext != NULL )
-        {
-            aglSetCurrentContext( NULL );
-            aglSetDrawable( _glfwWin.aglContext, NULL );
-            aglDestroyContext( _glfwWin.aglContext );
-            _glfwWin.aglContext = NULL;
-        }
-
-        if( _glfwWin.aglPixelFormat != NULL )
-        {
-            aglDestroyPixelFormat( _glfwWin.aglPixelFormat );
-            _glfwWin.aglPixelFormat = NULL;
-        }
-    }
-
-    if( _glfwWin.window != NULL )
-    {
-        ReleaseWindow( _glfwWin.window );
-        _glfwWin.window = NULL;
-    }
-}
-
-//========================================================================
-// Set the window title
-//========================================================================
-
-void _glfwPlatformSetWindowTitle( const char *title )
-{
-    CFStringRef windowTitle;
-
-    if( !_glfwWin.fullscreen )
-    {
-        windowTitle = CFStringCreateWithCString( kCFAllocatorDefault,
-                                                 title,
-                                                 kCFStringEncodingISOLatin1 );
-
-        (void)SetWindowTitleWithCFString( _glfwWin.window, windowTitle );
-
-        CFRelease( windowTitle );
-    }
-}
-
-//========================================================================
-// Set the window size
-//========================================================================
-
-void _glfwPlatformSetWindowSize( int width, int height )
-{
-    if( !_glfwWin.fullscreen )
-    {
-        SizeWindow( _glfwWin.window, width, height, TRUE );
-    }
-}
-
-//========================================================================
-// Set the window position
-//========================================================================
-
-void _glfwPlatformSetWindowPos( int x, int y )
-{
-    if( !_glfwWin.fullscreen )
-    {
-        MoveWindow( _glfwWin.window, x, y, FALSE );
-    }
-}
-
-//========================================================================
-// Window iconification
-//========================================================================
-
-void _glfwPlatformIconifyWindow( void )
-{
-    if( !_glfwWin.fullscreen )
-    {
-        (void)CollapseWindow( _glfwWin.window, TRUE );
-    }
-}
-
-//========================================================================
-// Window un-iconification
-//========================================================================
-
-void _glfwPlatformRestoreWindow( void )
-{
-    if( !_glfwWin.fullscreen )
-    {
-        (void)CollapseWindow( _glfwWin.window, FALSE );
-    }
-}
-
-//========================================================================
-// Swap buffers (double-buffering) and poll any new events
-//========================================================================
-
-void _glfwPlatformSwapBuffers( void )
-{
-    if( _glfwWin.fullscreen )
-    {
-        CGLFlushDrawable( _glfwWin.cglContext );
-    }
-    else
-    {
-        aglSwapBuffers( _glfwWin.aglContext );
-    }
-}
-
-//========================================================================
-// Set double buffering swap interval
-//========================================================================
-
-void _glfwPlatformSwapInterval( int interval )
-{
-    GLint AGLparameter = interval;
-
-    // CGL doesn't seem to like intervals other than 0 (vsync off) or 1 (vsync on)
-    long CGLparameter = ( interval ? 1 : 0 );
-
-    if( _glfwWin.fullscreen )
-    {
-        // Don't care if we fail here..
-        (void)CGLSetParameter( _glfwWin.cglContext,
-                               kCGLCPSwapInterval,
-                               (GLint*) &CGLparameter );
-    }
-    else
-    {
-        // ..or here
-        (void)aglSetInteger( _glfwWin.aglContext,
-                             AGL_SWAP_INTERVAL,
-                             &AGLparameter );
-    }
-}
-
-//========================================================================
-// Read back framebuffer parameters from the context
-//========================================================================
-
-#define _getAGLAttribute( aglAttributeName, variableName ) \
-{ \
-    GLint aglValue; \
-    (void)aglDescribePixelFormat( _glfwWin.aglPixelFormat, aglAttributeName, &aglValue ); \
-    variableName = aglValue; \
-}
-
-#define _getCGLAttribute( cglAttributeName, variableName ) \
-{ \
-    GLint cglValue; \
-    (void)CGLDescribePixelFormat( _glfwWin.cglPixelFormat, 0, cglAttributeName, &cglValue ); \
-    variableName = cglValue; \
-}
-
-void _glfwPlatformRefreshWindowParams( void )
-{
-    GLint rgbColorDepth;
-    GLint rgbaAccumDepth = 0;
-    GLint rgbChannelDepth = 0;
-
-    if( _glfwWin.fullscreen )
-    {
-        _getCGLAttribute( kCGLPFAAccelerated, _glfwWin.accelerated );
-        _getCGLAttribute( kCGLPFAAlphaSize,   _glfwWin.alphaBits );
-        _getCGLAttribute( kCGLPFADepthSize,   _glfwWin.depthBits );
-        _getCGLAttribute( kCGLPFAStencilSize, _glfwWin.stencilBits );
-        _getCGLAttribute( kCGLPFAAuxBuffers,  _glfwWin.auxBuffers );
-        _getCGLAttribute( kCGLPFAStereo,      _glfwWin.stereo );
-        _getCGLAttribute( kCGLPFASamples,     _glfwWin.samples );
-
-        // 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,
-                                      0,
-                                      kCGLPFAColorSize,
-                                      &rgbColorDepth );
-
-        if( rgbColorDepth == 24 || rgbColorDepth == 32 )
-        {
-            rgbChannelDepth = 8;
-        }
-        if( rgbColorDepth == 16 )
-        {
-            rgbChannelDepth = 5;
-        }
-
-        _glfwWin.redBits   = rgbChannelDepth;
-        _glfwWin.greenBits = rgbChannelDepth;
-        _glfwWin.blueBits  = rgbChannelDepth;
-
-        // Get pixel depth of accumulator - I haven't got the slightest idea
-        // how this number conforms to any other channel depth than 8 bits,
-        // so this might end up giving completely knackered results...
-        _getCGLAttribute( kCGLPFAColorSize, rgbaAccumDepth );
-        if( rgbaAccumDepth == 32 )
-        {
-            rgbaAccumDepth = 8;
-        }
-
-        _glfwWin.accumRedBits   = rgbaAccumDepth;
-        _glfwWin.accumGreenBits = rgbaAccumDepth;
-        _glfwWin.accumBlueBits  = rgbaAccumDepth;
-        _glfwWin.accumAlphaBits = rgbaAccumDepth;
-    }
-    else
-    {
-        _getAGLAttribute( AGL_ACCELERATED,      _glfwWin.accelerated );
-        _getAGLAttribute( AGL_RED_SIZE,         _glfwWin.redBits );
-        _getAGLAttribute( AGL_GREEN_SIZE,       _glfwWin.greenBits );
-        _getAGLAttribute( AGL_BLUE_SIZE,        _glfwWin.blueBits );
-        _getAGLAttribute( AGL_ALPHA_SIZE,       _glfwWin.alphaBits );
-        _getAGLAttribute( AGL_DEPTH_SIZE,       _glfwWin.depthBits );
-        _getAGLAttribute( AGL_STENCIL_SIZE,     _glfwWin.stencilBits );
-        _getAGLAttribute( AGL_ACCUM_RED_SIZE,   _glfwWin.accumRedBits );
-        _getAGLAttribute( AGL_ACCUM_GREEN_SIZE, _glfwWin.accumGreenBits );
-        _getAGLAttribute( AGL_ACCUM_BLUE_SIZE,  _glfwWin.accumBlueBits );
-        _getAGLAttribute( AGL_ACCUM_ALPHA_SIZE, _glfwWin.accumAlphaBits );
-        _getAGLAttribute( AGL_AUX_BUFFERS,      _glfwWin.auxBuffers );
-        _getAGLAttribute( AGL_STEREO,           _glfwWin.stereo );
-        _getAGLAttribute( AGL_SAMPLES_ARB,      _glfwWin.samples );
-    }
-}
-
-//========================================================================
-// Poll for new window and input events
-//========================================================================
-
-void _glfwPlatformPollEvents( void )
-{
-    EventRef event;
-    EventTargetRef eventDispatcher = GetEventDispatcherTarget();
-
-    while ( ReceiveNextEvent( 0, NULL, 0.0, TRUE, &event ) == noErr )
-    {
-        SendEventToEventTarget( event, eventDispatcher );
-        ReleaseEvent( event );
-    }
-}
-
-//========================================================================
-// Wait for new window and input events
-//========================================================================
-
-void _glfwPlatformWaitEvents( void )
-{
-    EventRef event;
-
-    // Wait for new events
-    ReceiveNextEvent( 0, NULL, kEventDurationForever, FALSE, &event );
-
-    // Process the new events
-    _glfwPlatformPollEvents();
-}
-
-//========================================================================
-// Hide mouse cursor (lock it)
-//========================================================================
-
-void _glfwPlatformHideMouseCursor( void )
-{
-    CGDisplayHideCursor( kCGDirectMainDisplay );
-    CGAssociateMouseAndMouseCursorPosition( false );
-}
-
-//========================================================================
-// Show mouse cursor (unlock it)
-//========================================================================
-
-void _glfwPlatformShowMouseCursor( void )
-{
-    CGDisplayShowCursor( kCGDirectMainDisplay );
-    CGAssociateMouseAndMouseCursorPosition( true );
-}
-
-//========================================================================
-// Set physical mouse cursor position
-//========================================================================
-
-void _glfwPlatformSetMouseCursorPos( int x, int y )
-{
-    Rect content;
-
-    if( _glfwWin.fullscreen )
-    {
-        CGDisplayMoveCursorToPoint( kCGDirectMainDisplay,
-                                    CGPointMake( x, y ) );
-    }
-    else
-    {
-        GetWindowBounds(_glfwWin.window, kWindowContentRgn, &content);
-
-        _glfwInput.MousePosX = x + content.left;
-        _glfwInput.MousePosY = y + content.top;
-
-        CGDisplayMoveCursorToPoint( kCGDirectMainDisplay,
-                                    CGPointMake( _glfwInput.MousePosX,
-                                                _glfwInput.MousePosY ) );
-    }
-}
-

+ 0 - 334
ThirdParty/GLFW/lib/carbon/platform.h

@@ -1,334 +0,0 @@
-//========================================================================
-// GLFW - An OpenGL framework
-// Platform:    Carbon/AGL/CGL
-// API Version: 2.7
-// WWW:         http://www.glfw.org/
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2003      Keith Bauer
-// Copyright (c) 2003-2010 Camilla Berglund <[email protected]>
-// Copyright (c) 2006-2007 Robin Leffmann
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#ifndef _platform_h_
-#define _platform_h_
-
-
-// This is the Mac OS X version of GLFW
-#define _GLFW_MAC_OS_X
-
-#include <Carbon/Carbon.h>
-#include <OpenGL/OpenGL.h>
-#include <AGL/agl.h>
-#include <sched.h>
-#include <pthread.h>
-#include <sys/sysctl.h>
-
-#include "../../include/GL/glfw.h"
-
-#if MACOSX_DEPLOYMENT_TARGET < MAC_OS_X_VERSION_10_3
-
-#ifndef kCGLNoError
-#define kCGLNoError 0
-#endif
-
-#endif
-
-
-#ifndef GL_VERSION_3_0
-
-typedef const GLubyte * (APIENTRY *PFNGLGETSTRINGIPROC) (GLenum, GLuint);
-
-#endif /*GL_VERSION_3_0*/
-
-
-//========================================================================
-// Defines
-//========================================================================
-
-#define _GLFW_MAX_PATH_LENGTH (8192)
-
-#define MAC_KEY_ENTER       0x24
-#define MAC_KEY_RETURN      0x34
-#define MAC_KEY_ESC         0x35
-#define MAC_KEY_F1          0x7A
-#define MAC_KEY_F2          0x78
-#define MAC_KEY_F3          0x63
-#define MAC_KEY_F4          0x76
-#define MAC_KEY_F5          0x60
-#define MAC_KEY_F6          0x61
-#define MAC_KEY_F7          0x62
-#define MAC_KEY_F8          0x64
-#define MAC_KEY_F9          0x65
-#define MAC_KEY_F10         0x6D
-#define MAC_KEY_F11         0x67
-#define MAC_KEY_F12         0x6F
-#define MAC_KEY_F13         0x69
-#define MAC_KEY_F14         0x6B
-#define MAC_KEY_F15         0x71
-#define MAC_KEY_UP          0x7E
-#define MAC_KEY_DOWN        0x7D
-#define MAC_KEY_LEFT        0x7B
-#define MAC_KEY_RIGHT       0x7C
-#define MAC_KEY_TAB         0x30
-#define MAC_KEY_BACKSPACE   0x33
-#define MAC_KEY_HELP        0x72
-#define MAC_KEY_DEL         0x75
-#define MAC_KEY_PAGEUP      0x74
-#define MAC_KEY_PAGEDOWN    0x79
-#define MAC_KEY_HOME        0x73
-#define MAC_KEY_END         0x77
-#define MAC_KEY_KP_0        0x52
-#define MAC_KEY_KP_1        0x53
-#define MAC_KEY_KP_2        0x54
-#define MAC_KEY_KP_3        0x55
-#define MAC_KEY_KP_4        0x56
-#define MAC_KEY_KP_5        0x57
-#define MAC_KEY_KP_6        0x58
-#define MAC_KEY_KP_7        0x59
-#define MAC_KEY_KP_8        0x5B
-#define MAC_KEY_KP_9        0x5C
-#define MAC_KEY_KP_DIVIDE   0x4B
-#define MAC_KEY_KP_MULTIPLY 0x43
-#define MAC_KEY_KP_SUBTRACT 0x4E
-#define MAC_KEY_KP_ADD      0x45
-#define MAC_KEY_KP_DECIMAL  0x41
-#define MAC_KEY_KP_EQUAL    0x51
-#define MAC_KEY_KP_ENTER    0x4C
-#define MAC_KEY_NUMLOCK     0x47
-
-
-//========================================================================
-// GLFW platform specific types
-//========================================================================
-
-//------------------------------------------------------------------------
-// Pointer length integer
-//------------------------------------------------------------------------
-typedef intptr_t GLFWintptr;
-
-
-GLFWGLOBAL CFDictionaryRef _glfwDesktopVideoMode;
-
-//------------------------------------------------------------------------
-// Window structure
-//------------------------------------------------------------------------
-typedef struct _GLFWwin_struct _GLFWwin;
-
-struct _GLFWwin_struct {
-
-// ========= PLATFORM INDEPENDENT MANDATORY PART =========================
-
-    // User callback functions
-    GLFWwindowsizefun    windowSizeCallback;
-    GLFWwindowclosefun   windowCloseCallback;
-    GLFWwindowrefreshfun windowRefreshCallback;
-    GLFWmousebuttonfun   mouseButtonCallback;
-    GLFWmouseposfun      mousePosCallback;
-    GLFWmousewheelfun    mouseWheelCallback;
-    GLFWkeyfun           keyCallback;
-    GLFWcharfun          charCallback;
-
-    // User selected window settings
-    int       fullscreen;      // Fullscreen flag
-    int       mouseLock;       // Mouse-lock flag
-    int       autoPollEvents;  // Auto polling flag
-    int       sysKeysDisabled; // System keys disabled flag
-    int       windowNoResize;  // Resize- and maximize gadgets disabled flag
-    int       refreshRate;     // Vertical monitor refresh rate
-
-    // Window status & parameters
-    int       opened;          // Flag telling if window is opened or not
-    int       active;          // Application active flag
-    int       iconified;       // Window iconified flag
-    int       width, height;   // Window width and heigth
-    int       accelerated;     // GL_TRUE if window is HW accelerated
-
-    // Framebuffer attributes
-    int       redBits;
-    int       greenBits;
-    int       blueBits;
-    int       alphaBits;
-    int       depthBits;
-    int       stencilBits;
-    int       accumRedBits;
-    int       accumGreenBits;
-    int       accumBlueBits;
-    int       accumAlphaBits;
-    int       auxBuffers;
-    int       stereo;
-    int       samples;
-
-    // OpenGL extensions and context attributes
-    int       has_GL_SGIS_generate_mipmap;
-    int       has_GL_ARB_texture_non_power_of_two;
-    int       glMajor, glMinor, glRevision;
-    int       glForward, glDebug, glProfile;
-
-    PFNGLGETSTRINGIPROC GetStringi;
-
-// ========= PLATFORM SPECIFIC PART ======================================
-
-    WindowRef          window;
-
-    AGLContext         aglContext;
-    AGLPixelFormat     aglPixelFormat;
-
-    CGLContextObj      cglContext;
-    CGLPixelFormatObj  cglPixelFormat;
-
-    EventHandlerUPP    windowUPP;
-    EventHandlerUPP    mouseUPP;
-    EventHandlerUPP    commandUPP;
-    EventHandlerUPP    keyboardUPP;
-};
-
-GLFWGLOBAL _GLFWwin _glfwWin;
-
-
-//------------------------------------------------------------------------
-// User input status (some of this should go in _GLFWwin)
-//------------------------------------------------------------------------
-GLFWGLOBAL struct {
-
-// ========= PLATFORM INDEPENDENT MANDATORY PART =========================
-
-    // Mouse status
-    int      MousePosX, MousePosY;
-    int      WheelPos;
-    char     MouseButton[ GLFW_MOUSE_BUTTON_LAST + 1 ];
-
-    // Keyboard status
-    char     Key[ GLFW_KEY_LAST + 1 ];
-    int      LastChar;
-
-    // User selected settings
-    int      StickyKeys;
-    int      StickyMouseButtons;
-    int      KeyRepeat;
-
-// ========= PLATFORM SPECIFIC PART ======================================
-
-    UInt32 Modifiers;
-
-} _glfwInput;
-
-
-
-//------------------------------------------------------------------------
-// Thread information
-//------------------------------------------------------------------------
-typedef struct _GLFWthread_struct _GLFWthread;
-
-// Thread record (one for each thread)
-struct _GLFWthread_struct {
-
-    // Pointer to previous and next threads in linked list
-    _GLFWthread   *Previous, *Next;
-
-    // GLFW user side thread information
-    GLFWthread    ID;
-    GLFWthreadfun Function;
-
-    // System side thread information
-    pthread_t     PosixID;
-};
-
-// General thread information
-GLFWGLOBAL struct {
-
-    // Critical section lock
-    pthread_mutex_t  CriticalSection;
-
-    // Next thread ID to use (increments for every created thread)
-    GLFWthread       NextID;
-
-    // First thread in linked list (always the main thread)
-    _GLFWthread      First;
-
-} _glfwThrd;
-
-
-//------------------------------------------------------------------------
-// Library global data
-//------------------------------------------------------------------------
-GLFWGLOBAL struct {
-
-// ========= PLATFORM INDEPENDENT MANDATORY PART =========================
-
-    // Window opening hints
-    _GLFWhints      hints;
-
-// ========= PLATFORM SPECIFIC PART ======================================
-
-    // Timer data
-    struct {
-	double       t0;
-    } Timer;
-
-    struct {
-	    // Bundle for dynamically-loading extension function pointers
-        CFBundleRef OpenGLFramework;
-    } Libs;
-
-    int Unbundled;
-
-} _glfwLibrary;
-
-
-
-//========================================================================
-// Macros for encapsulating critical code sections (i.e. making parts
-// of GLFW thread safe)
-//========================================================================
-
-// Define so we can use the same thread code as X11
-#define _glfw_numprocessors(n) { \
-    int mib[2], ncpu; \
-    size_t len = 1; \
-    mib[0] = CTL_HW; \
-    mib[1] = HW_NCPU; \
-    n      = 1; \
-    if( sysctl( mib, 2, &ncpu, &len, NULL, 0 ) != -1 ) \
-    { \
-        if( len > 0 ) \
-        { \
-            n = ncpu; \
-        } \
-    } \
-}
-
-// Thread list management
-#define ENTER_THREAD_CRITICAL_SECTION \
-pthread_mutex_lock( &_glfwThrd.CriticalSection );
-#define LEAVE_THREAD_CRITICAL_SECTION \
-pthread_mutex_unlock( &_glfwThrd.CriticalSection );
-
-
-//========================================================================
-// Prototypes for platform specific internal functions
-//========================================================================
-
-void  _glfwChangeToResourcesDirectory( void );
-
-#endif // _platform_h_

+ 22 - 0
ThirdParty/GLFW/lib/cocoa/cocoa_window.m

@@ -529,8 +529,19 @@ int  _glfwPlatformOpenWindow( int width, int height,
 
     if( wndconfig->mode == GLFW_FULLSCREEN )
     {
+        // Urho3D: fade to black during switch
+        CGDisplayFadeReservationToken fade = kCGDisplayFadeReservationInvalidToken;
+        if (CGAcquireDisplayFadeReservation(3.0, &fade) == kCGErrorSuccess)
+            CGDisplayFade(fade, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, TRUE);
+
         CGCaptureAllDisplays();
         CGDisplaySwitchToMode( CGMainDisplayID(), fullscreenMode );
+
+        if (fade != kCGDisplayFadeReservationInvalidToken)
+        {
+            CGDisplayFade(fade, 0.3, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, FALSE);
+            CGReleaseDisplayFadeReservation(fade);
+        }
     }
 
     unsigned int attribute_count = 0;
@@ -636,10 +647,21 @@ void _glfwPlatformCloseWindow( void )
 
     if( _glfwWin.fullscreen )
     {
+        // Urho3D: fade to black during switch
+        CGDisplayFadeReservationToken fade = kCGDisplayFadeReservationInvalidToken;
+        if (CGAcquireDisplayFadeReservation(3.0, &fade) == kCGErrorSuccess)
+            CGDisplayFade(fade, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, TRUE);  
+    
         [[_glfwWin.window contentView] exitFullScreenModeWithOptions:nil];
         CGDisplaySwitchToMode( CGMainDisplayID(),
                                (CFDictionaryRef)_glfwLibrary.DesktopMode );
         CGReleaseAllDisplays();
+
+        if (fade != kCGDisplayFadeReservationInvalidToken)
+        {
+            CGDisplayFade(fade, 0.3, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, FALSE);
+            CGReleaseDisplayFadeReservation(fade);
+        }
     }
 
     [_glfwWin.pixelFormat release];