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); }