From 108bb5aabec27f41f977bdf7a4d2ed3f3a3962eb Mon Sep 17 00:00:00 2001 From: Vanfanel Date: Tue, 16 Mar 2021 00:51:17 +0100 Subject: [PATCH] [KMSDRM] Modify SDL_CreateRenderer() to create an opengles2 renderer when the KMSDRM backend is being used and no renderer name has been specified. --- src/render/SDL_render.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 0552918ab..c5ba8351e 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -838,6 +838,28 @@ SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags) } } +#if SDL_VIDEO_DRIVER_KMSDRM + + /* Even if full OpenGL works with the KMSDRM backend, GLES2 renderer is still preferred. */ + if ((SDL_strcmp(SDL_GetCurrentVideoDriver(), "KMSDRM") == 0) && (!renderer)) { + + for (index = 0; index < n; ++index) { + + const SDL_RenderDriver *driver = render_drivers[index]; + + if ((SDL_strcmp(driver->info.name, "opengles2") == 0) && (!renderer)) { + /* Create a new renderer instance */ + renderer = driver->CreateRenderer(window, flags); + if (renderer) { + /* Got an OpenGL_ES2 renderer as expected for KMSDRM by default. */ + break; + } + } + } + } + +#endif + if (!renderer) { for (index = 0; index < n; ++index) { const SDL_RenderDriver *driver = render_drivers[index];