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) {