Jump to content
  • Advertisement
Sign in to follow this  
Nodlehs

Timing functions and application

This topic is 4832 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

Question about timing. 1. Under linux using C, what functions are an accurate and reliable way to keep timing for game loops? 2. What is a good way to wait for the next game loop? Especially in respect with being friendly to other processes. 3. What are some typical game loop lengths? .5/1/2/5 seconds? I assume its based on the type of game, if so, what are common ones for say a mud, fps, rpg, mmorpg? I am starting in on a generic C timing library which will be used in linux, and want it to be flexible enough for a fast or slow game loop game.

Share this post


Link to post
Share on other sites
Advertisement
There is sleep() and usleep() in Linux. usleep() is for micro-seconds i think and sleep is for seconds.

ace

Share this post


Link to post
Share on other sites
On my BSD machine, there are man pages for sleep, usleep [microsleep] and even nanosleep. All listed as C standard functions. I'm a little skeptical of how standard that nanosleep is, or how accurate it gets in real life.

In my timer I use for windows code the default 'tick' of the timer is 33ms. Rendering goes as fast as possible, even though the app's timer isn't incremented any faster than 30 [and some change] times per second.

Share this post


Link to post
Share on other sites
Still wondering about functions that are accurate and reliable to get time in C under linux. I was looking at gettimeofday but don't know if that is good enough.
If there is a better way I would love to hear it.

Share this post


Link to post
Share on other sites
Read to understand what accuracy is and what you are actually looking for.
gettimeofday is fine for game needs; if POSIX realtime extensions are available, clock_gettime's interface offers the potential for even higher resolution.

Share this post


Link to post
Share on other sites
Thanks for that link Jan, lots of good info there, and I do have POSIX extensions available so I will check out clock_gettime as well.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!