Skip to contentSkip to conversation

ui/sdl2: OpenGL window context

PATCH Superseded Antonio Caggiano 2 participants 2 messages Jun 9, 2023 – Jun 12, 2023

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 ui/sdl2: OpenGL window context

When OpenGL is enabled, create only the OpenGL context, ignoring the SDL renderer as it is unused anyway.

---
v2: There is no need to specify major and minor version if the SDL renderer is
not created. Also, tested on Windows.
v3: Completely messed up the commit, now fixed.

 ui/sdl2.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
ui/sdl2.c +3 -3
index 9d703200bf..82e6ee5511 100644
@@ -113,11 +113,11 @@ void sdl2_window_create(struct sdl2_console *scon)
 
         SDL_SetHint(SDL_HINT_RENDER_DRIVER, driver);
         SDL_SetHint(SDL_HINT_RENDER_BATCHING, "1");
-    }
-    scon->real_renderer = SDL_CreateRenderer(scon->real_window, -1, 0);
 
-    if (scon->opengl) {
         scon->winctx = SDL_GL_CreateContext(scon->real_window);
+    } else {
+        /* The SDL renderer is only used by sdl2-2D, when OpenGL is disabled */
+        scon->real_renderer = SDL_CreateRenderer(scon->real_window, -1, 0);
     }
     sdl_update_caption(scon);
 }
Signature · 1 line
2.40.0
#1 lore raw

Hi Antonio

Quoted 30 lines · Antonio Caggiano

When OpenGL is enabled, create only the OpenGL context, ignoring the SDL renderer as it is unused anyway.

---
v2: There is no need to specify major and minor version if the SDL renderer is
not created. Also, tested on Windows.
v3: Completely messed up the commit, now fixed.

 ui/sdl2.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
ui/sdl2.c +2 -3
index 9d703200bf..82e6ee5511 100644
@@ -113,11 +113,11 @@ void sdl2_window_create(struct sdl2_console *scon)
 
         SDL_SetHint(SDL_HINT_RENDER_DRIVER, driver);
         SDL_SetHint(SDL_HINT_RENDER_BATCHING, "1");
-    }
-    scon->real_renderer = SDL_CreateRenderer(scon->real_window, -1, 0);
 
-    if (scon->opengl) {
         scon->winctx = SDL_GL_CreateContext(scon->real_window);
+    } else {
+        /* The SDL renderer is only used by sdl2-2D, when OpenGL is

disabled */
+ scon->real_renderer = SDL_CreateRenderer(scon->real_window, -1,

Quoted 7 lines
0);
     }
     sdl_update_caption(scon);

}
--
2.40.0

sdl2_window_destroy() should still be updated to avoid calling Destroy functions with NULL arguments. (we don't check the return value, but it's being checked by SDL)