WhatMeWorry
2005.08.01, 03:20 AM
I create a timer like this:
// CLOCKS_PER_SEC is number of clock ticks per second
clock_t future = ( (clock_t) seconds * CLOCKS_PER_SEC );
u->timerExpiration = clock() + future;
and then check for the expiration of said timer with:
clock_t ticksRightNow = clock();
if ( ticksRightNow > u->timerExpiration )
{
// timer expiration code here
}
The problem is that the ticksRightNow is _painfully_ slow. It should
be 100 ticks per second according to CLOCKS_PER_SEC. Its more
like 1 tick a second :)
I wrote a little test program outside of my game, and the ticksRightNow
was very fast, that is, was being incremented 100 times second.
So, I'm wondering if something in my game could be screwing up
the time. I do use glutTimerFunc(). Could that be goofing everything up?
I'd get rid of it, but the glutTimerFunc is was drives the openGL
display() function to update the screen. I've got lots of objects moving
around.
I've heard (read here) that glut can be problematic. Should I move to SDL?
// CLOCKS_PER_SEC is number of clock ticks per second
clock_t future = ( (clock_t) seconds * CLOCKS_PER_SEC );
u->timerExpiration = clock() + future;
and then check for the expiration of said timer with:
clock_t ticksRightNow = clock();
if ( ticksRightNow > u->timerExpiration )
{
// timer expiration code here
}
The problem is that the ticksRightNow is _painfully_ slow. It should
be 100 ticks per second according to CLOCKS_PER_SEC. Its more
like 1 tick a second :)
I wrote a little test program outside of my game, and the ticksRightNow
was very fast, that is, was being incremented 100 times second.
So, I'm wondering if something in my game could be screwing up
the time. I do use glutTimerFunc(). Could that be goofing everything up?
I'd get rid of it, but the glutTimerFunc is was drives the openGL
display() function to update the screen. I've got lots of objects moving
around.
I've heard (read here) that glut can be problematic. Should I move to SDL?