THIS PAGE IS A WORK IN PROGRESS ... Please make edits to this page to improve it!
This macro compares 32 bit tick values provided by SDL_GetTicks. Because the SDL_GetTicks value is 32 bits in milliseconds, it will wrap approximately every 49 days. This handles the rollover condition appropriately, ensuring that this is safe for events that happen significantly faster than every 49 days.
To completely avoid edge cases associated with monotonically increasing time counts within a human lifespan, you're encouraged to use SDL_GetTicks64 instead. Do not use this macro with the output of SDL_GetTicks64.
SDL_TICKS_PASSED(A, B)
A |
the first ticks values |
B |
the second ticks values |
Returns "true" if A has passed B.
/* if you want to wait 100 ms, you could do this: */
100;
Uint32 timeout = SDL_GetTicks() + while (!SDL_TICKS_PASSED(SDL_GetTicks(), timeout)) {
/* ... do work until timeout has elapsed */
}
This function is available since SDL 2.0.1.
CategoryAPI, CategoryTimer, CategoryDraft