sdlAddTimer function
- int interval,
- Pointer<
NativeFunction< callback,SdlTimerCallback> > - Pointer<
NativeType> userdata
Call a callback function at a future time.
The callback function is passed the current timer interval and the user supplied parameter from the SDL_AddTimer() call and should return the next timer interval. If the value returned from the callback is 0, the timer is canceled and will be removed.
The callback is run on a separate thread, and for short timeouts can potentially be called before this function returns.
Timers take into account the amount of time it took to execute the callback. For example, if the callback took 250 ms to execute and returned 1000 (ms), the timer would only wait another 750 ms before its next iteration.
Timing may be inexact due to OS scheduling. Be sure to note the current time with SDL_GetTicksNS() or SDL_GetPerformanceCounter() in case your callback needs to adjust for variances.
\param interval the timer delay, in milliseconds, passed to callback
.
\param callback the SDL_TimerCallback function to call when the specified
interval
elapses.
\param userdata a pointer that is passed to callback
.
\returns a timer ID or 0 on failure; call SDL_GetError() for more
information.
\threadsafety It is safe to call this function from any thread.
\since This function is available since SDL 3.1.3.
\sa SDL_AddTimerNS \sa SDL_RemoveTimer
extern SDL_DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *userdata)
Implementation
int sdlAddTimer(
int interval,
Pointer<NativeFunction<SdlTimerCallback>> callback,
Pointer<NativeType> userdata) {
final sdlAddTimerLookupFunction = libSdl3.lookupFunction<
Uint32 Function(
Uint32 interval,
Pointer<NativeFunction<SdlTimerCallback>> callback,
Pointer<NativeType> userdata),
int Function(
int interval,
Pointer<NativeFunction<SdlTimerCallback>> callback,
Pointer<NativeType> userdata)>('SDL_AddTimer');
return sdlAddTimerLookupFunction(interval, callback, userdata);
}