Ensure that the time-out for sleeping is never negative.

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@375 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
rkrolib 2003-12-02 21:04:33 +00:00
parent 819e8645b6
commit 642f60f651

View File

@ -423,10 +423,12 @@ static int fgHavePendingRedisplays (void)
static long fgNextTimer( void ) static long fgNextTimer( void )
{ {
long ret = INT_MAX; long ret = INT_MAX;
SFG_Timer *timer; SFG_Timer *timer = fgState.Timers.First;
if( (timer = fgState.Timers.First) ) if( timer )
ret = timer->TriggerTime - fgElapsedTime(); ret = timer->TriggerTime - fgElapsedTime();
if( ret < 0 )
ret = 0;
return ret; return ret;
} }
@ -452,7 +454,7 @@ static void fgSleepForEvents( void )
msec = fgNextTimer( ); msec = fgNextTimer( );
if( fgHaveJoystick( ) ) if( fgHaveJoystick( ) )
msec = MIN( msec, 10 ); msec = MIN( msec, 10 );
wait.tv_sec = msec / 1000; wait.tv_sec = msec / 1000;
wait.tv_usec = (msec % 1000) * 1000; wait.tv_usec = (msec % 1000) * 1000;
err = select( socket+1, &fdset, NULL, NULL, &wait ); err = select( socket+1, &fdset, NULL, NULL, &wait );