From 7aea5cb88f9a8cc9f9ca52ecd4d13cfd7ab16e69 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sat, 22 Jan 2022 20:20:43 +0100 Subject: [PATCH] Enable high-res timers on Windows This should fix issues like #11891, caused by the fps limiting code being unable to operate correctly. --- src/CMakeLists.txt | 2 +- src/porting.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ed0929564..7f207244c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -268,7 +268,7 @@ if(WIN32) else() # Probably MinGW = GCC set(PLATFORM_LIBS "") endif() - set(PLATFORM_LIBS ws2_32.lib version.lib shlwapi.lib ${PLATFORM_LIBS}) + set(PLATFORM_LIBS ws2_32.lib version.lib shlwapi.lib winmm.lib ${PLATFORM_LIBS}) set(EXTRA_DLL "" CACHE FILEPATH "Optional paths to additional DLLs that should be packaged") diff --git a/src/porting.cpp b/src/porting.cpp index 4c87bddee..f78de39ad 100644 --- a/src/porting.cpp +++ b/src/porting.cpp @@ -35,6 +35,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include #include + #include #endif #if !defined(_WIN32) #include @@ -766,6 +767,9 @@ bool open_directory(const std::string &path) inline double get_perf_freq() { + // Also use this opportunity to enable high-res timers + timeBeginPeriod(1); + LARGE_INTEGER freq; QueryPerformanceFrequency(&freq); return freq.QuadPart; -- 2.44.0