summaryrefslogtreecommitdiff
path: root/src/video/win32_v.cpp
diff options
context:
space:
mode:
authorsean <43609023+spnda@users.noreply.github.com>2021-03-09 10:22:52 +0100
committerGitHub <noreply@github.com>2021-03-09 10:22:52 +0100
commit0464a50ab8f5f6c7028da80cb0d579cdfc84717a (patch)
tree2bacc79fb89d9140f7edcca56a5cf82a943f3524 /src/video/win32_v.cpp
parent64a8c38d2f08de5aee6315e5746cbe5ec73da9e3 (diff)
downloadopenttd-0464a50ab8f5f6c7028da80cb0d579cdfc84717a.tar.xz
Add: Display refresh rate game option (#8813)
Diffstat (limited to 'src/video/win32_v.cpp')
-rw-r--r--src/video/win32_v.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp
index 8030380ce..a802cdafa 100644
--- a/src/video/win32_v.cpp
+++ b/src/video/win32_v.cpp
@@ -916,6 +916,27 @@ void VideoDriver_Win32Base::EditBoxLostFocus()
SetCandidatePos(this->main_wnd);
}
+std::vector<int> VideoDriver_Win32Base::GetListOfMonitorRefreshRates()
+{
+ std::vector<int> rates = {};
+ EnumDisplayMonitors(nullptr, nullptr, [](HMONITOR hMonitor, HDC hDC, LPRECT rc, LPARAM data) -> BOOL {
+ auto &list = *reinterpret_cast<std::vector<int>*>(data);
+
+ MONITORINFOEX monitorInfo = {};
+ monitorInfo.cbSize = sizeof(MONITORINFOEX);
+ GetMonitorInfo(hMonitor, &monitorInfo);
+
+ DEVMODE devMode = {};
+ devMode.dmSize = sizeof(DEVMODE);
+ devMode.dmDriverExtra = 0;
+ EnumDisplaySettings(monitorInfo.szDevice, ENUM_CURRENT_SETTINGS, &devMode);
+
+ if (devMode.dmDisplayFrequency != 0) list.push_back(devMode.dmDisplayFrequency);
+ return true;
+ }, reinterpret_cast<LPARAM>(&rates));
+ return rates;
+}
+
Dimension VideoDriver_Win32Base::GetScreenSize() const
{
return { static_cast<uint>(GetSystemMetrics(SM_CXSCREEN)), static_cast<uint>(GetSystemMetrics(SM_CYSCREEN)) };