diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 89ca290bc..13f841a5b 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -3231,14 +3231,24 @@ static void I_InitFrameTime(const UINT64 now, const UINT32 cap) } double I_GetFrameTime(void) -{ +{ +#if defined(_WIN32) + LARGE_INTEGER now; + QueryPerformanceCounter(&now); + const UINT64 nowValue = now.QuadPart; +#else const UINT64 now = SDL_GetPerformanceCounter(); +#endif const UINT32 cap = R_GetFramerateCap(); if (cap != frame_rate) { // Maybe do this in a OnChange function for cv_fpscap? +#if defined(_WIN32) + I_InitFrameTime(nowValue, cap); +#else I_InitFrameTime(now, cap); +#endif } if (frame_rate == 0) @@ -3248,10 +3258,17 @@ double I_GetFrameTime(void) } else { +#if defined(_WIN32) + elapsed_frames += (nowValue - frame_epoch) / frame_frequency; +#else elapsed_frames += (now - frame_epoch) / frame_frequency; +#endif } - - frame_epoch = now; // moving epoch +#if defined(_WIN32) + frame_epoch = nowValue; // moving epoch +#else + frame_epoch = now; // moving epoch +#endif return elapsed_frames; } @@ -3260,8 +3277,13 @@ double I_GetFrameTime(void) // void I_StartupTimer(void) { - timer_frequency = SDL_GetPerformanceFrequency(); - +#if defined(_WIN32) + LARGE_INTEGER frequency; + QueryPerformanceFrequency(&frequency); + timer_frequency = frequency.QuadPart; +#else + timer_frequency = SDL_GetPerformanceFrequency(); +#endif I_InitFrameTime(0, R_GetFramerateCap()); elapsed_frames = 0.0; }