X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;ds=sidebyside;f=src%2Ffreeglut_init.c;h=973c7f203341517abc41ea9ed24d65f688dbfd3f;hb=2e5dc871b7c1df472978af9811d0e97b6684707c;hp=dc25180a02128788c4fdd2cc56109eaaf66ff4fb;hpb=19ec40fe17e7f60ce3548d986249381014807c35;p=freeglut diff --git a/src/freeglut_init.c b/src/freeglut_init.c index dc25180..973c7f2 100644 --- a/src/freeglut_init.c +++ b/src/freeglut_init.c @@ -29,19 +29,19 @@ #include "config.h" #endif -#define G_LOG_DOMAIN "freeglut-init" - #include "../include/GL/freeglut.h" #include "freeglut_internal.h" /* * TODO BEFORE THE STABLE RELEASE: * - * fgDeinitialize() -- Win32's OK, X11 needs the OS-specific deinitialization done + * fgDeinitialize() -- Win32's OK, X11 needs the OS-specific + * deinitialization done * glutInitDisplayString() -- display mode string parsing * - * Wouldn't it be cool to use gettext() for error messages? I just love bash saying - * "nie znaleziono pliku" instead of "file not found" :) Is gettext easily portable? + * Wouldn't it be cool to use gettext() for error messages? I just love + * bash saying "nie znaleziono pliku" instead of "file not found" :) + * Is gettext easily portable? */ /* -- GLOBAL VARIABLES ----------------------------------------------------- */ @@ -216,29 +216,29 @@ void fgDeinitialize( void ) /* * If there was a menu created, destroy the rendering context */ - if ( fgStructure.MenuContext ) + if( fgStructure.MenuContext ) { - free ( fgStructure.MenuContext ) ; - fgStructure.MenuContext = NULL ; + free( fgStructure.MenuContext ); + fgStructure.MenuContext = NULL; } fgDestroyStructure(); - while ( (timer = (SFG_Timer *)fgState.Timers.First) != NULL ) + while( timer = (SFG_Timer *)fgState.Timers.First ) { - fgListRemove ( &fgState.Timers, &timer->Node ) ; - free ( timer ) ; + fgListRemove ( &fgState.Timers, &timer->Node ); + free( timer ); } - fgJoystickClose(); + fgJoystickClose( ); - fgState.Position.X = -1 ; - fgState.Position.Y = -1 ; - fgState.Position.Use = FALSE ; + fgState.Position.X = -1; + fgState.Position.Y = -1; + fgState.Position.Use = FALSE; - fgState.Size.X = 300 ; - fgState.Size.Y = 300 ; - fgState.Size.Use = TRUE ; + fgState.Size.X = 300; + fgState.Size.Y = 300; + fgState.Size.Use = TRUE; fgState.DisplayMode = GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH; @@ -258,26 +258,35 @@ void fgDeinitialize( void ) fgState.GameModeDepth = 16; fgState.GameModeRefresh = 72; - fgState.Time.Set = FALSE ; + fgState.Time.Set = FALSE; - fgState.Timers.First = fgState.Timers.Last = NULL ; - fgState.IdleCallback = NULL ; - fgState.MenuStateCallback = (FGCBmenuState)NULL ; - fgState.MenuStatusCallback = (FGCBmenuStatus)NULL ; + fgState.Timers.First = fgState.Timers.Last = NULL; + fgState.IdleCallback = NULL; + fgState.MenuStateCallback = (FGCBmenuState)NULL; + fgState.MenuStatusCallback = (FGCBmenuStatus)NULL; fgState.SwapCount = 0; fgState.SwapTime = 0; fgState.FPSInterval = 0; + if( fgState.ProgramName ) + { + free( fgState.ProgramName ); + fgState.ProgramName = NULL; + } + + #if TARGET_HOST_UNIX_X11 /* - * Make sure all X-client data we have created will be destroyed on display closing + * Make sure all X-client data we have created will be destroyed on + * display closing */ XSetCloseDownMode( fgDisplay.Display, DestroyAll ); /* - * Close the display connection, destroying all windows we have created so far + * Close the display connection, destroying all windows we have + * created so far */ XCloseDisplay( fgDisplay.Display ); @@ -317,22 +326,22 @@ void FGAPIENTRY glutInit( int* pargc, char** argv ) /* check if GLUT_FPS env var is set */ { - const char *fps = getenv ( "GLUT_FPS" ); - if ( fps ) - { - sscanf ( fps, "%d", &fgState.FPSInterval ) ; - if ( fgState.FPSInterval <= 0 ) - fgState.FPSInterval = 5000 ; /* 5000 milliseconds */ - } + const char *fps = getenv ( "GLUT_FPS" ); + if( fps ) + { + sscanf( fps, "%d", &fgState.FPSInterval ); + if( fgState.FPSInterval <= 0 ) + fgState.FPSInterval = 5000; /* 5000 milliseconds */ + } } #if TARGET_HOST_WIN32 - if ( !getenv ( "DISPLAY" ) ) - displayName = strdup ( "" ) ; + if( !getenv( "DISPLAY" ) ) + displayName = strdup( "" ); else #endif displayName = strdup( getenv( "DISPLAY" ) ); - if (!displayName) + if( !displayName ) fgError ("Could not allocate space for display name."); for( i=1; i= 0) && (y >= 0) ) { - fgState.Position.X = x; fgState.Position.Y = y; fgState.Position.Use = TRUE;