diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index ee39c5824..8fb70b997 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -190,26 +190,12 @@ Renderer &Renderer::getInstance(){ void Renderer::reinitAll() { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - const Game *gamePtr = this->game; - const MainMenu *menuPtr = this->menu; - - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - - //end(); - init(); - - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - - if(gamePtr != NULL) { - //endGame(); - initGame(gamePtr); - } - - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - - if(menuPtr != NULL) { - //endMenu(); - initMenu(menuPtr); + //resources + for(int i=0; iinit(); + textureManager[i]->init(true); + //particleManager[i]->init(); + fontManager[i]->init(); } SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index caa2d28e2..f390026a8 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -210,9 +210,12 @@ void MainWindow::eventKeyDown(char key){ if(keystate.mod & (KMOD_LALT | KMOD_RALT)) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ALT-ENTER pressed\n",__FILE__,__FUNCTION__,__LINE__); - //Renderer &renderer= Renderer::getInstance(); - //renderer.reloadResources(); - //renderer.reinitAll(); + // This stupidity only required in win32. + // We reload the textures so that +#ifdef WIN32 + Renderer &renderer= Renderer::getInstance(); + renderer.reinitAll(); +#endif SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); } diff --git a/source/shared_lib/include/graphics/texture.h b/source/shared_lib/include/graphics/texture.h index ca449ea27..300a34f60 100644 --- a/source/shared_lib/include/graphics/texture.h +++ b/source/shared_lib/include/graphics/texture.h @@ -78,6 +78,8 @@ public: virtual void init(Filter filter= fBilinear, int maxAnisotropy= 1)=0; virtual void end()=0; + + virtual void reseInitState() { inited = false; } }; // ===================================================== diff --git a/source/shared_lib/include/graphics/texture_manager.h b/source/shared_lib/include/graphics/texture_manager.h index 2c1925ecf..59272b311 100644 --- a/source/shared_lib/include/graphics/texture_manager.h +++ b/source/shared_lib/include/graphics/texture_manager.h @@ -38,13 +38,14 @@ protected: public: TextureManager(); ~TextureManager(); - void init(); + void init(bool forceInit=false); void end(); void setFilter(Texture::Filter textureFilter); void setMaxAnisotropy(int maxAnisotropy); void initTexture(Texture *texture); void endTexture(Texture **texture); + void reinitTextures(); Texture *getTexture(const string &path); Texture1D *newTexture1D(); diff --git a/source/shared_lib/sources/graphics/texture_manager.cpp b/source/shared_lib/sources/graphics/texture_manager.cpp index 3c4900ba9..ac74a1542 100644 --- a/source/shared_lib/sources/graphics/texture_manager.cpp +++ b/source/shared_lib/sources/graphics/texture_manager.cpp @@ -12,6 +12,7 @@ #include "texture_manager.h" #include +#include #include "graphics_interface.h" #include "graphics_factory.h" @@ -47,9 +48,16 @@ void TextureManager::endTexture(Texture **texture) { } } -void TextureManager::init(){ +void TextureManager::init(bool forceInit) { for(int i=0; iinit(textureFilter, maxAnisotropy); + Texture *texture = textures[i]; + if(texture == NULL) { + throw std::runtime_error("texture == NULL during init"); + } + if(forceInit == true) { + texture->reseInitState(); + } + texture->init(textureFilter, maxAnisotropy); } } diff --git a/source/shared_lib/sources/platform/sdl/window.cpp b/source/shared_lib/sources/platform/sdl/window.cpp index 9d750fdf8..008d6fbaf 100644 --- a/source/shared_lib/sources/platform/sdl/window.cpp +++ b/source/shared_lib/sources/platform/sdl/window.cpp @@ -330,6 +330,9 @@ void Window::toggleFullscreen() { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] Window::isFullScreen == false [%d]\n",__FILE__,__FUNCTION__,__LINE__,handle); ShowWindow(handle, SW_RESTORE); } + + SDL_Surface *sf = SDL_GetVideoSurface(); + SDL_SetVideoMode(0, 0, 0, sf->flags ^SDL_FULLSCREEN); #else SDL_WM_ToggleFullScreen(SDL_GetVideoSurface());