Could somebody be so nice and help me with SDL’s timers.
I cannot figure out how to create a timer (SDL_AddTimer, SDL_SetTimer)
and a callback function. Well, maybe more exactly my problem is that I
cannot understand how to make a callback function with parameters.
I’m trying to do something like (it should switch something on and off
on a regular interval).
// the callbackfunction
SDL_TimerCallback Switch( bool *on )
{
}
…
// the timer
timer = AddTimer( 1000, Switch(…
This is the description of SDL_AddTimer from the docs
SDL_AddTimer – Add a timer which
will call a callback after the
specified number of milliseconds
has elapsed.
Synopsis
#include "SDL.h"
SDL_TimerID SDL_AddTimer(Uint32 interval,
SDL_NewTimerCallback callback, void *param);
Callback
/* type definition for the "new"
timer callback function */
typedef Uint32 (*SDL_NewTimerCallback)
(Uint32 interval, void *param);
Thank you very much for any working example and explanation of
callbacks!!!
Z.