diff --git a/glfw/cocoa_init.m b/glfw/cocoa_init.m index bdad46aa8..5252614b7 100644 --- a/glfw/cocoa_init.m +++ b/glfw/cocoa_init.m @@ -529,6 +529,32 @@ static GLFWapplicationwillfinishlaunchingfun finish_launching_callback = NULL; @end +////////////////////////////////////////////////////////////////////////// +////// GLFW internal API ////// +////////////////////////////////////////////////////////////////////////// + +void* _glfwLoadLocalVulkanLoaderNS(void) +{ + CFBundleRef bundle = CFBundleGetMainBundle(); + if (!bundle) + return NULL; + + CFURLRef url = + CFBundleCopyAuxiliaryExecutableURL(bundle, CFSTR("libvulkan.1.dylib")); + if (!url) + return NULL; + + char path[PATH_MAX]; + void* handle = NULL; + + if (CFURLGetFileSystemRepresentation(url, true, (UInt8*) path, sizeof(path) - 1)) + handle = _glfw_dlopen(path); + + CFRelease(url); + return handle; +} + + ////////////////////////////////////////////////////////////////////////// ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// diff --git a/glfw/cocoa_platform.h b/glfw/cocoa_platform.h index 226950a3f..bcad82fce 100644 --- a/glfw/cocoa_platform.h +++ b/glfw/cocoa_platform.h @@ -239,6 +239,8 @@ void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor); float _glfwTransformYNS(float y); +void* _glfwLoadLocalVulkanLoaderNS(void); + void _glfwClearDisplayLinks(void); void _glfwRestartDisplayLinks(void); void _glfwDispatchTickCallback(void); diff --git a/glfw/vulkan.c b/glfw/vulkan.c index 3f5ba0161..fe8485210 100644 --- a/glfw/vulkan.c +++ b/glfw/vulkan.c @@ -57,6 +57,8 @@ bool _glfwInitVulkan(int mode) _glfw.vk.handle = _glfw_dlopen("vulkan-1.dll"); #elif defined(_GLFW_COCOA) _glfw.vk.handle = _glfw_dlopen("libvulkan.1.dylib"); + if (!_glfw.vk.handle) + _glfw.vk.handle = _glfwLoadLocalVulkanLoaderNS(); #else _glfw.vk.handle = _glfw_dlopen("libvulkan.so.1"); #endif