Browse Source

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

Alex Szpakowski 10 years ago
parent
commit
18569979e9
2 changed files with 11 additions and 3 deletions
  1. 2 0
      src/modules/graphics/opengl/Graphics.cpp
  2. 9 3
      src/modules/window/sdl/Window.cpp

+ 2 - 0
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());
 

+ 9 - 3
src/modules/window/sdl/Window.cpp

@@ -48,11 +48,17 @@ Window::Window()
 
 Window::~Window()
 {
-	if (window)
-		SDL_DestroyWindow(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);
 
 	SDL_QuitSubSystem(SDL_INIT_VIDEO);
 }