[SDL] Higher precision SDL_GetTicks()?

Tim Angus tim at ngus.net
Wed Feb 8 07:38:55 PST 2012


On 08/02/2012 15:27, Patrick Baggett wrote:
>     For Linux I just use:
>         struct timespec ts;
>         clock_gettime(CLOCK_MONOTONIC, &ts);
>         return (double) ts.tv_sec + ts.tv_nsec / 1000000000.0;
>
>
> Yep -- that's what's in SDL ;)

It does but the SDL_GetTicks implementation only returns millisecond 
accuracy. There is however a more accurate timer API added last year:

4279   6bd701987ba9   2011-03-25 14:45 -0700   slouken
   Added high resolution timing API: SDL_GetPerformanceCounter(), 
SDL_GetPerformanceFrequency()



More information about the SDL mailing list