add it here too
This commit is contained in:
1 parent
31964b34af
commit
a747e9c7c0
1 file changed
+27
-5
+27
-5
@@ -3203,14 +3203,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)
|
||||
@@ -3220,10 +3230,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;
|
||||
}
|
||||
|
||||
@@ -3232,8 +3249,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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user