Jump to content
  • Advertisement
Sign in to follow this  
Vuk Samotnjak

OpenGL OpenGL + SDL, CPU usage.

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

Right now I use "SDL_Delay(1)" to prevent my program from eating up 100% of the CPU at all times. This seemed to work initially, but soon after I noticed that at certain time intervals my program would hit a "slow patch" -> this would happen about every 20 seconds or so. From the info that I looked up on my own, It turns out that "SDL_Delay(1)" isn't really an "exact" delay, because it seems to be subject to regular OS scheduling interrupts, which means it's waiting "at least" 1 millisecond + whatever else the OS needs to add on to that delay. So my questions: 1 - Is there a function similar to "SDL_Delay()" that initiates an exact delay independent of the OS scheduler? 2 - What is the most common/efficient method used to prevent CPU hogging? 3 - Is there a way to prevent CPU hogging and still hold a smooth framerate, because even though it's 1 millisecond in this case, the slowdown is quite noticeable in contrast to how things ran when my program used 100% of the CPU -> and I don't see why that should be the case when my refresh rate is at 60Hz. In theory I shouldn't be able to notice any changes, right?

Share this post


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

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!