Sdl_init_timer

Does someone know why the timer works only once ?
Tested on RedHat Linux 6.2 with SDL-1.1.6

Regards

Nicolas

#include <stdio.h>
#include <SDL.h>

Uint32 MyTimer(Uint32 nextTime)
{
printf(“timer works !!!\n”);
return 0;
}

int main( int argv, char *argc[])
{

while (1){
SDL_Init(SDL_INIT_TIMER);

SDL_SetTimer(100,MyTimer);
SDL_Delay(500);
printf("Did you see the timer ?\n");
SDL_Quit();

}
return 0;
}

Does someone know why the timer works only once ?

Uint32 MyTimer(Uint32 nextTime)
{
printf(“timer works !!!\n”);
return 0;
}

You have to return the nextTime. :slight_smile:
You can actually return any time you want to be called next, and 0 means
"Don’t call this timer again".

See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software