From: <dc...@us...> - 2013-04-07 08:04:00
|
Revision: 1613 http://freeglut.svn.sourceforge.net/freeglut/?rev=1613&view=rev Author: dcnieho Date: 2013-04-07 08:03:48 +0000 (Sun, 07 Apr 2013) Log Message: ----------- doc that timers are sorted by endtime + don't call fgElapsedTime() if no timers to check, its a waste Modified Paths: -------------- trunk/freeglut/freeglut/src/fg_callbacks.c trunk/freeglut/freeglut/src/fg_main.c Modified: trunk/freeglut/freeglut/src/fg_callbacks.c =================================================================== --- trunk/freeglut/freeglut/src/fg_callbacks.c 2013-04-06 14:08:59 UTC (rev 1612) +++ trunk/freeglut/freeglut/src/fg_callbacks.c 2013-04-07 08:03:48 UTC (rev 1613) @@ -63,6 +63,7 @@ timer->ID = timerID; timer->TriggerTime = fgElapsedTime() + timeOut; + /* Insert such that timers are sorted by end-time */ for( node = fgState.Timers.First; node; node = node->Node.Next ) { if( node->TriggerTime > timer->TriggerTime ) Modified: trunk/freeglut/freeglut/src/fg_main.c =================================================================== --- trunk/freeglut/freeglut/src/fg_main.c 2013-04-06 14:08:59 UTC (rev 1612) +++ trunk/freeglut/freeglut/src/fg_main.c 2013-04-07 08:03:48 UTC (rev 1613) @@ -261,7 +261,7 @@ 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 ); @@ -388,12 +388,13 @@ */ 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 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |