From a01cd628abd00ec8b41856272b93e74c7a5d2e20 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 12ac2152a..754878441 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -5903,6 +5903,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 d598b3d7a..e765bbb87 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1999,12 +1999,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 98a8424ce..319acab4b 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) {