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
This commit is contained in:
Camilla Löwy 2024-03-25 21:02:10 +01:00
parent 3573c5a890
commit 228e58262e
3 changed files with 15 additions and 4 deletions

View File

@ -33,6 +33,7 @@ video tutorials.
- Nicolas Caramelli
- David Carlier
- Arturo Castro
- Jose Luis Cercós Pita
- Chi-kwan Chan
- Victor Chernyakin
- TheChocolateOre

View File

@ -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

View File

@ -914,10 +914,14 @@ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle)
assert(window != NULL);
if (window->context.source != GLFW_EGL_CONTEXT_API)
{
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;
}
@ -930,9 +934,13 @@ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle)
assert(window != NULL);
if (window->context.source != GLFW_EGL_CONTEXT_API)
{
if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND ||
window->context.source != GLFW_NATIVE_CONTEXT_API)
{
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
return EGL_NO_SURFACE;
return EGL_NO_CONTEXT;
}
}
return window->context.egl.surface;