Commit 7077c83f71 for qemu.org
commit 7077c83f71a7530af5d93748e998b00732f6fb36
Author: Anthony Roberts <anthony.roberts@linaro.org>
Date: Thu Apr 9 12:02:55 2026 +0100
ui/sdl2: Fix assumption of EGL presence at runtime
The original commit had a section of code which worked on the assumption
that if OpenGL was enabled at build, it was present on the end user machine,
and calls could be made to it. This is not always the case (such as Windows
on Arm devices).
This line should have also included a runtime check.
This commit moves the relevant line to inside a runtime check for OpenGL.
Fixes: 52053b7e0a0e ("ui/sdl2: Implement dpy dmabuf functions")
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3347
Cc: qemu-stable@nongnu.org
Signed-off-by: Anthony Roberts <anthony.roberts@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20260409110256.684-1-anthony.roberts@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
diff --git a/ui/sdl2.c b/ui/sdl2.c
index aaaede56e0..987ad334bb 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -120,15 +120,15 @@ void sdl2_window_create(struct sdl2_console *scon)
scon->winctx = SDL_GL_CreateContext(scon->real_window);
SDL_GL_SetSwapInterval(0);
+
+#ifdef CONFIG_OPENGL
+ qemu_egl_display = eglGetCurrentDisplay();
+#endif
} else {
/* The SDL renderer is only used by sdl2-2D, when OpenGL is disabled */
scon->real_renderer = SDL_CreateRenderer(scon->real_window, -1, 0);
}
-#ifdef CONFIG_OPENGL
- qemu_egl_display = eglGetCurrentDisplay();
-#endif
-
sdl_update_caption(scon);
}