From a9d90f2002fbc0b849c99a06069fcc0ff86268df Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Sat, 14 Aug 2021 12:09:13 -0400 Subject: [PATCH] Add SDL_HINT_VIDEO_EGL_FORCE_TRANSPARENCY --- include/SDL_hints.h | 12 ++++++++++++ src/video/SDL_egl.c | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/SDL_hints.h b/include/SDL_hints.h index ba043acf23b99..bc10e70d6bea2 100644 --- a/include/SDL_hints.h +++ b/include/SDL_hints.h @@ -1218,6 +1218,18 @@ extern "C" { */ #define SDL_HINT_VIDEO_DOUBLE_BUFFER "SDL_VIDEO_DOUBLE_BUFFER" + +/** + * \brief A variable controlling whether the OpenGL window is composited as + * transparent, rather than opaque. + * + * Most window systems will always render windows opaque, even if the surface + * format has an alpha channel. This is not always true, however, so by default + * SDL will try to enforce opaque composition. To override this behavior, you + * can set this hint to "1". + */ +#define SDL_HINT_VIDEO_EGL_FORCE_TRANSPARENCY "SDL_VIDEO_EGL_FORCE_TRANSPARENCY" + /** * \brief A variable controlling whether the graphics context is externally managed. * diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c index 85ed51d41ce80..8bddfd3b41f69 100644 --- a/src/video/SDL_egl.c +++ b/src/video/SDL_egl.c @@ -1224,8 +1224,9 @@ SDL_EGL_CreateSurface(_THIS, NativeWindowType nw) #ifdef EGL_EXT_present_opaque if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_EXT_present_opaque")) { + const SDL_bool force_transparent = SDL_GetHintBoolean(SDL_HINT_VIDEO_EGL_FORCE_TRANSPARENCY, SDL_FALSE); attribs[attr++] = EGL_PRESENT_OPAQUE_EXT; - attribs[attr++] = EGL_TRUE; + attribs[attr++] = force_transparent ? EGL_FALSE : EGL_TRUE; } #endif