From 228e58262e18f2ee61799bd86d0be718b1e31f9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 25 Mar 2024 21:02:10 +0100 Subject: [PATCH] EGL: Allow native access with defaults on Wayland The intent of enforcing GLFW_EGL_CONTEXT_API for EGL native access functions was to ensure that the application had requested the same context creation API at window creation time that it then attempted native access for. With the 3.4 ABI this both isn't true anymore, as a single binary may have multiple meanings of GLFW_NATIVE_CONTEXT_API, and is no longer necessary, since glfwGetPlatform provides enough information to disambiguate even without knowing what GLFW_PLATFORM was set to. This all leaves the requirement that the context creation API be GLFW_EGL_CONTEXT_API as just an unnecessary annoyance. Fixes #2518 --- CONTRIBUTORS.md | 1 + README.md | 2 ++ src/egl_context.c | 16 ++++++++++++---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index e04a68c3..1371aedb 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -33,6 +33,7 @@ video tutorials. - Nicolas Caramelli - David Carlier - Arturo Castro + - Jose Luis Cercós Pita - Chi-kwan Chan - Victor Chernyakin - TheChocolateOre diff --git a/README.md b/README.md index 4bccdb29..2718e45e 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,8 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: `glfwInit` would segfault on compositor with no seat (#2517) - [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface` - [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless` + - [EGL] Allowed native access on Wayland with `GLFW_CONTEXT_CREATION_API` set to + `GLFW_NATIVE_CONTEXT_API` (#2518) ## Contact diff --git a/src/egl_context.c b/src/egl_context.c index b901c1be..517c64cb 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -915,8 +915,12 @@ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle) if (window->context.source != GLFW_EGL_CONTEXT_API) { - _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); - return EGL_NO_CONTEXT; + if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND || + window->context.source != GLFW_NATIVE_CONTEXT_API) + { + _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); + return EGL_NO_CONTEXT; + } } return window->context.egl.handle; @@ -931,8 +935,12 @@ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle) if (window->context.source != GLFW_EGL_CONTEXT_API) { - _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); - return EGL_NO_SURFACE; + if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND || + window->context.source != GLFW_NATIVE_CONTEXT_API) + { + _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); + return EGL_NO_CONTEXT; + } } return window->context.egl.surface;