From 18569979e96f58af5f3229d9a8288a99fa9ffe3a Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Wed, 21 Jan 2015 18:23:16 -0400 Subject: [PATCH] Better cleanup when the graphics and window subsystems are destroyed and restarted. --- src/modules/graphics/opengl/Graphics.cpp | 2 ++ src/modules/window/sdl/Window.cpp | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index 45cd09f52..bc8524da3 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -50,6 +50,8 @@ Graphics::Graphics() , created(false) , activeStencil(false) { + gl = OpenGL(); + states.reserve(10); states.push_back(DisplayState()); diff --git a/src/modules/window/sdl/Window.cpp b/src/modules/window/sdl/Window.cpp index 451d29e16..dac94e5cf 100644 --- a/src/modules/window/sdl/Window.cpp +++ b/src/modules/window/sdl/Window.cpp @@ -48,12 +48,18 @@ Window::Window() Window::~Window() { + if (context) + { + graphics::Graphics *gfx = Module::getInstance(Module::M_GRAPHICS); + if (gfx != nullptr) + gfx->unSetMode(); + + SDL_GL_DeleteContext(context); + } + if (window) SDL_DestroyWindow(window); - if (context) - SDL_GL_DeleteContext(context); - SDL_QuitSubSystem(SDL_INIT_VIDEO); }