From 7b260aebe0f1b52535ec8e14c3ba10a1ff263b37 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 25 Nov 2025 16:35:00 +0100 Subject: [PATCH] do some more cleanup when shutting down graphics system make sure we free all our opengl allocated stuff by calling HWR_Shutdown make sure we also destroy our sdl texture, renderer and window if the exist --- src/hardware/hw_main.cpp | 1 + src/sdl/i_video.c | 16 ++++++++++++++-- src/sdl/ogl_sdl.c | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 653220866..133332f8b 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -5930,6 +5930,7 @@ void HWR_Shutdown(void) HWR_FreeExtraSubsectors(); HWR_FreeMapTextures(); GL_FlushScreenTextures(); + HWR_ClearAllTextures(); #ifdef USE_FBO_OGL GL_Framebuffer_Disable(); #endif diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 4fbf42bc3..acf4f754e 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -2180,12 +2180,24 @@ void I_ShutdownGraphics(void) I_OutputMsg("shut down\n"); #ifdef HWRENDER + if (vid.glstate == VID_GL_LIBRARY_LOADED) + HWR_Shutdown(); + if (sdlglcontext) - { SDL_GL_DeleteContext(sdlglcontext); - } + sdlglcontext = NULL; #endif + if (texture) + SDL_DestroyTexture(texture); + texture = NULL; + if (renderer) + SDL_DestroyRenderer(renderer); + renderer = NULL; + if (window) + SDL_DestroyWindow(window); + window = NULL; + SDL_QuitSubSystem(SDL_INIT_VIDEO); framebuffer = SDL_FALSE; } diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index e029b3316..b63166639 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -81,7 +81,7 @@ boolean UseScreenFBO(void) /** \brief SDL video display surface */ INT32 oglflags = 0; -SDL_GLContext sdlglcontext = 0; +SDL_GLContext sdlglcontext = NULL; void *GetGLFunc(const char *proc) {