SDL use the QPF on windows but
currently SDL have precision of 10 ms because of SDL Header files.
But you can change this values in your
include/sdl_timer.h file.
thats the defaults
/* This is the OS scheduler timeslice, in milliseconds */
#define SDL_TIMESLICE 10
/* This is the maximum resolution of the SDL timer on all platforms /
#define TIMER_RESOLUTION 10 / Experimentally determined */
and here is code of get ticks for win32.seem easy to add a SDL command that
return better accuracy.
Uint32 SDL_GetTicks(void)
{
DWORD now, ticks;
#ifndef USE_GETTICKCOUNT
LARGE_INTEGER hires_now;
#endif
#ifdef USE_GETTICKCOUNT
now = GetTickCount();
#else
if (hires_timer_available)
{
QueryPerformanceCounter(&hires_now);
hires_now.QuadPart -= hires_start_ticks.QuadPart;
hires_now.QuadPart *= 1000;
hires_now.QuadPart /= hires_ticks_per_second.QuadPart;
return (DWORD)hires_now.QuadPart;
}
else
{
now = timeGetTime();
}
#endif
if ( now < start ) {
ticks = (TIME_WRAP_VALUE-start) + now;
} else {
ticks = (now - start);
}
return(ticks);
}
I’ve been using SDL_GetTicks() in my program to start work on a simple
physics implementation.
This only has millisecond accuracy to my understanding.
Is there anything similar to the Win32 function QueryPerformanceCounter in
SDL, or are there plans to implement it in SDL?
Looks like this might be a cross platform solution, but it looks kind of
nasty: http://www.devmaster.net/forums/showthread.php?t=1407
Here, one of the posters makes reference to a call to
QueryPeformanceCounter within the SDL source code:
High resolution timer - General and Gameplay Programming - GameDev.net
Are there any other reasonable options for cross platform high-performance
timers?
Always respect knowledge.
Regards