Jump to content
  • Advertisement


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


stupid timer (i took my moron pills today)

This topic is 6522 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
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.


now = timeGetTime();
Elapsed = 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

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!