diff options
author | Sam Lantinga <slouken@libsdl.org> | 2013-10-20 20:42:55 -0700 |
---|---|---|
committer | Sam Lantinga <slouken@libsdl.org> | 2013-10-20 20:42:55 -0700 |
commit | d545c7b4721f821d1d2a896ee0573ba09d17636e (patch) | |
tree | c6ec6a6edabed23c55f6be1ddfe4f0938c9d6299 /include/SDL_timer.h | |
parent | eb3407a3b66d82e8a6ed2c8d8f143c12141c2f5b (diff) | |
download | sdl-d545c7b4721f821d1d2a896ee0573ba09d17636e.tar.gz |
Added a macro SDL_TICKS_PASSED() to correctly compare two 32-bit tick values.
Went through the code and used the macro and fixed a couple places that were using incorrect timestamp comparisons.
Diffstat (limited to 'include/SDL_timer.h')
-rw-r--r-- | include/SDL_timer.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/SDL_timer.h b/include/SDL_timer.h index e065cf4f9..28ab415b4 100644 --- a/include/SDL_timer.h +++ b/include/SDL_timer.h @@ -45,6 +45,17 @@ extern "C" { extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); /** + * \brief Compare SDL ticks values, and return true if A has passed B + * + * e.g. 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 + * } + */ +#define SDL_TICKS_PASSED(A, B) ((Sint32)((B) - (A)) <= 0) + +/** * \brief Get the current value of the high resolution counter */ extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceCounter(void); |