Skip to content

Commit

Permalink
Enable high-res timers on Windows
Browse files Browse the repository at this point in the history
This should fix issues like #11891, caused by the fps limiting
code being unable to operate correctly.
  • Loading branch information
sfan5 committed Jan 27, 2022
1 parent 058846d commit 7aea5cb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Expand Up @@ -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")

Expand Down
4 changes: 4 additions & 0 deletions src/porting.cpp
Expand Up @@ -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>
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 7aea5cb

Please sign in to comment.