ui/sdl2: OpenGL window context
PATCH 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.
Signed-off-by Antonio Caggiano <[email protected]>
--- ui/sdl2.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
ui/sdl2.c +11 -7
@@ -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); }
@@ -128,10 +128,14 @@ void sdl2_window_destroy(struct sdl2_console *scon)return ; } -SDL_GL_DeleteContext (scon->winctx); - scon->winctx =NULL ; -SDL_DestroyRenderer (scon->real_renderer); - scon->real_renderer =NULL ; +if (scon->winctx) { +SDL_GL_DeleteContext (scon->winctx); + scon->winctx =NULL ; + } +if (scon->real_renderer) { +SDL_DestroyRenderer (scon->real_renderer); + scon->real_renderer =NULL ; + }SDL_DestroyWindow (scon->real_window); scon->real_window =NULL ; }
Signature · 1 line
2.40.0
Quoted 5 lines · Antonio Caggiano
When OpenGL is enabled, create only the OpenGL context, ignoring the SDL renderer as it is unused anyway.
Signed-off-by Antonio Caggiano <[email protected]>
Reviewed-by Marc-André Lureau <[email protected]>
Quoted 49 lines
--- ui/sdl2.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)ui/sdl2.c +2
-3@@ -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);}
ui/sdl2.c +8
-5@@ -128,10 +128,14 @@ void sdl2_window_destroy(struct sdl2_console *scon)return ; } -SDL_GL_DeleteContext (scon->winctx); - scon->winctx =NULL ; -SDL_DestroyRenderer (scon->real_renderer); - scon->real_renderer =NULL ; +if (scon->winctx) { +SDL_GL_DeleteContext (scon->winctx); + scon->winctx =NULL ; + } +if (scon->real_renderer) { +SDL_DestroyRenderer (scon->real_renderer); + scon->real_renderer =NULL ; + }SDL_DestroyWindow (scon->real_window); scon->real_window =NULL ; } --2.40.0
Signature · 1 line
Marc-André Lureau