Added code to support toggling between windowed and fullscreen mode for win32 platform.

This commit is contained in:
Mark Vejvoda
2010-04-05 20:42:05 +00:00
parent c525407904
commit b7a5970a3c
6 changed files with 29 additions and 26 deletions

View File

@@ -190,26 +190,12 @@ Renderer &Renderer::getInstance(){
void Renderer::reinitAll() { void Renderer::reinitAll() {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
const Game *gamePtr = this->game; //resources
const MainMenu *menuPtr = this->menu; for(int i=0; i<rsCount; ++i){
modelManager[i]->init();
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); textureManager[i]->init(true);
//particleManager[i]->init();
//end(); fontManager[i]->init();
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);
} }
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

View File

@@ -210,9 +210,12 @@ void MainWindow::eventKeyDown(char key){
if(keystate.mod & (KMOD_LALT | KMOD_RALT)) { if(keystate.mod & (KMOD_LALT | KMOD_RALT)) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ALT-ENTER pressed\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ALT-ENTER pressed\n",__FILE__,__FUNCTION__,__LINE__);
//Renderer &renderer= Renderer::getInstance(); // This stupidity only required in win32.
//renderer.reloadResources(); // We reload the textures so that
//renderer.reinitAll(); #ifdef WIN32
Renderer &renderer= Renderer::getInstance();
renderer.reinitAll();
#endif
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
} }

View File

@@ -78,6 +78,8 @@ public:
virtual void init(Filter filter= fBilinear, int maxAnisotropy= 1)=0; virtual void init(Filter filter= fBilinear, int maxAnisotropy= 1)=0;
virtual void end()=0; virtual void end()=0;
virtual void reseInitState() { inited = false; }
}; };
// ===================================================== // =====================================================

View File

@@ -38,13 +38,14 @@ protected:
public: public:
TextureManager(); TextureManager();
~TextureManager(); ~TextureManager();
void init(); void init(bool forceInit=false);
void end(); void end();
void setFilter(Texture::Filter textureFilter); void setFilter(Texture::Filter textureFilter);
void setMaxAnisotropy(int maxAnisotropy); void setMaxAnisotropy(int maxAnisotropy);
void initTexture(Texture *texture); void initTexture(Texture *texture);
void endTexture(Texture **texture); void endTexture(Texture **texture);
void reinitTextures();
Texture *getTexture(const string &path); Texture *getTexture(const string &path);
Texture1D *newTexture1D(); Texture1D *newTexture1D();

View File

@@ -12,6 +12,7 @@
#include "texture_manager.h" #include "texture_manager.h"
#include <cstdlib> #include <cstdlib>
#include <stdexcept>
#include "graphics_interface.h" #include "graphics_interface.h"
#include "graphics_factory.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; i<textures.size(); ++i){ for(int i=0; i<textures.size(); ++i){
textures[i]->init(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);
} }
} }

View File

@@ -330,6 +330,9 @@ void Window::toggleFullscreen() {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] Window::isFullScreen == false [%d]\n",__FILE__,__FUNCTION__,__LINE__,handle); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] Window::isFullScreen == false [%d]\n",__FILE__,__FUNCTION__,__LINE__,handle);
ShowWindow(handle, SW_RESTORE); ShowWindow(handle, SW_RESTORE);
} }
SDL_Surface *sf = SDL_GetVideoSurface();
SDL_SetVideoMode(0, 0, 0, sf->flags ^SDL_FULLSCREEN);
#else #else
SDL_WM_ToggleFullScreen(SDL_GetVideoSurface()); SDL_WM_ToggleFullScreen(SDL_GetVideoSurface());