add it here too

This commit is contained in:
Alug committed 2024-02-11 06:38:45 +01:00
1 parent 0272dd4c24
commit cb2b8f2e7c
1 file changed
+27 -5
+27 -5
View File
@@ -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;
}