- The interpolation code needs the current frame rate so it must be retrieved.

This commit is contained in:
Christoph Oelckers 2020-01-03 20:13:44 +01:00
parent 064a453b41
commit f2cc7e3636
2 changed files with 21 additions and 0 deletions

View File

@ -59,6 +59,7 @@ extern "C" {
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}
void GetRefreshRate(HWND hWnd);
EXTERN_CVAR(Int, vid_defwidth)
EXTERN_CVAR(Int, vid_defheight)
@ -339,6 +340,7 @@ void SystemBaseFrameBuffer::PositionWindow(bool fullscreen, bool initialcall)
}
m_Fullscreen = fullscreen;
SetSize(GetClientWidth(), GetClientHeight());
GetRefreshRate(Window);
}
//==========================================================================

View File

@ -330,6 +330,22 @@ bool CallHook(FInputDevice *device, HWND hWnd, UINT message, WPARAM wParam, LPAR
return device->WndProcHook(hWnd, message, wParam, lParam, result);
}
void GetRefreshRate(HWND hWnd)
{
HMONITOR moni = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
MONITORINFOEXA moninf;
moninf.cbSize = sizeof(moninf);
if (GetMonitorInfoA(moni, (LPMONITORINFO)&moninf))
{
DEVMODEA dm;
dm.dmSize = sizeof(DEVMODEA);
if (EnumDisplaySettingsA(moninf.szDevice, ENUM_CURRENT_SETTINGS, &dm))
{
refreshfreq = dm.dmDisplayFrequency;
}
}
}
LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
LRESULT result;
@ -417,6 +433,7 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
break;
case WM_SETFOCUS:
GetRefreshRate(hWnd);
I_CheckNativeMouse (false, false); // This cannot call the event handler. Doing it from here is unsafe.
break;
@ -461,6 +478,8 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
break;
case WM_DISPLAYCHANGE:
GetRefreshRate(hWnd);
// fall through
case WM_STYLECHANGED:
return DefWindowProc(hWnd, message, wParam, lParam);