Forget about my previous message.
Actually, the slow down was due to the following mistake (hope this will help
some of you) :
I was doing (pseudo code)
for ( ; game.running ; )
{
if ( SDL_PollEvent(&evt) > 0 )
{
/* Treat the next event in the queue */
}
SDL_Delay(5);
}
Instead of:
for ( ; game.running ; )
{
ticks = SDL_GetTicks();
while ( SDL_PollEvent(&evt) > 0 )
{
/* Treat the next event in the queue */
}
while ( SDL_GetTicks() - ticks < 5 )
;
}
(“while” instead of “if”, and use of SDL_GetTicks instead of SDL_Delay)
I’m not sure about the explaination: The"if" doesn’t empty the
event loop but get the next available event.
Hence the queue may grow in size and slow down the game.
The “while” empties the event loop by treating all the events which occured
since the previous frame.
Then, last thing, it seems that SDL_GetTicks() is more precise because it
takes in account the time needed to perform one game step while SDL_Delay()
just delays in every case.
Thank you for your advice
Julien_____________________________________________________________________________
Envoyez avec Yahoo! Mail. Une boite mail plus intelligente http://mail.yahoo.fr