Better cleanup when the graphics and window subsystems are destroyed and restarted.

This commit is contained in:
Alex Szpakowski
2015-01-21 18:23:16 -04:00
parent e82d1dfe54
commit 18569979e9
2 changed files with 11 additions and 3 deletions
+2
View File
@@ -50,6 +50,8 @@ Graphics::Graphics()
, created(false)
, activeStencil(false)
{
gl = OpenGL();
states.reserve(10);
states.push_back(DisplayState());
+9 -3
View File
@@ -48,12 +48,18 @@ Window::Window()
Window::~Window()
{
if (context)
{
graphics::Graphics *gfx = Module::getInstance<graphics::Graphics>(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);
}