SFG_State fgState = { { -1, -1, FALSE }, /* Position */
{ 300, 300, TRUE }, /* Size */
GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH, /* DisplayMode */
+ FALSE, /* Initalized */
FALSE, /* ForceDirectContext */
TRUE, /* TryDirectContext */
FALSE, /* ForceIconic */
#endif
fgJoystickInit( 0 );
+
+ fgState.Initalized = GL_TRUE;
}
/*
{
SFG_Timer *timer;
- if( !fgState.Time.Set )
+ if( !fgState.Initalized )
{
- fgWarning( "fgDeinitialize(): fgState.Timer is null => "
- "no valid initialization has been performed" );
+ fgWarning( "fgDeinitialize(): "
+ "no valid initialization has been performed" );
return;
}
+ fgState.Initalized = GL_FALSE;
+
/*
* If there was a menu created, destroy the rendering context
*/
if( !fgState.ProgramName )
fgError ("Could not allocate space for the program's name.");
- if( fgState.Time.Set )
+ if( fgState.Initalized )
fgError( "illegal glutInit() reinitialization attemp" );
fgCreateStructure( );
-#if TARGET_HOST_UNIX_X11
- gettimeofday( &fgState.Time.Value, NULL );
-#elif TARGET_HOST_WIN32
- fgState.Time.Value = timeGetTime( );
-#endif
- fgState.Time.Set = TRUE;
+ fgElapsedTime( );
/* check if GLUT_FPS env var is set */
{
SFG_XYUse Size; /* The default windows' size */
unsigned int DisplayMode; /* Display mode for new windows */
+ GLboolean Initalized; /* Freeglut has been initalized */
+
GLboolean ForceDirectContext; /* Force direct rendering? */
GLboolean TryDirectContext; /* What about giving a try to? */
* A call to this function makes us sure that the Display and Structure
* subsystems have been properly initialized and are ready to be used
*/
-#define freeglut_assert_ready assert( fgState.Time.Set );
+#define freeglut_assert_ready assert( fgState.Initalized );
/*
* Following definitions are somewhat similiar to GLib's,
*/
long fgElapsedTime( void )
{
+ if (fgState.Time.Set)
+ {
#if TARGET_HOST_UNIX_X11
- struct timeval now;
- long elapsed;
+ struct timeval now;
+ long elapsed;
- gettimeofday( &now, NULL );
+ gettimeofday( &now, NULL );
- elapsed = (now.tv_usec - fgState.Time.Value.tv_usec) / 1000;
- elapsed += (now.tv_sec - fgState.Time.Value.tv_sec) * 1000;
+ elapsed = (now.tv_usec - fgState.Time.Value.tv_usec) / 1000;
+ elapsed += (now.tv_sec - fgState.Time.Value.tv_sec) * 1000;
- return elapsed;
+ return elapsed;
+#elif TARGET_HOST_WIN32
+ return timeGetTime() - fgState.Time.Value;
+#endif
+ }
+ else
+ {
+#if TARGET_HOST_UNIX_X11
+ gettimeofday( &fgState.Time.Value, NULL );
#elif TARGET_HOST_WIN32
- return timeGetTime() - fgState.Time.Value;
+ fgState.Time.Value = timeGetTime( );
#endif
+ fgState.Time.Set = TRUE;
+ }
}
/*
int returnValue ;
GLboolean boolValue ;
- if ( eWhat == GLUT_INIT_STATE )
- return ( fgState.Time.Set ) ;
+ switch (eWhat)
+ {
+ case GLUT_INIT_STATE:
+ return ( fgState.Initalized ) ;
+
+ case GLUT_ELAPSED_TIME:
+ return( fgElapsedTime() );
+ }
freeglut_assert_ready;
*/
switch( eWhat )
{
- case GLUT_ELAPSED_TIME:
- return( fgElapsedTime() );
-
/*
* Following values are stored in fgState and fgDisplay global structures
*/
* If the freeglut internals haven't been initialized yet,
* do it now. Hack's idea courtesy of Chris Purnell...
*/
- if( !fgState.Time.Set )
+ if( !fgState.Initalized )
glutInit( &fakeArgc, NULL );
/*
* If the freeglut internals haven't been initialized yet,
* do it now. Hack's idea courtesy of Chris Purnell...
*/
- if( !fgState.Time.Set )
+ if( !fgState.Initalized )
glutInit( &fakeArgc, NULL );
menu->ParentWindow = fgStructure.Window;
fgDisplay.ScreenWidth,
fgDisplay.ScreenHeight
);
- XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
+
+ XFlush( fgDisplay.Display ); /* This is needed */
XTranslateCoordinates(
fgDisplay.Display,