X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_init.c;h=078192c5684b456bd1b5773aaac32a0f5adef3fe;hb=e168af86e8c8ab1ac30817bb570b374964da72a2;hp=75908c980af8e794a7d055e8e8b2cd28c96b7395;hpb=cb35752f171cdd1ee2319194c890d86bc6242259;p=freeglut diff --git a/src/freeglut_init.c b/src/freeglut_init.c index 75908c9..078192c 100644 --- a/src/freeglut_init.c +++ b/src/freeglut_init.c @@ -25,10 +25,6 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #include #include "freeglut_internal.h" @@ -64,7 +60,7 @@ SFG_State fgState = { { -1, -1, GL_FALSE }, /* Position */ GL_FALSE, /* UseCurrentContext */ GL_FALSE, /* GLDebugSwitch */ GL_FALSE, /* XSyncSwitch */ - GL_TRUE, /* KeyRepeat */ + GLUT_KEY_REPEAT_ON, /* KeyRepeat */ 0xffffffff, /* Modifiers */ 0, /* FPSInterval */ 0, /* SwapCount */ @@ -183,7 +179,7 @@ static void fghInitialize( const char* displayName ) /* Register the window class */ atom = RegisterClass( &wc ); - assert( atom ); + FREEGLUT_INTERNAL_ERROR_EXIT ( atom, "Window Class Not Registered", "fghInitialize" ); } /* The screen dimensions can be obtained via GetSystemMetrics() calls */ @@ -200,6 +196,9 @@ static void fghInitialize( const char* displayName ) ReleaseDC( desktop, context ); } + /* Set the timer granularity to 1 ms */ + timeBeginPeriod ( 1 ); + #endif fgState.Initialised = GL_TRUE; @@ -219,8 +218,6 @@ void fgDeinitialize( void ) return; } - /* fgState.Initialised = GL_FALSE; */ - /* If there was a menu created, destroy the rendering context */ if( fgStructure.MenuContext ) { @@ -230,13 +227,13 @@ void fgDeinitialize( void ) fgDestroyStructure( ); - while( timer = fgState.Timers.First ) + while( ( timer = fgState.Timers.First) ) { fgListRemove( &fgState.Timers, &timer->Node ); free( timer ); } - while( timer = fgState.FreeTimers.First ) + while( ( timer = fgState.FreeTimers.First) ) { fgListRemove( &fgState.FreeTimers, &timer->Node ); free( timer ); @@ -268,7 +265,7 @@ void fgDeinitialize( void ) fgState.ActionOnWindowClose = GLUT_ACTION_EXIT; fgState.ExecState = GLUT_EXEC_STATE_INIT; - fgState.KeyRepeat = GL_TRUE; + fgState.KeyRepeat = GLUT_KEY_REPEAT_ON; fgState.Modifiers = 0xffffffff; fgState.GameModeSize.X = 640; @@ -295,7 +292,6 @@ void fgDeinitialize( void ) fgState.ProgramName = NULL; } - #if TARGET_HOST_UNIX_X11 /* @@ -310,7 +306,14 @@ void fgDeinitialize( void ) */ XCloseDisplay( fgDisplay.Display ); +#elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE + + /* Reset the timer granularity */ + timeEndPeriod ( 1 ); + #endif + + fgState.Initialised = GL_FALSE; } /* @@ -620,9 +623,13 @@ void FGAPIENTRY glutInit( int* pargc, char** argv ) if (geometry ) { + unsigned int parsedWidth, parsedHeight; int mask = XParseGeometry( geometry, &fgState.Position.X, &fgState.Position.Y, - &fgState.Size.X, &fgState.Size.Y ); + &parsedWidth, &parsedHeight ); + /* TODO: Check for overflow? */ + fgState.Size.X = parsedWidth; + fgState.Size.Y = parsedHeight; if( (mask & (WidthValue|HeightValue)) == (WidthValue|HeightValue) ) fgState.Size.Use = GL_TRUE; @@ -678,7 +685,6 @@ void FGAPIENTRY glutInitDisplayMode( unsigned int displayMode ) /* -- INIT DISPLAY STRING PARSING ------------------------------------------ */ -#define NUM_TOKENS 36 static char* Tokens[] = { "alpha", "acca", "acc", "blue", "buffer", "conformant", "depth", "double", @@ -687,19 +693,9 @@ static char* Tokens[] = "xstaticgray", "xgrayscale", "xstaticcolor", "xpseudocolor", "xtruecolor", "xdirectcolor", "xstaticgrey", "xgreyscale", "xstaticcolour", "xpseudocolour", - "xtruecolour", "xdirectcolour", "borderless" -}; - -static int TokenLengths[] = -{ - 5, 4, 3, 4, 6, 10, 5, 6, - 5, 5, 3, 3, 4, 3, 9, 7, - 6, 6, 7, 4, 8, 8, 7, - 11, 10, 12, 12, - 10, 12, - 11, 10, 13, 13, - 11, 13, 10 + "xtruecolour", "xdirectcolour", "borderless", "aux" }; +#define NUM_TOKENS (sizeof(Tokens) / sizeof(*Tokens)) void FGAPIENTRY glutInitDisplayString( const char* displayMode ) { @@ -721,7 +717,7 @@ void FGAPIENTRY glutInitDisplayString( const char* displayMode ) int i ; for ( i = 0; i < NUM_TOKENS; i++ ) { - if ( strncmp ( token, Tokens[i], TokenLengths[i] ) == 0 ) break ; + if ( strcmp ( token, Tokens[i] ) == 0 ) break ; } switch ( i ) @@ -874,7 +870,11 @@ void FGAPIENTRY glutInitDisplayString( const char* displayMode ) #endif break ; - case 36 : /* Unrecognized */ + case 36 : /* "aux": some number of aux buffers */ + glut_state_flag |= GLUT_AUX1; + break ; + + case 37 : /* Unrecognized */ fgWarning ( "WARNING - Display string token not recognized: %s", token ); break ;