Message ID | 20230609140752.69758-1-quic_acaggian@quicinc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v3] ui/sdl2: OpenGL window context | expand |
Hi Antonio On Fri, Jun 9, 2023 at 4:08 PM Antonio Caggiano <quic_acaggian@quicinc.com> wrote: > When OpenGL is enabled, create only the OpenGL context, ignoring the SDL > renderer as it is unused anyway. > > Signed-off-by: Antonio Caggiano <quic_acaggian@quicinc.com> > --- > 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(-) > > diff --git a/ui/sdl2.c b/ui/sdl2.c > index 9d703200bf..82e6ee5511 100644 > --- a/ui/sdl2.c > +++ b/ui/sdl2.c > @@ -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); > } > -- > 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)
diff --git a/ui/sdl2.c b/ui/sdl2.c index 9d703200bf..82e6ee5511 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -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); }
When OpenGL is enabled, create only the OpenGL context, ignoring the SDL renderer as it is unused anyway. Signed-off-by: Antonio Caggiano <quic_acaggian@quicinc.com> --- 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(-)