Jump to content
  • Advertisement
Sign in to follow this  

SDL_Delay

This topic is 3618 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 noticed by putting SDL_Delay(10) in my main game loop I decrease CPU use from 100 to 60 percent, but will this have negative effects on my game, such as mis-timed counters?

Share this post


Link to post
Share on other sites
Advertisement
It could, depending on the resolution of your timers.

Then again, you shouldn't count on timers being entirely accurate even when CPU usage is 100%. Timers are typically implemented as events which are scheduled on the system's timer interrupt, which is generally around every 10ms. So a 10ms timer could end up taking nearly 20ms due to timing. A 500ms timer can take somewhere between 490ms and 510ms. Either way a reasonably acceptable deviation.

If you need delay precision in the order of magnitude of dozens of ms, I still find polling a high frequency counter the best solution. Does mean you get 100% cpu usage though.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!