From: Sam Lantinga <slouken@libsdl.org>
Date: Mon, 3 Nov 2025 08:11:58 -0800
Subject: Re-try creating the window if it failed due to missing OpenGL

OpenGL isn't available when using the dummy video driver or if OpenGL isn't installed.

Bug: https://github.com/libsdl-org/sdl12-compat/issues/380
Origin: upstream, 3.2.28, commit:b667924b02211dc5b259c27392a75ee72802d553
---
 src/SDL12_compat.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index f54f60e..d533919 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -6629,6 +6629,11 @@ SetVideoModeImpl(int width, int height, int bpp, Uint32 flags12)
         }
 
         VideoWindow20 = SDL20_CreateWindow(WindowTitle, x, y, scaled_width, scaled_height, flags20);
+        if (!VideoWindow20 && (flags20 & SDL_WINDOW_OPENGL) && !(flags12 & SDL12_OPENGL)) {
+            /* OpenGL might not be installed, try again without that flag */
+            flags20 &= ~SDL_WINDOW_OPENGL;
+            VideoWindow20 = SDL20_CreateWindow(WindowTitle, x, y, scaled_width, scaled_height, flags20);
+        }
         if (!VideoWindow20) {
             return EndVidModeCreate();
         }
