SDL Wiki

Draft

THIS PAGE IS A WORK IN PROGRESS ... Please make edits to this page to improve it!

SDL_TICKS_PASSED

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.

Syntax

SDL_TICKS_PASSED(A, B)

Function Parameters

A

the first ticks values

B

the second ticks values

Return Value

Returns "true" if A has passed B.

Code Examples

/* if you want to wait 100 ms, you could do this: */
Uint32 timeout = SDL_GetTicks() + 100;
while (!SDL_TICKS_PASSED(SDL_GetTicks(), timeout)) {
    /* ... do work until timeout has elapsed */
}

Version

This function is available since SDL 2.0.1.

SDL_GetTicks

CategoryAPI, CategoryTimer, CategoryDraft


[ edit | delete | history | feedback | raw ]

[ front page | index | search | recent changes | git repo | offline html ]

All wiki content is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).
Wiki powered by ghwikipp.