|
From: Lasse Kärkkäi. <tr...@us...> - 2011-07-06 23:36:13
|
Author: Lasse Karkkainen <tro...@tr...>
Date: Mon May 30 10:45:01 2011 +0300
Allow screens to do their own OpenGL reload handling.
---
game/main.cc | 3 +--
game/screen.hh | 4 ++++
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/game/main.cc b/game/main.cc
index cc08f5a..db3adde 100644
--- a/game/main.cc
+++ b/game/main.cc
@@ -109,8 +109,7 @@ static void checkEvents_SDL(ScreenManager& sm) {
}
if (config["graphic/fullscreen"].b() != sm.window().getFullscreen()) {
sm.window().setFullscreen(config["graphic/fullscreen"].b());
- // Reloading the screen seems to counter window going white on Windows and possibly OSX
- sm.activateScreen(sm.getCurrentScreen()->getName());
+ sm.reloadGL();
}
}
diff --git a/game/screen.hh b/game/screen.hh
index 189d50b..1ea4fbd 100644
--- a/game/screen.hh
+++ b/game/screen.hh
@@ -25,6 +25,8 @@ class Screen {
virtual void enter() = 0;
/// exits screen
virtual void exit() = 0;
+ /// reloads OpenGL textures but avoids restarting music etc.
+ virtual void reloadGL() { exit(); enter(); }
/// returns screen name
std::string getName() const { return m_name; }
@@ -49,6 +51,8 @@ class ScreenManager: public Singleton <ScreenManager> {
void updateScreen();
/// Draws the current screen and possible transition effects
void drawScreen();
+ /// Reload OpenGL resources (after fullscreen toggle etc)
+ void reloadGL() { if (currentScreen) currentScreen->reloadGL(); }
/// Returns pointer to current Screen
Screen* getCurrentScreen() { return currentScreen; };
/// Returns pointer to Screen for given name
|