21#include "../../SDL_internal.h"
23#ifdef SDL_TIMER_WINDOWS
25#include "../../core/windows/SDL_windows.h"
33static DWORD
start = 0;
34static BOOL ticks_started =
FALSE;
37static BOOL hires_timer_available;
39static LARGE_INTEGER hires_start_ticks;
41static LARGE_INTEGER hires_ticks_per_second;
44SDL_SetSystemTimerResolution(
const UINT uPeriod)
47 static UINT timer_period = 0;
49 if (uPeriod != timer_period) {
51 timeEndPeriod(timer_period);
54 timer_period = uPeriod;
57 timeBeginPeriod(timer_period);
64SDL_TimerResolutionChanged(
void *userdata,
const char *
name,
const char *oldValue,
const char *hint)
74 if (uPeriod || oldValue != hint) {
75 SDL_SetSystemTimerResolution(uPeriod);
90 SDL_TimerResolutionChanged,
NULL);
96 if (QueryPerformanceFrequency(&hires_ticks_per_second) ==
TRUE) {
97 hires_timer_available =
TRUE;
98 QueryPerformanceCounter(&hires_start_ticks);
100 hires_timer_available =
FALSE;
102 start = timeGetTime();
111 SDL_TimerResolutionChanged,
NULL);
113 SDL_SetSystemTimerResolution(0);
123 LARGE_INTEGER hires_now;
125 if (!ticks_started) {
129 if (hires_timer_available) {
130 QueryPerformanceCounter(&hires_now);
132 hires_now.QuadPart -= hires_start_ticks.QuadPart;
133 hires_now.QuadPart *= 1000;
134 hires_now.QuadPart /= hires_ticks_per_second.QuadPart;
136 return (DWORD) hires_now.QuadPart;
143 return (now -
start);
151 if (!QueryPerformanceCounter(&
counter)) {
160 LARGE_INTEGER frequency;
162 if (!QueryPerformanceFrequency(&frequency)) {
165 return frequency.QuadPart;
183#if defined(__WINRT__) && defined(_MSC_FULL_VER) && (_MSC_FULL_VER <= 180030723)
184 static HANDLE
mutex = 0;
186 mutex = CreateEventEx(0, 0, 0, EVENT_ALL_ACCESS);
190 if (!ticks_started) {
#define SDL_DelHintCallback
#define SDL_GetPerformanceCounter
#define SDL_AddHintCallback
#define SDL_HINT_TIMER_RESOLUTION
A variable that controls the timer resolution, in milliseconds.
GLuint const GLchar * name
Uint32 SDL_GetTicks(void)
Get the number of milliseconds since the SDL library initialization.
Uint64 SDL_GetPerformanceFrequency(void)
Get the count per second of the high resolution counter.