[SDL] Timing issues - SDL_Delay

CptAJ antonioetayo at gmail.com
Tue Jul 17 20:22:48 PDT 2007


I'm having some trouble with SDL_Delay. I'm trying to limit framerate for a 
little tech-demo practice thing I'm doing. Now, this works perfectly:

==============
while (fps.stop() < ( 1000 / FPS ) ){ //fps.stop() being part of my timer
	//wait                            // class it returns the enlapsed time 
}                                     //between start() and stop().
==============

Of course, this uses up all the CPU time available and skips when anything
 else happens. None of which are acceptable. So I used this instead:

==============
time = 33 - fps.stop();  //Time being Uint32
if ( time > 0 ){
	SDL_Delay( time );
}
==============

This is when it all breaks down. The delay has a very unpredictable behaviour.
It starts working just fine and with no speed variations... then the animation
just stops and none of the events respond. Clearly stuck in the delay function.

So what gives? Am I doing anything wrong?

Heres the whole code from the modified version (SDL_Delay one)
http://pastebin.com/m3719631

Thanks



More information about the SDL mailing list