From 91637f4578ce0720991478e7f745139fe8fc06ba Mon Sep 17 00:00:00 2001 From: Sylvain Date: Tue, 14 Feb 2023 23:46:51 +0100 Subject: [PATCH] Fix X11 + EGL + GLFW_TRANSPARENT_FRAMEBUFFER by ignoring visual id (tested with example/gears.c) --- src/egl_context.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/egl_context.c b/src/egl_context.c index 64dcdd6f..2f3e6a22 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -841,7 +841,13 @@ GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig, XVisualInfo desired; EGLConfig native; EGLint visualID = 0, count = 0; - const long vimask = VisualScreenMask | VisualIDMask; + long vimask; + + if (fbconfig->transparent) { + vimask = VisualScreenMask; + } else { + vimask = VisualScreenMask | VisualIDMask; + } if (!chooseEGLConfig(ctxconfig, fbconfig, &native)) return GLFW_FALSE; @@ -860,6 +866,21 @@ GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig, return GLFW_FALSE; } + if (fbconfig->transparent) { + int i; + for (i = 0; i < count; i++) { + XVisualInfo *vinfo = &result[i]; + if (vinfo->class == DirectColor || vinfo->class == TrueColor) { + if (vinfo->depth == 32) { + *visual = vinfo->visual; + *depth = vinfo->depth; + XFree(result); + return GLFW_TRUE; + } + } + } + } + *visual = result->visual; *depth = result->depth;