From 9856979906a0236e2d4d4c071e9863d9ec0013dd Mon Sep 17 00:00:00 2001 From: IoI_xD Date: Sat, 8 Aug 2026 16:24:23 -0700 Subject: [PATCH] Dynload winmm, which is weird but it fixes vs2022 builds --- CMakeLists.txt | 8 +++++++- include/Mw/LowLevel.h | 6 ++++++ include/Mw/MachDep.h | 1 + src/abstract/time.c | 2 +- src/core.c | 14 +++++++++++++- 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b9882e4..8866686 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,7 +85,7 @@ if(MW_TRY_VULKAN) if(${Vulkan_FOUND}) set(MW_BUILD_VULKAN ON) message(STATUS "Vulkan widget has been enabled") - else() + else( message(WARNING "Vulkan widget has been disabled") endif() endif() @@ -471,6 +471,12 @@ if(MW_BUILD_VULKAN) PRIVATE MW_VULKAN ) +else() + target_compile_definitions( + Mw + PRIVATE + MW_VULKAN_NO_INCLUDE + ) endif() target_compile_definitions( diff --git a/include/Mw/LowLevel.h b/include/Mw/LowLevel.h index 0c53bd3..44c5b64 100644 --- a/include/Mw/LowLevel.h +++ b/include/Mw/LowLevel.h @@ -363,6 +363,12 @@ MWDECL int (*MwFLTextHeightWithText)(MwFLFont ttf, const char* text); MWDECL void* (*MwFLFontLoad)(unsigned char* data, unsigned int size, int px); MWDECL void (*MwFLFontFree)(void* handle); +#ifdef _WIN32 +void *MwLL_winmmLib; +long (__stdcall* MwLL_PFN_timeGetTime)(void); +unsigned int (__stdcall* MwLL_PFN_timeBeginPeriod)(unsigned int period); +#endif + #ifdef __cplusplus } #endif diff --git a/include/Mw/MachDep.h b/include/Mw/MachDep.h index 4c98b24..c791157 100644 --- a/include/Mw/MachDep.h +++ b/include/Mw/MachDep.h @@ -26,6 +26,7 @@ #ifdef _MILSKO #include #include +#include #ifndef GWLP_USERDATA #define GWLP_USERDATA GWL_USERDATA #define GWLP_WNDPROC GWL_WNDPROC diff --git a/src/abstract/time.c b/src/abstract/time.c index 59e9774..892cd32 100644 --- a/src/abstract/time.c +++ b/src/abstract/time.c @@ -2,7 +2,7 @@ #if defined(_WIN32) long MwTimeGetTick(void) { - return timeGetTime(); + return MwLL_PFN_timeGetTime(); } void MwTimeSleep(int ms) { diff --git a/src/core.c b/src/core.c index 9d149d8..1087577 100644 --- a/src/core.c +++ b/src/core.c @@ -1090,7 +1090,19 @@ int MwLibraryInit(void) { int i; #ifdef _WIN32 - timeBeginPeriod(10); + /* + There's no Windows configuration that Milsko supports that doesn't have winmm. + However, uhh, Visual Studio 2022. For some fucking reason. + Thanks for coming to my TED Talk. + */ + char winmmPath[MAX_PATH] = {0}; + GetSystemDirectory(winmmPath, MAX_PATH); + strcat_s(winmmPath, MAX_PATH, "\\winmm.dll"); + MwLL_winmmLib = LoadLibraryA(winmmPath); + MwLL_PFN_timeGetTime = (void *)GetProcAddress(MwLL_winmmLib, "timeGetTime"); + MwLL_PFN_timeBeginPeriod = (void *)GetProcAddress(MwLL_winmmLib, "timeBeginPeriod"); + + MwLL_PFN_timeBeginPeriod(10); #endif #ifdef USE_WAYLAND