• Advertisement
Sign in to follow this  

[SDL] how to conserve CPU cycles

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

Hey, i'm working with SDLnet now and since i have a main loop it makes sense that CPU % is at 100%. But i'm asking if there is an alternative to main loops? btw, i'm using TCP protocol and the problem is in the server.

Share this post


Link to post
Share on other sites
Advertisement
hi,

there was a thread about SDL CPU Usage, have a look on it,
perhaps it could help:


http://www.gamedev.net/community/forums/topic.asp?topic_id=368222



Marc

Share this post


Link to post
Share on other sites
ah, so basicly there is no other option than delay?
although, it's perfect for a kind of server i'm having.

Share this post


Link to post
Share on other sites
SDL_WaitEvent might help out in the case of an editor like the post above where you want the application to react to events instead of polling for them and do other things in the mean time. In the case of a server though depending on what kind of reaction time you are wanting SDL_Delay may be the right choice in that case.

Personally I would check if I have any current connections, if not then I would increase the delay to something close to 1 second since there is no real reason to update other than catching new connections. If I did then I would make the delay 0 or something small to cap the frame rate.

One thing of note though, I think SDL_Delay has different resolutions on different systems.
Quote:
Note: Count on a delay granularity of at least 10 ms. Some platforms have shorter clock ticks but this is the most common.

Check the SDL_Delay documentation for more information.

Share this post


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

  • Advertisement