Shallow formatting pass (no code changes).

This commit is contained in:
Camilla Berglund 2010-09-08 01:57:24 +02:00
Родитель bb2c33e97e
Коммит 105e927b84
8 изменённых файлов: 22 добавлений и 250 удалений

Просмотреть файл

@ -44,9 +44,7 @@ static void enableMouseCursor( void )
int centerPosX, centerPosY; int centerPosX, centerPosY;
if( !_glfwWin.opened || !_glfwWin.mouseLock ) if( !_glfwWin.opened || !_glfwWin.mouseLock )
{
return; return;
}
// Show mouse cursor // Show mouse cursor
_glfwPlatformShowMouseCursor(); _glfwPlatformShowMouseCursor();
@ -79,9 +77,7 @@ static void enableMouseCursor( void )
static void disableMouseCursor( void ) static void disableMouseCursor( void )
{ {
if( !_glfwWin.opened || _glfwWin.mouseLock ) if( !_glfwWin.opened || _glfwWin.mouseLock )
{
return; return;
}
// Hide mouse cursor // Hide mouse cursor
_glfwPlatformHideMouseCursor(); _glfwPlatformHideMouseCursor();
@ -118,9 +114,7 @@ static void disableStickyKeys( void )
for( i = 0; i <= GLFW_KEY_LAST; i++ ) for( i = 0; i <= GLFW_KEY_LAST; i++ )
{ {
if( _glfwInput.Key[ i ] == 2 ) if( _glfwInput.Key[ i ] == 2 )
{
_glfwInput.Key[ i ] = 0; _glfwInput.Key[ i ] = 0;
}
} }
} }
@ -148,9 +142,7 @@ static void disableStickyMouseButtons( void )
for( i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++ ) for( i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++ )
{ {
if( _glfwInput.MouseButton[ i ] == 2 ) if( _glfwInput.MouseButton[ i ] == 2 )
{
_glfwInput.MouseButton[ i ] = 0; _glfwInput.MouseButton[ i ] = 0;
}
} }
} }
@ -162,9 +154,7 @@ static void disableStickyMouseButtons( void )
static void enableSystemKeys( void ) static void enableSystemKeys( void )
{ {
if( !_glfwWin.sysKeysDisabled ) if( !_glfwWin.sysKeysDisabled )
{
return; return;
}
_glfwPlatformEnableSystemKeys(); _glfwPlatformEnableSystemKeys();
@ -179,9 +169,7 @@ static void enableSystemKeys( void )
static void disableSystemKeys( void ) static void disableSystemKeys( void )
{ {
if( _glfwWin.sysKeysDisabled ) if( _glfwWin.sysKeysDisabled )
{
return; return;
}
_glfwPlatformDisableSystemKeys(); _glfwPlatformDisableSystemKeys();
@ -228,7 +216,6 @@ static void disableAutoPollEvents( void )
} }
//************************************************************************ //************************************************************************
//**** GLFW user functions **** //**** GLFW user functions ****
//************************************************************************ //************************************************************************
@ -239,11 +226,8 @@ static void disableAutoPollEvents( void )
GLFWAPI void glfwEnable( int token ) GLFWAPI void glfwEnable( int token )
{ {
// Is GLFW initialized?
if( !_glfwInitialized ) if( !_glfwInitialized )
{
return; return;
}
switch( token ) switch( token )
{ {
@ -277,11 +261,8 @@ GLFWAPI void glfwEnable( int token )
GLFWAPI void glfwDisable( int token ) GLFWAPI void glfwDisable( int token )
{ {
// Is GLFW initialized?
if( !_glfwInitialized ) if( !_glfwInitialized )
{
return; return;
}
switch( token ) switch( token )
{ {

Просмотреть файл

@ -41,13 +41,11 @@
GLFWAPI int glfwGetVideoModes( GLFWvidmode *list, int maxcount ) GLFWAPI int glfwGetVideoModes( GLFWvidmode *list, int maxcount )
{ {
int count, i, swap, res1, res2, depth1, depth2; int count, i, swap, res1, res2, depth1, depth2;
GLFWvidmode vm; GLFWvidmode vm;
if( !_glfwInitialized || maxcount <= 0 || list == (GLFWvidmode*) 0 ) if( !_glfwInitialized || maxcount <= 0 || list == (GLFWvidmode*) 0 )
{
return 0; return 0;
}
// Get list of video modes // Get list of video modes
count = _glfwPlatformGetVideoModes( list, maxcount ); count = _glfwPlatformGetVideoModes( list, maxcount );
@ -63,7 +61,8 @@ GLFWAPI int glfwGetVideoModes( GLFWvidmode *list, int maxcount )
res2 = list[i+1].Width*list[i+1].Height; res2 = list[i+1].Width*list[i+1].Height;
depth2 = list[i+1].RedBits+list[i+1].GreenBits+ depth2 = list[i+1].RedBits+list[i+1].GreenBits+
list[i+1].BlueBits; list[i+1].BlueBits;
if( (depth2<depth1) || ((depth2==depth1) && (res2<res1)) )
if( (depth2 < depth1) || ((depth2 == depth1) && (res2 < res1)) )
{ {
vm = list[i]; vm = list[i];
list[i] = list[i+1]; list[i] = list[i+1];
@ -85,9 +84,7 @@ GLFWAPI int glfwGetVideoModes( GLFWvidmode *list, int maxcount )
GLFWAPI void glfwGetDesktopMode( GLFWvidmode *mode ) GLFWAPI void glfwGetDesktopMode( GLFWvidmode *mode )
{ {
if( !_glfwInitialized || mode == (GLFWvidmode*) 0 ) if( !_glfwInitialized || mode == (GLFWvidmode*) 0 )
{
return; return;
}
_glfwPlatformGetDesktopMode( mode ); _glfwPlatformGetDesktopMode( mode );
} }

Просмотреть файл

@ -52,30 +52,24 @@ void _glfwParseGLVersion( int *major, int *minor, int *rev )
// Get OpenGL version string // Get OpenGL version string
version = glGetString( GL_VERSION ); version = glGetString( GL_VERSION );
if( !version ) if( !version )
{
return; return;
}
// Parse string // Parse string
ptr = version; ptr = version;
for( _major = 0; *ptr >= '0' && *ptr <= '9'; ptr ++ ) for( _major = 0; *ptr >= '0' && *ptr <= '9'; ptr ++ )
{
_major = 10*_major + (*ptr - '0'); _major = 10*_major + (*ptr - '0');
}
if( *ptr == '.' ) if( *ptr == '.' )
{ {
ptr ++; ptr ++;
for( _minor = 0; *ptr >= '0' && *ptr <= '9'; ptr ++ ) for( _minor = 0; *ptr >= '0' && *ptr <= '9'; ptr ++ )
{
_minor = 10*_minor + (*ptr - '0'); _minor = 10*_minor + (*ptr - '0');
}
if( *ptr == '.' ) if( *ptr == '.' )
{ {
ptr ++; ptr ++;
for( _rev = 0; *ptr >= '0' && *ptr <= '9'; ptr ++ ) for( _rev = 0; *ptr >= '0' && *ptr <= '9'; ptr ++ )
{
_rev = 10*_rev + (*ptr - '0'); _rev = 10*_rev + (*ptr - '0');
}
} }
} }
@ -103,17 +97,15 @@ int _glfwStringInExtensionString( const char *string,
{ {
where = (GLubyte *) strstr( (const char *) start, string ); where = (GLubyte *) strstr( (const char *) start, string );
if( !where ) if( !where )
{
return GL_FALSE; return GL_FALSE;
}
terminator = where + strlen( string ); terminator = where + strlen( string );
if( where == start || *(where - 1) == ' ' ) if( where == start || *(where - 1) == ' ' )
{ {
if( *terminator == ' ' || *terminator == '\0' ) if( *terminator == ' ' || *terminator == '\0' )
{
break; break;
}
} }
start = terminator; start = terminator;
} }
@ -137,18 +129,13 @@ GLFWAPI int glfwExtensionSupported( const char *extension )
GLint count; GLint count;
int i; int i;
// Is GLFW initialized?
if( !_glfwInitialized || !_glfwWin.opened ) if( !_glfwInitialized || !_glfwWin.opened )
{
return GL_FALSE; return GL_FALSE;
}
// Extension names should not have spaces // Extension names should not have spaces
where = (GLubyte *) strchr( extension, ' ' ); where = (GLubyte *) strchr( extension, ' ' );
if( where || *extension == '\0' ) if( where || *extension == '\0' )
{
return GL_FALSE; return GL_FALSE;
}
if( _glfwWin.glMajor < 3 ) if( _glfwWin.glMajor < 3 )
{ {
@ -158,9 +145,7 @@ GLFWAPI int glfwExtensionSupported( const char *extension )
if( extensions != NULL ) if( extensions != NULL )
{ {
if( _glfwStringInExtensionString( extension, extensions ) ) if( _glfwStringInExtensionString( extension, extensions ) )
{
return GL_TRUE; return GL_TRUE;
}
} }
} }
else else
@ -181,9 +166,7 @@ GLFWAPI int glfwExtensionSupported( const char *extension )
// Additional platform specific extension checking (e.g. WGL) // Additional platform specific extension checking (e.g. WGL)
if( _glfwPlatformExtensionSupported( extension ) ) if( _glfwPlatformExtensionSupported( extension ) )
{
return GL_TRUE; return GL_TRUE;
}
return GL_FALSE; return GL_FALSE;
} }
@ -196,11 +179,8 @@ GLFWAPI int glfwExtensionSupported( const char *extension )
GLFWAPI void * glfwGetProcAddress( const char *procname ) GLFWAPI void * glfwGetProcAddress( const char *procname )
{ {
// Is GLFW initialized?
if( !_glfwInitialized || !_glfwWin.opened ) if( !_glfwInitialized || !_glfwWin.opened )
{
return NULL; return NULL;
}
return _glfwPlatformGetProcAddress( procname ); return _glfwPlatformGetProcAddress( procname );
} }
@ -212,23 +192,16 @@ GLFWAPI void * glfwGetProcAddress( const char *procname )
GLFWAPI void glfwGetGLVersion( int *major, int *minor, int *rev ) GLFWAPI void glfwGetGLVersion( int *major, int *minor, int *rev )
{ {
// Is GLFW initialized?
if( !_glfwInitialized || !_glfwWin.opened ) if( !_glfwInitialized || !_glfwWin.opened )
{
return; return;
}
if( major != NULL ) if( major != NULL )
{
*major = _glfwWin.glMajor; *major = _glfwWin.glMajor;
}
if( minor != NULL ) if( minor != NULL )
{
*minor = _glfwWin.glMinor; *minor = _glfwWin.glMinor;
}
if( rev != NULL ) if( rev != NULL )
{
*rev = _glfwWin.glRevision; *rev = _glfwWin.glRevision;
}
} }

Просмотреть файл

@ -37,16 +37,13 @@
//************************************************************************ //************************************************************************
//======================================================================== //========================================================================
// glfwInit() - Initialize various GLFW state // Initialize various GLFW state
//======================================================================== //========================================================================
GLFWAPI int glfwInit( void ) GLFWAPI int glfwInit( void )
{ {
// Is GLFW already initialized?
if( _glfwInitialized ) if( _glfwInitialized )
{
return GL_TRUE; return GL_TRUE;
}
memset( &_glfwLibrary, 0, sizeof( _glfwLibrary ) ); memset( &_glfwLibrary, 0, sizeof( _glfwLibrary ) );
memset( &_glfwWin, 0, sizeof( _glfwWin ) ); memset( &_glfwWin, 0, sizeof( _glfwWin ) );
@ -62,9 +59,7 @@ GLFWAPI int glfwInit( void )
// Platform specific initialization // Platform specific initialization
if( !_glfwPlatformInit() ) if( !_glfwPlatformInit() )
{
return GL_FALSE; return GL_FALSE;
}
// Form now on, GLFW state is valid // Form now on, GLFW state is valid
_glfwInitialized = GL_TRUE; _glfwInitialized = GL_TRUE;
@ -73,24 +68,18 @@ GLFWAPI int glfwInit( void )
} }
//======================================================================== //========================================================================
// Close window and shut down library // Close window and shut down library
//======================================================================== //========================================================================
GLFWAPI void glfwTerminate( void ) GLFWAPI void glfwTerminate( void )
{ {
// Is GLFW initialized?
if( !_glfwInitialized ) if( !_glfwInitialized )
{
return; return;
}
// Platform specific termination // Platform specific termination
if( !_glfwPlatformTerminate() ) if( !_glfwPlatformTerminate() )
{
return; return;
}
// GLFW is no longer initialized // GLFW is no longer initialized
_glfwInitialized = GL_FALSE; _glfwInitialized = GL_FALSE;
@ -98,13 +87,18 @@ GLFWAPI void glfwTerminate( void )
//======================================================================== //========================================================================
// glfwGetVersion() - Get GLFW version // Get GLFW version
//======================================================================== //========================================================================
GLFWAPI void glfwGetVersion( int *major, int *minor, int *rev ) GLFWAPI void glfwGetVersion( int *major, int *minor, int *rev )
{ {
if( major != NULL ) *major = GLFW_VERSION_MAJOR; if( major != NULL )
if( minor != NULL ) *minor = GLFW_VERSION_MINOR; *major = GLFW_VERSION_MAJOR;
if( rev != NULL ) *rev = GLFW_VERSION_REVISION;
if( minor != NULL )
*minor = GLFW_VERSION_MINOR;
if( rev != NULL )
*rev = GLFW_VERSION_REVISION;
} }

Просмотреть файл

@ -37,17 +37,12 @@
GLFWAPI int glfwGetKey( int key ) GLFWAPI int glfwGetKey( int key )
{ {
// Is GLFW initialized?
if( !_glfwInitialized || !_glfwWin.opened ) if( !_glfwInitialized || !_glfwWin.opened )
{
return GLFW_RELEASE; return GLFW_RELEASE;
}
// Is it a valid key? // Is it a valid key?
if( key < 0 || key > GLFW_KEY_LAST ) if( key < 0 || key > GLFW_KEY_LAST )
{
return GLFW_RELEASE; return GLFW_RELEASE;
}
if( _glfwInput.Key[ key ] == GLFW_STICK ) if( _glfwInput.Key[ key ] == GLFW_STICK )
{ {
@ -66,17 +61,12 @@ GLFWAPI int glfwGetKey( int key )
GLFWAPI int glfwGetMouseButton( int button ) GLFWAPI int glfwGetMouseButton( int button )
{ {
// Is GLFW initialized?
if( !_glfwInitialized || !_glfwWin.opened ) if( !_glfwInitialized || !_glfwWin.opened )
{
return GLFW_RELEASE; return GLFW_RELEASE;
}
// Is it a valid mouse button? // Is it a valid mouse button?
if( button < 0 || button > GLFW_MOUSE_BUTTON_LAST ) if( button < 0 || button > GLFW_MOUSE_BUTTON_LAST )
{
return GLFW_RELEASE; return GLFW_RELEASE;
}
if( _glfwInput.MouseButton[ button ] == GLFW_STICK ) if( _glfwInput.MouseButton[ button ] == GLFW_STICK )
{ {
@ -95,21 +85,15 @@ GLFWAPI int glfwGetMouseButton( int button )
GLFWAPI void glfwGetMousePos( int *xpos, int *ypos ) GLFWAPI void glfwGetMousePos( int *xpos, int *ypos )
{ {
// Is GLFW initialized?
if( !_glfwInitialized || !_glfwWin.opened ) if( !_glfwInitialized || !_glfwWin.opened )
{
return; return;
}
// Return mouse position // Return mouse position
if( xpos != NULL ) if( xpos != NULL )
{
*xpos = _glfwInput.MousePosX; *xpos = _glfwInput.MousePosX;
}
if( ypos != NULL ) if( ypos != NULL )
{
*ypos = _glfwInput.MousePosY; *ypos = _glfwInput.MousePosY;
}
} }
@ -119,17 +103,12 @@ GLFWAPI void glfwGetMousePos( int *xpos, int *ypos )
GLFWAPI void glfwSetMousePos( int xpos, int ypos ) GLFWAPI void glfwSetMousePos( int xpos, int ypos )
{ {
// Is GLFW initialized?
if( !_glfwInitialized || !_glfwWin.opened ) if( !_glfwInitialized || !_glfwWin.opened )
{
return; return;
}
// Don't do anything if the mouse position did not change // Don't do anything if the mouse position did not change
if( xpos == _glfwInput.MousePosX && ypos == _glfwInput.MousePosY ) if( xpos == _glfwInput.MousePosX && ypos == _glfwInput.MousePosY )
{
return; return;
}
// Set GLFW mouse position // Set GLFW mouse position
_glfwInput.MousePosX = xpos; _glfwInput.MousePosX = xpos;
@ -137,9 +116,7 @@ GLFWAPI void glfwSetMousePos( int xpos, int ypos )
// If we have a locked mouse, do not change cursor position // If we have a locked mouse, do not change cursor position
if( _glfwWin.mouseLock ) if( _glfwWin.mouseLock )
{
return; return;
}
// Update physical cursor position // Update physical cursor position
_glfwPlatformSetMouseCursorPos( xpos, ypos ); _glfwPlatformSetMouseCursorPos( xpos, ypos );
@ -152,11 +129,8 @@ GLFWAPI void glfwSetMousePos( int xpos, int ypos )
GLFWAPI int glfwGetMouseWheel( void ) GLFWAPI int glfwGetMouseWheel( void )
{ {
// Is GLFW initialized?
if( !_glfwInitialized || !_glfwWin.opened ) if( !_glfwInitialized || !_glfwWin.opened )
{
return 0; return 0;
}
// Return mouse wheel position // Return mouse wheel position
return _glfwInput.WheelPos; return _glfwInput.WheelPos;
@ -169,11 +143,8 @@ GLFWAPI int glfwGetMouseWheel( void )
GLFWAPI void glfwSetMouseWheel( int pos ) GLFWAPI void glfwSetMouseWheel( int pos )
{ {
// Is GLFW initialized?
if( !_glfwInitialized || !_glfwWin.opened ) if( !_glfwInitialized || !_glfwWin.opened )
{
return; return;
}
// Set mouse wheel position // Set mouse wheel position
_glfwInput.WheelPos = pos; _glfwInput.WheelPos = pos;
@ -186,11 +157,8 @@ GLFWAPI void glfwSetMouseWheel( int pos )
GLFWAPI void glfwSetKeyCallback( GLFWkeyfun cbfun ) GLFWAPI void glfwSetKeyCallback( GLFWkeyfun cbfun )
{ {
// Is GLFW initialized?
if( !_glfwInitialized || !_glfwWin.opened ) if( !_glfwInitialized || !_glfwWin.opened )
{
return; return;
}
// Set callback function // Set callback function
_glfwWin.keyCallback = cbfun; _glfwWin.keyCallback = cbfun;
@ -203,11 +171,8 @@ GLFWAPI void glfwSetKeyCallback( GLFWkeyfun cbfun )
GLFWAPI void glfwSetCharCallback( GLFWcharfun cbfun ) GLFWAPI void glfwSetCharCallback( GLFWcharfun cbfun )
{ {
// Is GLFW initialized?
if( !_glfwInitialized || !_glfwWin.opened ) if( !_glfwInitialized || !_glfwWin.opened )
{
return; return;
}
// Set callback function // Set callback function
_glfwWin.charCallback = cbfun; _glfwWin.charCallback = cbfun;
@ -220,11 +185,8 @@ GLFWAPI void glfwSetCharCallback( GLFWcharfun cbfun )
GLFWAPI void glfwSetMouseButtonCallback( GLFWmousebuttonfun cbfun ) GLFWAPI void glfwSetMouseButtonCallback( GLFWmousebuttonfun cbfun )
{ {
// Is GLFW initialized?
if( !_glfwInitialized || !_glfwWin.opened ) if( !_glfwInitialized || !_glfwWin.opened )
{
return; return;
}
// Set callback function // Set callback function
_glfwWin.mouseButtonCallback = cbfun; _glfwWin.mouseButtonCallback = cbfun;
@ -237,11 +199,8 @@ GLFWAPI void glfwSetMouseButtonCallback( GLFWmousebuttonfun cbfun )
GLFWAPI void glfwSetMousePosCallback( GLFWmouseposfun cbfun ) GLFWAPI void glfwSetMousePosCallback( GLFWmouseposfun cbfun )
{ {
// Is GLFW initialized?
if( !_glfwInitialized || !_glfwWin.opened ) if( !_glfwInitialized || !_glfwWin.opened )
{
return; return;
}
// Set callback function // Set callback function
_glfwWin.mousePosCallback = cbfun; _glfwWin.mousePosCallback = cbfun;
@ -249,9 +208,7 @@ GLFWAPI void glfwSetMousePosCallback( GLFWmouseposfun cbfun )
// Call the callback function to let the application know the current // Call the callback function to let the application know the current
// mouse position // mouse position
if( cbfun ) if( cbfun )
{
cbfun( _glfwInput.MousePosX, _glfwInput.MousePosY ); cbfun( _glfwInput.MousePosX, _glfwInput.MousePosY );
}
} }
@ -261,11 +218,8 @@ GLFWAPI void glfwSetMousePosCallback( GLFWmouseposfun cbfun )
GLFWAPI void glfwSetMouseWheelCallback( GLFWmousewheelfun cbfun ) GLFWAPI void glfwSetMouseWheelCallback( GLFWmousewheelfun cbfun )
{ {
// Is GLFW initialized?
if( !_glfwInitialized || !_glfwWin.opened ) if( !_glfwInitialized || !_glfwWin.opened )
{
return; return;
}
// Set callback function // Set callback function
_glfwWin.mouseWheelCallback = cbfun; _glfwWin.mouseWheelCallback = cbfun;
@ -273,8 +227,6 @@ GLFWAPI void glfwSetMouseWheelCallback( GLFWmousewheelfun cbfun )
// Call the callback function to let the application know the current // Call the callback function to let the application know the current
// mouse wheel position // mouse wheel position
if( cbfun ) if( cbfun )
{
cbfun( _glfwInput.WheelPos ); cbfun( _glfwInput.WheelPos );
}
} }

Просмотреть файл

@ -41,11 +41,8 @@
GLFWAPI int glfwGetJoystickParam( int joy, int param ) GLFWAPI int glfwGetJoystickParam( int joy, int param )
{ {
// Is GLFW initialized?
if( !_glfwInitialized ) if( !_glfwInitialized )
{
return 0; return 0;
}
return _glfwPlatformGetJoystickParam( joy, param ); return _glfwPlatformGetJoystickParam( joy, param );
} }
@ -59,17 +56,12 @@ GLFWAPI int glfwGetJoystickPos( int joy, float *pos, int numaxes )
{ {
int i; int i;
// Is GLFW initialized?
if( !_glfwInitialized ) if( !_glfwInitialized )
{
return 0; return 0;
}
// Clear positions // Clear positions
for( i = 0; i < numaxes; i++ ) for( i = 0; i < numaxes; i++ )
{
pos[ i ] = 0.0f; pos[ i ] = 0.0f;
}
return _glfwPlatformGetJoystickPos( joy, pos, numaxes ); return _glfwPlatformGetJoystickPos( joy, pos, numaxes );
} }
@ -85,17 +77,12 @@ GLFWAPI int glfwGetJoystickButtons( int joy,
{ {
int i; int i;
// Is GLFW initialized?
if( !_glfwInitialized ) if( !_glfwInitialized )
{
return 0; return 0;
}
// Clear button states // Clear button states
for( i = 0; i < numbuttons; i++ ) for( i = 0; i < numbuttons; i++ )
{
buttons[ i ] = GLFW_RELEASE; buttons[ i ] = GLFW_RELEASE;
}
return _glfwPlatformGetJoystickButtons( joy, buttons, numbuttons ); return _glfwPlatformGetJoystickButtons( joy, buttons, numbuttons );
} }

Просмотреть файл

@ -41,11 +41,8 @@
GLFWAPI double glfwGetTime( void ) GLFWAPI double glfwGetTime( void )
{ {
// Is GLFW initialized?
if( !_glfwInitialized ) if( !_glfwInitialized )
{
return 0.0; return 0.0;
}
return _glfwPlatformGetTime(); return _glfwPlatformGetTime();
} }
@ -57,11 +54,8 @@ GLFWAPI double glfwGetTime( void )
GLFWAPI void glfwSetTime( double time ) GLFWAPI void glfwSetTime( double time )
{ {
// Is GLFW initialized?
if( !_glfwInitialized ) if( !_glfwInitialized )
{
return; return;
}
_glfwPlatformSetTime( time ); _glfwPlatformSetTime( time );
} }

Просмотреть файл

@ -33,7 +33,6 @@
#include <limits.h> #include <limits.h>
//************************************************************************ //************************************************************************
//**** GLFW internal functions **** //**** GLFW internal functions ****
//************************************************************************ //************************************************************************
@ -66,18 +65,14 @@ void _glfwInputDeactivation( void )
for( i = 0; i <= GLFW_KEY_LAST; i ++ ) for( i = 0; i <= GLFW_KEY_LAST; i ++ )
{ {
if( _glfwInput.Key[ i ] == GLFW_PRESS ) if( _glfwInput.Key[ i ] == GLFW_PRESS )
{
_glfwInputKey( i, GLFW_RELEASE ); _glfwInputKey( i, GLFW_RELEASE );
}
} }
// Release all mouse buttons // Release all mouse buttons
for( i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i ++ ) for( i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i ++ )
{ {
if( _glfwInput.MouseButton[ i ] == GLFW_PRESS ) if( _glfwInput.MouseButton[ i ] == GLFW_PRESS )
{
_glfwInputMouseClick( i, GLFW_RELEASE ); _glfwInputMouseClick( i, GLFW_RELEASE );
}
} }
} }
@ -92,18 +87,14 @@ void _glfwClearInput( void )
// Release all keyboard keys // Release all keyboard keys
for( i = 0; i <= GLFW_KEY_LAST; i ++ ) for( i = 0; i <= GLFW_KEY_LAST; i ++ )
{
_glfwInput.Key[ i ] = GLFW_RELEASE; _glfwInput.Key[ i ] = GLFW_RELEASE;
}
// Clear last character // Clear last character
_glfwInput.LastChar = 0; _glfwInput.LastChar = 0;
// Release all mouse buttons // Release all mouse buttons
for( i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i ++ ) for( i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i ++ )
{
_glfwInput.MouseButton[ i ] = GLFW_RELEASE; _glfwInput.MouseButton[ i ] = GLFW_RELEASE;
}
// Set mouse position to (0,0) // Set mouse position to (0,0)
_glfwInput.MousePosX = 0; _glfwInput.MousePosX = 0;
@ -130,21 +121,15 @@ void _glfwInputKey( int key, int action )
int keyrepeat = 0; int keyrepeat = 0;
if( key < 0 || key > GLFW_KEY_LAST ) if( key < 0 || key > GLFW_KEY_LAST )
{
return; return;
}
// Are we trying to release an already released key? // Are we trying to release an already released key?
if( action == GLFW_RELEASE && _glfwInput.Key[ key ] != GLFW_PRESS ) if( action == GLFW_RELEASE && _glfwInput.Key[ key ] != GLFW_PRESS )
{
return; return;
}
// Register key action // Register key action
if( action == GLFW_RELEASE && _glfwInput.StickyKeys ) if( action == GLFW_RELEASE && _glfwInput.StickyKeys )
{
_glfwInput.Key[ key ] = GLFW_STICK; _glfwInput.Key[ key ] = GLFW_STICK;
}
else else
{ {
keyrepeat = (_glfwInput.Key[ key ] == GLFW_PRESS) && keyrepeat = (_glfwInput.Key[ key ] == GLFW_PRESS) &&
@ -154,9 +139,7 @@ void _glfwInputKey( int key, int action )
// Call user callback function // Call user callback function
if( _glfwWin.keyCallback && (_glfwInput.KeyRepeat || !keyrepeat) ) if( _glfwWin.keyCallback && (_glfwInput.KeyRepeat || !keyrepeat) )
{
_glfwWin.keyCallback( key, action ); _glfwWin.keyCallback( key, action );
}
} }
@ -170,25 +153,17 @@ void _glfwInputChar( int character, int action )
// Valid Unicode (ISO 10646) character? // Valid Unicode (ISO 10646) character?
if( !( (character >= 32 && character <= 126) || character >= 160 ) ) if( !( (character >= 32 && character <= 126) || character >= 160 ) )
{
return; return;
}
// Is this a key repeat? // Is this a key repeat?
if( action == GLFW_PRESS && _glfwInput.LastChar == character ) if( action == GLFW_PRESS && _glfwInput.LastChar == character )
{
keyrepeat = 1; keyrepeat = 1;
}
// Store this character as last character (or clear it, if released) // Store this character as last character (or clear it, if released)
if( action == GLFW_PRESS ) if( action == GLFW_PRESS )
{
_glfwInput.LastChar = character; _glfwInput.LastChar = character;
}
else else
{
_glfwInput.LastChar = 0; _glfwInput.LastChar = 0;
}
if( action != GLFW_PRESS ) if( action != GLFW_PRESS )
{ {
@ -209,9 +184,7 @@ void _glfwInputChar( int character, int action )
} }
if( _glfwWin.charCallback && (_glfwInput.KeyRepeat || !keyrepeat) ) if( _glfwWin.charCallback && (_glfwInput.KeyRepeat || !keyrepeat) )
{
_glfwWin.charCallback( character, action ); _glfwWin.charCallback( character, action );
}
} }
@ -225,19 +198,13 @@ void _glfwInputMouseClick( int button, int action )
{ {
// Register mouse button action // Register mouse button action
if( action == GLFW_RELEASE && _glfwInput.StickyMouseButtons ) if( action == GLFW_RELEASE && _glfwInput.StickyMouseButtons )
{
_glfwInput.MouseButton[ button ] = GLFW_STICK; _glfwInput.MouseButton[ button ] = GLFW_STICK;
}
else else
{
_glfwInput.MouseButton[ button ] = (char) action; _glfwInput.MouseButton[ button ] = (char) action;
}
// Call user callback function // Call user callback function
if( _glfwWin.mouseButtonCallback ) if( _glfwWin.mouseButtonCallback )
{
_glfwWin.mouseButtonCallback( button, action ); _glfwWin.mouseButtonCallback( button, action );
}
} }
} }
@ -282,24 +249,16 @@ const _GLFWfbconfig *_glfwChooseFBConfig( const _GLFWfbconfig *desired,
missing = 0; missing = 0;
if( desired->alphaBits > 0 && current->alphaBits == 0 ) if( desired->alphaBits > 0 && current->alphaBits == 0 )
{
missing++; missing++;
}
if( desired->depthBits > 0 && current->depthBits == 0 ) if( desired->depthBits > 0 && current->depthBits == 0 )
{
missing++; missing++;
}
if( desired->stencilBits > 0 && current->stencilBits == 0 ) if( desired->stencilBits > 0 && current->stencilBits == 0 )
{
missing++; missing++;
}
if( desired->auxBuffers > 0 && current->auxBuffers < desired->auxBuffers ) if( desired->auxBuffers > 0 && current->auxBuffers < desired->auxBuffers )
{
missing += desired->auxBuffers - current->auxBuffers; missing += desired->auxBuffers - current->auxBuffers;
}
if( desired->samples > 0 && current->samples == 0 ) if( desired->samples > 0 && current->samples == 0 )
{ {
@ -392,9 +351,7 @@ const _GLFWfbconfig *_glfwChooseFBConfig( const _GLFWfbconfig *desired,
// Figure out if the current one is better than the best one found so far // Figure out if the current one is better than the best one found so far
if( missing < leastMissing ) if( missing < leastMissing )
{
closest = current; closest = current;
}
else if( missing == leastMissing ) else if( missing == leastMissing )
{ {
if( desiresColor ) if( desiresColor )
@ -442,11 +399,8 @@ GLFWAPI int glfwOpenWindow( int width, int height,
_GLFWfbconfig fbconfig; _GLFWfbconfig fbconfig;
_GLFWwndconfig wndconfig; _GLFWwndconfig wndconfig;
// Is GLFW initialized?
if( !_glfwInitialized || _glfwWin.opened ) if( !_glfwInitialized || _glfwWin.opened )
{
return GL_FALSE; return GL_FALSE;
}
// Set up desired framebuffer config // Set up desired framebuffer config
fbconfig.redBits = Max( redbits, 0 ); fbconfig.redBits = Max( redbits, 0 );
@ -511,9 +465,7 @@ GLFWAPI int glfwOpenWindow( int width, int height,
// Check input arguments // Check input arguments
if( mode != GLFW_WINDOW && mode != GLFW_FULLSCREEN ) if( mode != GLFW_WINDOW && mode != GLFW_FULLSCREEN )
{
return GL_FALSE; return GL_FALSE;
}
// Clear GLFW window state // Clear GLFW window state
_glfwWin.active = GL_TRUE; _glfwWin.active = GL_TRUE;
@ -557,9 +509,7 @@ GLFWAPI int glfwOpenWindow( int width, int height,
// Platform specific window opening routine // Platform specific window opening routine
if( !_glfwPlatformOpenWindow( width, height, &wndconfig, &fbconfig ) ) if( !_glfwPlatformOpenWindow( width, height, &wndconfig, &fbconfig ) )
{
return GL_FALSE; return GL_FALSE;
}
// Flag that window is now opened // Flag that window is now opened
_glfwWin.opened = GL_TRUE; _glfwWin.opened = GL_TRUE;
@ -601,9 +551,7 @@ GLFWAPI int glfwOpenWindow( int width, int height,
// If full-screen mode was requested, disable mouse cursor // If full-screen mode was requested, disable mouse cursor
if( mode == GLFW_FULLSCREEN ) if( mode == GLFW_FULLSCREEN )
{
glfwDisable( GLFW_MOUSE_CURSOR ); glfwDisable( GLFW_MOUSE_CURSOR );
}
// Start by clearing the front buffer to black (avoid ugly desktop // Start by clearing the front buffer to black (avoid ugly desktop
// remains in our OpenGL window) // remains in our OpenGL window)
@ -622,9 +570,7 @@ GLFWAPI void glfwOpenWindowHint( int target, int hint )
{ {
// Is GLFW initialized? // Is GLFW initialized?
if( !_glfwInitialized ) if( !_glfwInitialized )
{
return; return;
}
switch( target ) switch( target )
{ {
@ -683,9 +629,7 @@ GLFWAPI void glfwOpenWindowHint( int target, int hint )
GLFWAPI void glfwCloseWindow( void ) GLFWAPI void glfwCloseWindow( void )
{ {
if( !_glfwInitialized ) if( !_glfwInitialized )
{
return; return;
}
// Show mouse pointer again (if hidden) // Show mouse pointer again (if hidden)
glfwEnable( GLFW_MOUSE_CURSOR ); glfwEnable( GLFW_MOUSE_CURSOR );
@ -703,11 +647,8 @@ GLFWAPI void glfwCloseWindow( void )
GLFWAPI void glfwSetWindowTitle( const char *title ) GLFWAPI void glfwSetWindowTitle( const char *title )
{ {
// Is GLFW initialized?
if( !_glfwInitialized || !_glfwWin.opened ) if( !_glfwInitialized || !_glfwWin.opened )
{
return; return;
}
// Set window title // Set window title
_glfwPlatformSetWindowTitle( title ); _glfwPlatformSetWindowTitle( title );
@ -721,13 +662,10 @@ GLFWAPI void glfwSetWindowTitle( const char *title )
GLFWAPI void glfwGetWindowSize( int *width, int *height ) GLFWAPI void glfwGetWindowSize( int *width, int *height )
{ {
if( width != NULL ) if( width != NULL )
{
*width = _glfwWin.width; *width = _glfwWin.width;
}
if( height != NULL ) if( height != NULL )
{
*height = _glfwWin.height; *height = _glfwWin.height;
}
} }
@ -737,17 +675,12 @@ GLFWAPI void glfwGetWindowSize( int *width, int *height )
GLFWAPI void glfwSetWindowSize( int width, int height ) GLFWAPI void glfwSetWindowSize( int width, int height )
{ {
// Is GLFW initialized?
if( !_glfwInitialized || !_glfwWin.opened || _glfwWin.iconified ) if( !_glfwInitialized || !_glfwWin.opened || _glfwWin.iconified )
{
return; return;
}
// Don't do anything if the window size did not change // Don't do anything if the window size did not change
if( width == _glfwWin.width && height == _glfwWin.height ) if( width == _glfwWin.width && height == _glfwWin.height )
{
return; return;
}
// Change window size // Change window size
_glfwPlatformSetWindowSize( width, height ); _glfwPlatformSetWindowSize( width, height );
@ -764,7 +697,6 @@ GLFWAPI void glfwSetWindowSize( int width, int height )
GLFWAPI void glfwSetWindowPos( int x, int y ) GLFWAPI void glfwSetWindowPos( int x, int y )
{ {
// Is GLFW initialized?
if( !_glfwInitialized || !_glfwWin.opened || _glfwWin.fullscreen || if( !_glfwInitialized || !_glfwWin.opened || _glfwWin.fullscreen ||
_glfwWin.iconified ) _glfwWin.iconified )
{ {
@ -782,11 +714,8 @@ GLFWAPI void glfwSetWindowPos( int x, int y )
GLFWAPI void glfwIconifyWindow( void ) GLFWAPI void glfwIconifyWindow( void )
{ {
// Is GLFW initialized?
if( !_glfwInitialized || !_glfwWin.opened || _glfwWin.iconified ) if( !_glfwInitialized || !_glfwWin.opened || _glfwWin.iconified )
{
return; return;
}
// Iconify window // Iconify window
_glfwPlatformIconifyWindow(); _glfwPlatformIconifyWindow();
@ -799,11 +728,8 @@ GLFWAPI void glfwIconifyWindow( void )
GLFWAPI void glfwRestoreWindow( void ) GLFWAPI void glfwRestoreWindow( void )
{ {
// Is GLFW initialized?
if( !_glfwInitialized || !_glfwWin.opened || !_glfwWin.iconified ) if( !_glfwInitialized || !_glfwWin.opened || !_glfwWin.iconified )
{
return; return;
}
// Restore iconified window // Restore iconified window
_glfwPlatformRestoreWindow(); _glfwPlatformRestoreWindow();
@ -819,23 +745,16 @@ GLFWAPI void glfwRestoreWindow( void )
GLFWAPI void glfwSwapBuffers( void ) GLFWAPI void glfwSwapBuffers( void )
{ {
// Is GLFW initialized?
if( !_glfwInitialized || !_glfwWin.opened ) if( !_glfwInitialized || !_glfwWin.opened )
{
return; return;
}
// Update display-buffer // Update display-buffer
if( _glfwWin.opened ) if( _glfwWin.opened )
{
_glfwPlatformSwapBuffers(); _glfwPlatformSwapBuffers();
}
// Check for window messages // Check for window messages
if( _glfwWin.autoPollEvents ) if( _glfwWin.autoPollEvents )
{
glfwPollEvents(); glfwPollEvents();
}
} }
@ -845,11 +764,8 @@ GLFWAPI void glfwSwapBuffers( void )
GLFWAPI void glfwSwapInterval( int interval ) GLFWAPI void glfwSwapInterval( int interval )
{ {
// Is GLFW initialized?
if( !_glfwInitialized || !_glfwWin.opened ) if( !_glfwInitialized || !_glfwWin.opened )
{
return; return;
}
// Set double buffering swap interval // Set double buffering swap interval
_glfwPlatformSwapInterval( interval ); _glfwPlatformSwapInterval( interval );
@ -862,19 +778,14 @@ GLFWAPI void glfwSwapInterval( int interval )
GLFWAPI int glfwGetWindowParam( int param ) GLFWAPI int glfwGetWindowParam( int param )
{ {
// Is GLFW initialized?
if( !_glfwInitialized ) if( !_glfwInitialized )
{
return 0; return 0;
}
// Is the window opened?
if( !_glfwWin.opened ) if( !_glfwWin.opened )
{ {
if( param == GLFW_OPENED ) if( param == GLFW_OPENED )
{
return GL_FALSE; return GL_FALSE;
}
return 0; return 0;
} }
@ -941,11 +852,8 @@ GLFWAPI int glfwGetWindowParam( int param )
GLFWAPI void glfwSetWindowSizeCallback( GLFWwindowsizefun cbfun ) GLFWAPI void glfwSetWindowSizeCallback( GLFWwindowsizefun cbfun )
{ {
// Is GLFW initialized?
if( !_glfwInitialized || !_glfwWin.opened ) if( !_glfwInitialized || !_glfwWin.opened )
{
return; return;
}
// Set callback function // Set callback function
_glfwWin.windowSizeCallback = cbfun; _glfwWin.windowSizeCallback = cbfun;
@ -953,9 +861,7 @@ GLFWAPI void glfwSetWindowSizeCallback( GLFWwindowsizefun cbfun )
// Call the callback function to let the application know the current // Call the callback function to let the application know the current
// window size // window size
if( cbfun ) if( cbfun )
{
cbfun( _glfwWin.width, _glfwWin.height ); cbfun( _glfwWin.width, _glfwWin.height );
}
} }
//======================================================================== //========================================================================
@ -964,11 +870,8 @@ GLFWAPI void glfwSetWindowSizeCallback( GLFWwindowsizefun cbfun )
GLFWAPI void glfwSetWindowCloseCallback( GLFWwindowclosefun cbfun ) GLFWAPI void glfwSetWindowCloseCallback( GLFWwindowclosefun cbfun )
{ {
// Is GLFW initialized?
if( !_glfwInitialized || !_glfwWin.opened ) if( !_glfwInitialized || !_glfwWin.opened )
{
return; return;
}
// Set callback function // Set callback function
_glfwWin.windowCloseCallback = cbfun; _glfwWin.windowCloseCallback = cbfun;
@ -981,11 +884,8 @@ GLFWAPI void glfwSetWindowCloseCallback( GLFWwindowclosefun cbfun )
GLFWAPI void glfwSetWindowRefreshCallback( GLFWwindowrefreshfun cbfun ) GLFWAPI void glfwSetWindowRefreshCallback( GLFWwindowrefreshfun cbfun )
{ {
// Is GLFW initialized?
if( !_glfwInitialized || !_glfwWin.opened ) if( !_glfwInitialized || !_glfwWin.opened )
{
return; return;
}
// Set callback function // Set callback function
_glfwWin.windowRefreshCallback = cbfun; _glfwWin.windowRefreshCallback = cbfun;
@ -998,11 +898,8 @@ GLFWAPI void glfwSetWindowRefreshCallback( GLFWwindowrefreshfun cbfun )
GLFWAPI void glfwPollEvents( void ) GLFWAPI void glfwPollEvents( void )
{ {
// Is GLFW initialized?
if( !_glfwInitialized || !_glfwWin.opened ) if( !_glfwInitialized || !_glfwWin.opened )
{
return; return;
}
// Poll for new events // Poll for new events
_glfwPlatformPollEvents(); _glfwPlatformPollEvents();
@ -1015,11 +912,8 @@ GLFWAPI void glfwPollEvents( void )
GLFWAPI void glfwWaitEvents( void ) GLFWAPI void glfwWaitEvents( void )
{ {
// Is GLFW initialized?
if( !_glfwInitialized || !_glfwWin.opened ) if( !_glfwInitialized || !_glfwWin.opened )
{
return; return;
}
// Poll for new events // Poll for new events
_glfwPlatformWaitEvents(); _glfwPlatformWaitEvents();