Remove a timer created with SDL_AddTimer().
SDL_bool SDL_RemoveTimer(SDL_TimerID id);
id | the ID of the timer to remove |
Returns SDL_TRUE if the timer is removed or SDL_FALSE if the timer wasn't found.
This function is available since SDL 2.0.0.
// Function to be called after a certain time
void* name) {
Uint32 callback(Uint32 interval,
"Hello %s!\n", static_cast<char*>(name));
printf(
return 0;
}
...
// Initialize timer
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0)
...
// Set timer to 1 second
1000, callback, const_cast<char*>("SDL"));
SDL_TimerID timerID = SDL_AddTimer(
// Main loop
while(!quit) {
...
}
// Remove timer after main loop
SDL_RemoveTimer(timerID);