From 269f294d1910fef9b5d83d5d2d86a83e619e5776 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Sat, 23 May 2020 00:27:41 +0200 Subject: [PATCH] Use CALayer instead of NSView for EGLNativeWindowType From upstream: https://github.com/glfw/glfw/commit/91eebe922de06a3ed4ba6622686c436c7941aa63. --- glfw/cocoa_platform.h | 2 +- glfw/cocoa_window.m | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/glfw/cocoa_platform.h b/glfw/cocoa_platform.h index f47fa12de..476ac4a41 100644 --- a/glfw/cocoa_platform.h +++ b/glfw/cocoa_platform.h @@ -104,7 +104,7 @@ typedef VkResult (APIENTRY *PFN_vkCreateMetalSurfaceEXT)(VkInstance,const VkMeta #define _glfw_dlclose(handle) dlclose(handle) #define _glfw_dlsym(handle, name) dlsym(handle, name) -#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->ns.view) +#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->ns.layer) #define _GLFW_EGL_NATIVE_DISPLAY EGL_DEFAULT_DISPLAY #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS ns diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index 374f0683b..7a2654eb8 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -1460,6 +1460,11 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, } else if (ctxconfig->source == GLFW_EGL_CONTEXT_API) { + // EGL implementation on macOS use CALayer* EGLNativeWindowType so we + // need to get the layer for EGL window surface creation. + [window->ns.view setWantsLayer:YES]; + window->ns.layer = [window->ns.view layer]; + if (!_glfwInitEGL()) return false; if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))