• Advertisement

Archived

This topic is now archived and is closed to further replies.

stupid timer (i took my moron pills today)

This topic is 6250 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I just don't seem to be able to think this afternoon. I'm sure it's just an order problem, but if you could take a look at my function and point me towards a solution it would be gratefully recieved The problem is that once started, the FPS display counter slowly decreases. the timer is initialised as follows: next_time = timeGetTime(); next_time += 1000; my updateFPS function is called just before my render routine in the main program loop. void UpdateFPS() { current_time = timeGetTime(); if (current_time >= next_time){ //fpsdisplay is converted to a string //and rendered in my render function FPSdisplay = FPScount FPScount=0; next_time = current_time; next_time += 1000; } else{ FPScount++; } } there's the code, it's very simple so i'm just being a moron today. Thanks; Prairie Edited by - Prairie on January 12, 2001 3:25:44 PM Edited by - Prairie on January 12, 2001 3:26:29 PM

Share this post


Link to post
Share on other sites
Advertisement
Is it impossible that it actually is slowing down?

Nope, your code is crap =) I made the same mistake when I first started fiddling with timers.

When you calculate the time to sleep, you need to sub off this cycles time.

SleepTime=1000;

while(....)
Sleep(SleepTime);
now = timeGetTime();
Elapsed = prevTime - now;
prevtime=now;
SleepTime = 1000 - Elapsed; //if it's negative the computer is too slow


Edited by - Magmai Kai Holmlor on January 12, 2001 7:51:17 PM

Share this post


Link to post
Share on other sites

  • Advertisement