From dd412894bb949f92912f238e4109586e05dc3afb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20W=C5=82odarczyk?= Date: Tue, 19 May 2026 10:45:18 +0200 Subject: [PATCH] Add macOS ARM64 build support Three small source tweaks that let the OpenGL renderer build and run on Apple Silicon without affecting the Windows/Linux paths: - stdafx.h: use GLM_FORCE_NEON on ARM64 instead of GLM_FORCE_AVX2. AVX2 pulls , which clang on ARM64 rejects because the x86 intrinsics are unimplemented. - utilities/utilities.cpp: provide an Apple libc++ fallback for Now() using localtime_r + strftime, since std::chrono::current_zone() is not yet implemented there. - audio/audio.h: prefer Khronos-style headers when they are on the include path (brew openal-soft) and fall back to the deprecated Apple OpenAL.framework's only otherwise. --- audio/audio.h | 2 +- stdafx.h | 4 ++++ utilities/utilities.cpp | 9 +++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/audio/audio.h b/audio/audio.h index d84d54a1..613c62c7 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -9,7 +9,7 @@ http://mozilla.org/MPL/2.0/. #pragma once -#ifdef __APPLE__ +#if defined(__APPLE__) && !__has_include() #include #include #else diff --git a/stdafx.h b/stdafx.h index fec02883..c3ba0716 100644 --- a/stdafx.h +++ b/stdafx.h @@ -89,7 +89,11 @@ #define glfwFocusWindow(w) #endif +#if defined(__aarch64__) || defined(__arm64__) +#define GLM_FORCE_NEON +#else #define GLM_FORCE_AVX2 +#endif #define GLM_FORCE_SWIZZLE #define GLM_ENABLE_EXPERIMENTAL #define GLM_FORCE_CTOR_INIT diff --git a/utilities/utilities.cpp b/utilities/utilities.cpp index fc1d7a53..81386c2c 100644 --- a/utilities/utilities.cpp +++ b/utilities/utilities.cpp @@ -39,9 +39,18 @@ bool DebugTractionFlag = false; std::string Now() { +#if defined(__APPLE__) + auto t = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); + std::tm tm{}; + localtime_r(&t, &tm); + char buf[64]; + std::strftime(buf, sizeof(buf), "%c", &tm); + return std::string(buf); +#else auto now = std::chrono::system_clock::now(); auto local = std::chrono::current_zone()->to_local(now); return std::format("{:%c}", local); +#endif } // zwraca różnicę czasu