From c3cb21a4988655e25008714ec8db7048635d7b26 Mon Sep 17 00:00:00 2001
From: eafton <[EMAIL REDACTED]>
Date: Tue, 30 Sep 2025 18:55:23 +0300
Subject: [PATCH] Fix for #13094
(cherry picked from commit 98eaa05a9f28b274977b5b06cc836690df0835aa)
---
src/video/SDL_egl.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c
index 1538f6ea4fae0..33874ea8b2775 100644
--- a/src/video/SDL_egl.c
+++ b/src/video/SDL_egl.c
@@ -1221,9 +1221,12 @@ EGLSurface SDL_EGL_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, Nat
// max 16 key+value pairs, plus terminator.
EGLint attribs[33];
int attr = 0;
-
+ bool use_opaque_ext;
+
EGLSurface surface;
+ use_opaque_ext = true;
+try:
if (!SDL_EGL_ChooseConfig(_this)) {
return EGL_NO_SURFACE;
}
@@ -1253,7 +1256,7 @@ EGLSurface SDL_EGL_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, Nat
}
#ifdef EGL_EXT_present_opaque
- if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_EXT_present_opaque")) {
+ if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_EXT_present_opaque") && use_opaque_ext) {
bool allow_transparent = false;
if (window && (window->flags & SDL_WINDOW_TRANSPARENT)) {
allow_transparent = true;
@@ -1294,6 +1297,10 @@ EGLSurface SDL_EGL_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, Nat
_this->egl_data->egl_config,
nw, &attribs[0]);
if (surface == EGL_NO_SURFACE) {
+ if (_this->egl_data->eglGetError() == EGL_BAD_ATTRIBUTE && use_opaque_ext) {
+ use_opaque_ext = false;
+ goto try;
+ }
SDL_EGL_SetError("unable to create an EGL window surface", "eglCreateWindowSurface");
}