This commit is contained in:
eafton 2025-09-30 18:55:23 +03:00 committed by Sam Lantinga
parent 8bba24757d
commit 98eaa05a9f

View file

@ -1250,9 +1250,12 @@ EGLSurface SDL_EGL_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, Nat
// max 16 key+value pairs, plus terminator. // max 16 key+value pairs, plus terminator.
EGLint attribs[33]; EGLint attribs[33];
int attr = 0; int attr = 0;
bool use_opaque_ext;
EGLSurface surface; EGLSurface surface;
use_opaque_ext = true;
try:
if (!SDL_EGL_ChooseConfig(_this)) { if (!SDL_EGL_ChooseConfig(_this)) {
return EGL_NO_SURFACE; return EGL_NO_SURFACE;
} }
@ -1282,7 +1285,7 @@ EGLSurface SDL_EGL_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, Nat
} }
#ifdef EGL_EXT_present_opaque #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; bool allow_transparent = false;
if (window && (window->flags & SDL_WINDOW_TRANSPARENT)) { if (window && (window->flags & SDL_WINDOW_TRANSPARENT)) {
allow_transparent = true; allow_transparent = true;
@ -1323,6 +1326,10 @@ EGLSurface SDL_EGL_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, Nat
_this->egl_data->egl_config, _this->egl_data->egl_config,
nw, &attribs[0]); nw, &attribs[0]);
if (surface == EGL_NO_SURFACE) { 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"); SDL_EGL_SetError("unable to create an EGL window surface", "eglCreateWindowSurface");
} }