From f2cc7e36369f36e26d18ee7ab34849a15bde03e9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 3 Jan 2020 20:13:44 +0100 Subject: [PATCH] - The interpolation code needs the current frame rate so it must be retrieved. --- source/platform/win32/base_sysfb.cpp | 2 ++ source/platform/win32/i_input.cpp | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/source/platform/win32/base_sysfb.cpp b/source/platform/win32/base_sysfb.cpp index b185d33b9..ade8299b2 100644 --- a/source/platform/win32/base_sysfb.cpp +++ b/source/platform/win32/base_sysfb.cpp @@ -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); } //========================================================================== diff --git a/source/platform/win32/i_input.cpp b/source/platform/win32/i_input.cpp index b0083b30d..53e413f3a 100644 --- a/source/platform/win32/i_input.cpp +++ b/source/platform/win32/i_input.cpp @@ -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);