From 66822c13fde5b87cbc9d40f41751a0e1a9922cdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 24 Jul 2023 16:39:34 +0200 Subject: [PATCH] Platform: don't let GLFW change CWD on Apple platforms. What a weird default. --- doc/changelog.dox | 3 +++ src/Magnum/Platform/GlfwApplication.cpp | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index 6e3929f4e..93d77e7b8 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -664,6 +664,9 @@ See also: prevents computer from entering a power-saving mode while the application is running, as that's generally undesirable for regular GUI applications. See @ref Platform-Sdl2Application-usage-power for more information. +- @ref Platform::GlfwApplication now overrides GLFW's default behavior that + changes current working directory to `Resources/` in the app bundle on + Apple platforms. @subsubsection changelog-latest-changes-scenegraph SceneGraph library diff --git a/src/Magnum/Platform/GlfwApplication.cpp b/src/Magnum/Platform/GlfwApplication.cpp index 2e7c636e5..fb4d49af0 100644 --- a/src/Magnum/Platform/GlfwApplication.cpp +++ b/src/Magnum/Platform/GlfwApplication.cpp @@ -93,7 +93,14 @@ GlfwApplication::GlfwApplication(const Arguments& arguments, NoCreateT): glfwSetErrorCallback([](int, const char* const description) { Error{} << description; }); - + #ifdef CORRADE_TARGET_APPLE + /* Don't change current working directory to Resources/ in the app bundle + on Apple platforms. Not sure why this would be done only on a single + platform of all, I guess it was for compatibility with SDL1 (and then + SDL2+ doesn't do this anymore but in GLFW it stays)? + https://wiki.libsdl.org/SDL2/README/macos#working-directory */ + glfwInitHint(GLFW_COCOA_CHDIR_RESOURCES, false); + #endif if(!glfwInit()) { Error() << "Could not initialize GLFW"; std::exit(8);