[SDL] SDL event loop

David Olofson david at olofson.net
Sun Jan 30 08:41:48 PST 2005

On Sunday 30 January 2005 17.31, Franki wrote:
> when we handle input like this:
> SDL_Event event; 
> while (!done) {
>   while(SDL_PollEvent(&event)) {
>         .........
>   }
> }
> do we keep polling for next event over and over? Isn't this a busy 
waiting if
> there are not frequent inputs? 

Nope, not if you actually do anything in the outer while() loop.

Preferably, SDL_Flip() should result in a proper block on retrace sync 
for each rendered frame. If you want to be nice to the system and not 
burn all cycles on targets that can't retrace sync, you can throttle 
using SDL_GetTicks() and SDL_Delay().

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
|  Free/Open Source audio engine for games and multimedia.  |
| MIDI, modular synthesis, real time effects, scripting,... |
`-----------------------------------> http://audiality.org -'
   --- http://olofson.net --- http://www.reologica.se ---

More information about the SDL mailing list