]> git.lizzy.rs Git - minetest.git/commitdiff
Enable high-res timers on Windows
authorsfan5 <sfan5@live.de>
Sat, 22 Jan 2022 19:20:43 +0000 (20:20 +0100)
committersfan5 <sfan5@live.de>
Thu, 27 Jan 2022 21:30:02 +0000 (22:30 +0100)
This should fix issues like #11891, caused by the fps limiting
code being unable to operate correctly.

src/CMakeLists.txt
src/porting.cpp

index ed0929564a0502dbdc2b6f0f74d6ed9d31ffa2ba..7f207244cae7e9fd4fcfb7806e5ea406de5cace6 100644 (file)
@@ -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")
 
index 4c87bddee0cf0b2a65be7a047262fa68d928af46..f78de39ad7ed70d3a8d571d25e50eefb0c0dd863 100644 (file)
@@ -35,6 +35,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
        #include <algorithm>
        #include <shlwapi.h>
        #include <shellapi.h>
+       #include <mmsystem.h>
 #endif
 #if !defined(_WIN32)
        #include <unistd.h>
@@ -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;