From: sf17k Date: Wed, 8 Jun 2011 13:42:13 +0000 (-0400) Subject: added alt+enter fullscreen toggle X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=801987203c1ae03f2d9592a92d933fdba73854c2;p=lugaru.git added alt+enter fullscreen toggle --- diff --git a/Source/OpenGL_Windows.cpp b/Source/OpenGL_Windows.cpp index e064f99..1abe2f1 100644 --- a/Source/OpenGL_Windows.cpp +++ b/Source/OpenGL_Windows.cpp @@ -237,21 +237,25 @@ void initGL(){ } static void toggleFullscreen(){ - SDL_WM_ToggleFullScreen(SDL_GetVideoSurface()); - //~ SDL_Surface* screen=SDL_GetVideoSurface(); - //~ Uint32 flags=screen->flags; - //~ screen=SDL_SetVideoMode(0,0,0,flags^SDL_FULLSCREEN); - //~ if(!screen) - //~ screen=SDL_SetVideoMode(0,0,0,flags); - //~ if(!screen) - //~ exit(1); - //~ //reload opengl state - //~ initGL(); - //~ for(std::vector::iterator it=Game::textures.begin(); it!=Game::textures.end(); it++) { - //~ it->load(); - //~ } - //~ pgame->text.BuildFont(); - //~ pgame->LoadScreenTexture(); + if(!SDL_WM_ToggleFullScreen(SDL_GetVideoSurface())){ + SDL_Surface* screen=SDL_GetVideoSurface(); + Uint32 flags=screen->flags; + screen=SDL_SetVideoMode(0,0,0,flags^SDL_FULLSCREEN); + if(!screen) + screen=SDL_SetVideoMode(0,0,0,flags); + if(!screen) + exit(1); + //reload opengl state + initGL(); + Texture::reloadAll(); + if(text) + text->BuildFont(); + if(firstload){ + screentexture=0; + LoadScreenTexture(); + } + screentexture2=0; + } } static void sdlEventProc(const SDL_Event &e) diff --git a/Source/Texture.cpp b/Source/Texture.cpp index 5c8834d..ef20536 100644 --- a/Source/Texture.cpp +++ b/Source/Texture.cpp @@ -20,6 +20,7 @@ private: int skinsize; GLubyte* data; int datalen; + GLubyte* skindata; void load(); @@ -37,9 +38,11 @@ vector TextureRes::list; void TextureRes::load(){ //load image into 'texture' global var - unsigned char filenamep[256]; - CopyCStringToPascal(ConvertFileName(filename.c_str()),filenamep); - upload_image(filenamep,hasAlpha); + if(!skindata){ + unsigned char filenamep[256]; + CopyCStringToPascal(ConvertFileName(filename.c_str()),filenamep); + upload_image(filenamep,hasAlpha); + } skinsize=texture.sizeX; GLuint type=GL_RGBA; @@ -62,14 +65,18 @@ void TextureRes::load(){ } if(isSkin){ - free(data); - const int nb=texture.sizeY*texture.sizeX*(texture.bpp/8); - data=(GLubyte*)malloc(nb*sizeof(GLubyte)); - datalen=0; - for(int i=0;i::iterator it=list.begin();it!=list.end();it++) + for(vector::iterator it=list.begin();it!=list.end();it++){ + (*it)->id=0; (*it)->load(); + } }