Originally Posted by
Auradrummer
Have some way to force the main loop to spend a specific amount of time each pass?
Yes, I have a way of forcing any piece of code to execute in any arbitrary length of time. I used this to predict the final outcome of the universe in less than two microseconds.
More seriously, you need to occassionally call a time-getting function to see if you're getting too far "ahead", sleeping if necessary. For instance, if each loop iteration takes dt seconds, then:
Code:
double t = CurrentTime();
for(;;)
{
if( t > CurrentTime() + slop )
WaitUntil( t );
...
t += dt;
}
Where CurrentTime() gives the current time in seconds (double precision), slop is the maximum time you are allowed to overshoot (possibly 0.0), and WaitUntil() is a function which causes the program to sleep until the time is greater than or equal to t.