#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 ----------------------------------------------------- */
if( !glXQueryExtension( fgDisplay.Display, NULL, NULL ) )
fgError( "OpenGL GLX extension not supported by display '%s'",
- XDisplayName( displayName ) );
+ XDisplayName( displayName ) );
fgDisplay.Screen = DefaultScreen( fgDisplay.Display );
fgDisplay.RootWindow = RootWindow(
fgDisplay.Screen
);
fgDisplay.ScreenHeightMM = DisplayHeightMM(
- fgDisplay.Display,
- fgDisplay.Screen
+ fgDisplay.Display,
+ fgDisplay.Screen
);
fgDisplay.Connection = ConnectionNumber( fgDisplay.Display );
if( !fgState.Time.Set )
{
fgWarning( "fgDeinitialize(): fgState.Timer is null => "
- "no valid initialization has been performed" );
+ "no valid initialization has been performed" );
return;
}
/*
* 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;
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 );
int i, j, argc = *pargc;
if (pargc && *pargc && argv && *argv && **argv)
- fgState.ProgramName = strdup (*argv);
+ fgState.ProgramName = strdup (*argv);
else
- fgState.ProgramName = strdup ("");
+ fgState.ProgramName = strdup ("");
if (!fgState.ProgramName)
- fgError ("Could not allocate space for the program's name.");
+ fgError ("Could not allocate space for the program's name.");
if( fgState.Time.Set )
- fgError( "illegal glutInit() reinitialization attemp" );
+ fgError( "illegal glutInit() reinitialization attemp" );
fgCreateStructure();
/* 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)
- fgError ("Could not allocate space for display name.");
+ displayName = strdup( getenv( "DISPLAY" ) );
+ if( !displayName )
+ fgError ("Could not allocate space for display name.");
for( i=1; i<argc; i++ )
{
fgError( "-display parameter must be followed by display name" );
if( displayName )
- free( displayName );
+ free( displayName );
displayName = strdup( argv[ i ] );
- if (!displayName)
- fgError( "Could not allocate space for display name (%s)",
- argv [i]);
+ if (!displayName)
+ fgError( "Could not allocate space for display name (%s)",
+ argv [i]);
argv[ i - 1 ] = NULL;
argv[ i ] = NULL;
}
else if( strcmp( argv[ i ], "-geometry" ) == 0 )
{
- int result, x, y;
- unsigned int w, h;
+ int result, x, y;
+ unsigned int w, h;
- if ( ++i >= argc )
+ if ( ++i >= argc )
fgError( "-geometry parameter must be followed by window "
- "geometry settings" );
- result = sscanf ( argv[i], "%dx%d+%d+%d", &x, &y, &w, &h );
+ "geometry settings" );
+ result = sscanf ( argv[i], "%dx%d+%d+%d", &x, &y, &w, &h );
- if ( result > 3 )
- fgState.Size.Y = h;
- if ( result > 2 )
- fgState.Size.X = w;
+ if ( result > 3 )
+ fgState.Size.Y = h;
+ if ( result > 2 )
+ fgState.Size.X = w;
- if( result > 1 )
+ if( result > 1 )
{
- if( y < 0 )
- fgState.Position.Y =
- fgDisplay.ScreenHeight + y - fgState.Size.Y;
- else
- fgState.Position.Y = y;
- }
-
- if( result > 0 )
+ if( y < 0 )
+ fgState.Position.Y =
+ fgDisplay.ScreenHeight + y - fgState.Size.Y;
+ else
+ fgState.Position.Y = y;
+ }
+
+ if( result > 0 )
{
- if( x < 0 )
- fgState.Position.X =
- fgDisplay.ScreenWidth + x - fgState.Size.X;
- else
- fgState.Position.X = x;
- }
-
- argv[ i - 1 ] = NULL;
- argv[ i ] = NULL;
- (*pargc) -= 2;
+ if( x < 0 )
+ fgState.Position.X =
+ fgDisplay.ScreenWidth + x - fgState.Size.X;
+ else
+ fgState.Position.X = x;
+ }
+
+ argv[ i - 1 ] = NULL;
+ argv[ i ] = NULL;
+ (*pargc) -= 2;
}
else if( strcmp( argv[ i ], "-direct" ) == 0)
{
if( fgState.TryDirectContext == FALSE )
fgError( "parameters ambiguity, -direct and -indirect "
- "cannot be both specified" );
+ "cannot be both specified" );
fgState.ForceDirectContext = TRUE;
argv[ i ] = NULL;
{
if( fgState.ForceDirectContext == TRUE )
fgError( "parameters ambiguity, -direct and -indirect "
- "cannot be both specified" );
+ "cannot be both specified" );
fgState.TryDirectContext = FALSE;
argv[ i ] = NULL;
j = 2 ;
for( i = 1; i < *pargc; i++, j++ )
{
- if( argv[ i ] == NULL )
+ if( argv[ i ] == NULL )
{
- /* Guaranteed to end because there are "*pargc" arguments left */
- while ( argv[j] == NULL )
- j++;
- argv[i] = argv[j] ;
- }
+ /* Guaranteed to end because there are "*pargc" arguments left */
+ while ( argv[j] == NULL )
+ j++;
+ argv[i] = argv[j] ;
+ }
}
/*
fgState.Size.Use = FALSE;
if( displayName )
- free( displayName );
+ free( displayName );
}
/*
{
if( (x >= 0) && (y >= 0) )
{
-
fgState.Position.X = x;
fgState.Position.Y = y;
fgState.Position.Use = TRUE;
G_CSET_a_2_z
"_"
G_CSET_A_2_Z
- ) /* cset_identifier_first */,
+ ) /* cset_identifier_first */,
(
G_CSET_a_2_z
"_0123456789"
G_CSET_LATINS
G_CSET_LATINC
"<>!=~"
- ) /* cset_identifier_nth */,
- ( "#\n" ) /* cpair_comment_single */,
- FALSE /* case_sensitive */,
- TRUE /* skip_comment_multi */,
- TRUE /* skip_comment_single */,
- TRUE /* scan_comment_multi */,
- TRUE /* scan_identifier */,
- FALSE /* scan_identifier_1char */,
- FALSE /* scan_identifier_NULL */,
- TRUE /* scan_symbols */,
- FALSE /* scan_binary */,
- TRUE /* scan_octal */,
- TRUE /* scan_float */,
- TRUE /* scan_hex */,
- FALSE /* scan_hex_dollar */,
- TRUE /* scan_string_sq */,
- TRUE /* scan_string_dq */,
- TRUE /* numbers_2_int */,
- FALSE /* int_2_float */,
- FALSE /* identifier_2_string */,
- TRUE /* char_2_token */,
- FALSE /* symbol_2_token */,
- FALSE /* scope_0_fallback */,
+ ) /* cset_identifier_nth */,
+ ( "#\n" ) /* cpair_comment_single */,
+ FALSE /* case_sensitive */,
+ TRUE /* skip_comment_multi */,
+ TRUE /* skip_comment_single */,
+ TRUE /* scan_comment_multi */,
+ TRUE /* scan_identifier */,
+ FALSE /* scan_identifier_1char */,
+ FALSE /* scan_identifier_NULL */,
+ TRUE /* scan_symbols */,
+ FALSE /* scan_binary */,
+ TRUE /* scan_octal */,
+ TRUE /* scan_float */,
+ TRUE /* scan_hex */,
+ FALSE /* scan_hex_dollar */,
+ TRUE /* scan_string_sq */,
+ TRUE /* scan_string_dq */,
+ TRUE /* numbers_2_int */,
+ FALSE /* int_2_float */,
+ FALSE /* identifier_2_string */,
+ TRUE /* char_2_token */,
+ FALSE /* symbol_2_token */,
+ FALSE /* scope_0_fallback */,
};
/*
if( comparison != FG_NONE && i < (gint) strlen( scanner->value.v_identifier ) )
{
valueString = strdup( scanner->value.v_identifier + i );
- if (!valueString)
- fgError ("Could not allocate an internal string.");
- }
+ if (!valueString)
+ fgError ("Could not allocate an internal string.");
+ }
/*
* If there was a value string, convert it to integer...