From b667924b02211dc5b259c27392a75ee72802d553 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 3 Nov 2025 08:11:58 -0800
Subject: [PATCH] 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.
Fixes https://github.com/libsdl-org/sdl12-compat/issues/380
---
src/SDL12_compat.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index aee55c4d2..ba5e25522 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();
}