[SDL] reducing cpu power

Started by
1 comment, last by Rakshasa 14 years, 6 months ago
Hello. How do I reduce CPU power on my program? When I use

while(quit)
{
 while(SDL_PollEvent(&event)
 {
  ...
 }
}
CPU on that program goes to 48-50%. How do I achieve 0% while nothing is happening?
Advertisement
I don't really know SDL, but it appears that SDL_WaitEvent does what you want - waits until an event (mouse move, keyboard press, etc) before returning. Note that this implies that it's also not updating the screen while nothing is happening, but presumably you already knew that...
SDL_Delay(a few milliseconds); at the end of the outer while loop should work wonders. Reduces the cpu use to near zero, but doesn't busy-wait until something happens.
Doesn't matter how much you lose as long as you make sure the winner loses enough blood.

This topic is closed to new replies.

Advertisement