.\" This manpage content is licensed under Creative Commons .\" Attribution 4.0 International (CC BY 4.0) .\" https://creativecommons.org/licenses/by/4.0/ .\" This manpage was generated from SDL's wiki page for SDL_AddTimer: .\" https://wiki.libsdl.org/SDL_AddTimer .\" Generated with SDL/build-scripts/wikiheaders.pl .\" revision SDL-3.1.0 .\" Please report issues in this manpage's content at: .\" https://github.com/libsdl-org/sdlwiki/issues/new .\" Please report issues in the generation of this manpage from the wiki at: .\" https://github.com/libsdl-org/SDL/issues/new?title=Misgenerated%20manpage%20for%20SDL_AddTimer .\" SDL can be found at https://libsdl.org/ .de URL \$2 \(laURL: \$1 \(ra\$3 .. .if \n[.g] .mso www.tmac .TH SDL_AddTimer 3 "SDL 3.1.0" "SDL" "SDL3 FUNCTIONS" .SH NAME SDL_AddTimer \- Call a callback function at a future time\[char46] .SH SYNOPSIS .nf .B #include \(dqSDL3/SDL.h\(dq .PP .BI "SDL_TimerID SDL_AddTimer(Uint32 interval, .BI " SDL_TimerCallback callback, .BI " void *param); .fi .SH DESCRIPTION If you use this function, you must pass .BR .BR SDL_INIT_TIMER to .BR SDL_Init ()\[char46] The callback function is passed the current timer interval and the user supplied parameter from the .BR SDL_AddTimer () call and should return the next timer interval\[char46] If the value returned from the callback is 0, the timer is canceled\[char46] The callback is run on a separate thread\[char46] Timers take into account the amount of time it took to execute the callback\[char46] 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\[char46] Timing may be inexact due to OS scheduling\[char46] Be sure to note the current time with .BR SDL_GetTicksNS () or .BR SDL_GetPerformanceCounter () in case your callback needs to adjust for variances\[char46] .SH FUNCTION PARAMETERS .TP .I interval the timer delay, in milliseconds, passed to .BR callback .TP .I callback the .BR SDL_TimerCallback function to call when the specified .BR interval elapses .TP .I param a pointer that is passed to .BR callback .SH RETURN VALUE Returns a timer ID or 0 if an error occurs; call .BR SDL_GetError () for more information\[char46] .SH AVAILABILITY This function is available since SDL 3\[char46]0\[char46]0\[char46] .SH SEE ALSO .BR SDL_RemoveTimer (3)