X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffg_main.c;h=4dee9b9948c71ae726e2f0cdcc6082472db05c31;hb=a00c7ee3552b527ac6b375d6a6ca42f90770ddc3;hp=82f708c615cabc9d2eaacf89d8cde7c82f779f49;hpb=99d53f15a4216240088132f6af9cb194b519b1cc;p=freeglut diff --git a/src/fg_main.c b/src/fg_main.c index 82f708c..4dee9b9 100644 --- a/src/fg_main.c +++ b/src/fg_main.c @@ -92,7 +92,7 @@ void fghOnReshapeNotify(SFG_Window *window, int width, int height, GLboolean for * window. * DN: Hmm.. the above sounds like a concern only in single buffered mode... */ - glutPostRedisplay( ); + window->State.WorkMask |= GLUT_DISPLAY_WORK; if( window->IsMenu ) fgSetWindow( saved_window ); } @@ -179,33 +179,6 @@ static void fghProcessWork( void ) fgEnumWindows( fghcbProcessWork, &enumerator ); } - -static void fghcbDisplayWindow( SFG_Window *window, - SFG_Enumerator *enumerator ) -{ - if( window->State.Redisplay && - window->State.Visible ) - { - window->State.Redisplay = GL_FALSE; - fghRedrawWindow ( window ); - } - - fgEnumSubWindows( window, fghcbDisplayWindow, enumerator ); -} - -/* - * Make all windows perform a display call - */ -static void fghDisplayAll( void ) -{ - SFG_Enumerator enumerator; - - enumerator.found = GL_FALSE; - enumerator.data = NULL; - - fgEnumWindows( fghcbDisplayWindow, &enumerator ); -} - /* * Window enumerator callback to check for the joystick polling code */ @@ -261,7 +234,7 @@ static void fghCheckTimers( void ) SFG_Timer *timer = fgState.Timers.First; if( timer->TriggerTime > checkTime ) - /* XXX: are timers always sorted by triggerTime? If not, this and fghNextTimer are wrong */ + /* Timers are sorted by triggerTime */ break; fgListRemove( &fgState.Timers, &timer->Node ); @@ -308,7 +281,7 @@ void fgError( const char *fmt, ... ) va_end( ap ); } else { -#if FREEGLUT_ERRORS +#ifdef FREEGLUT_PRINT_ERRORS va_start( ap, fmt ); fprintf( stderr, "freeglut "); @@ -341,7 +314,7 @@ void fgWarning( const char *fmt, ... ) va_end( ap ); } else { -#if FREEGLUT_WARNINGS +#ifdef FREEGLUT_PRINT_WARNINGS va_start( ap, fmt ); fprintf( stderr, "freeglut "); @@ -357,29 +330,28 @@ void fgWarning( const char *fmt, ... ) /* - * Indicates whether a redisplay is pending for ANY window. + * Indicates whether work is pending for ANY window. * * The current mechanism is to walk all of the windows and ask if - * a redisplay is pending. We have a short-circuit early - * return if we find any. + * work is pending. We have a short-circuit early return if we find any. */ -static void fghHavePendingRedisplaysCallback( SFG_Window* w, SFG_Enumerator* e) +static void fghHavePendingWorkCallback( SFG_Window* w, SFG_Enumerator* e) { - if( w->State.Redisplay && w->State.Visible ) + if( w->State.WorkMask ) { e->found = GL_TRUE; e->data = w; return; } - fgEnumSubWindows( w, fghHavePendingRedisplaysCallback, e ); + fgEnumSubWindows( w, fghHavePendingWorkCallback, e ); } -static int fghHavePendingRedisplays (void) +static int fghHavePendingWork (void) { SFG_Enumerator enumerator; enumerator.found = GL_FALSE; enumerator.data = NULL; - fgEnumWindows( fghHavePendingRedisplaysCallback, &enumerator ); + fgEnumWindows( fghHavePendingWorkCallback, &enumerator ); return !!enumerator.data; } @@ -388,12 +360,13 @@ static int fghHavePendingRedisplays (void) */ static fg_time_t fghNextTimer( void ) { - fg_time_t currentTime = fgElapsedTime(); - SFG_Timer *timer = fgState.Timers.First; + fg_time_t currentTime; + SFG_Timer *timer = fgState.Timers.First; /* timers are sorted by trigger time, so only have to check the first */ if( !timer ) return INT_MAX; + currentTime = fgElapsedTime(); if( timer->TriggerTime < currentTime ) return 0; else @@ -404,7 +377,7 @@ static void fghSleepForEvents( void ) { fg_time_t msec; - if( fghHavePendingRedisplays( ) ) + if( fghHavePendingWork( ) ) return; msec = fghNextTimer( ); @@ -432,12 +405,9 @@ void FGAPIENTRY glutMainLoopEvent( void ) if (fgState.NumActiveJoysticks>0) /* If zero, don't poll joysticks */ fghCheckJoystickPolls( ); - /* Perform work on the window (position, reshape, etc) */ + /* Perform work on the window (position, reshape, display, etc) */ fghProcessWork( ); - /* Display */ - fghDisplayAll( ); - fgCloseWindows( ); }