From eddc10294d448d62614d613008f5e7994ce118c0 Mon Sep 17 00:00:00 2001 From: stephena Date: Sat, 6 Dec 2003 00:17:29 +0000 Subject: [PATCH] All changes are to the SDL version. Made emulator pause when toggling between windowed and fullscreen modes. Added code for the TEXTURES_ARE_LOST definition. In Windows, when changing the window size or toggling fullscreen/windowed modes, the OpenGL textures are lost and must be reloaded. This now works. Fixed a long-standing bug in snapshot files. I made sure they were opened in binary mode. That wasn't required in Linux. Sometimes developing multi-platform code can really work the bugs out. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@228 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/ui/common/Snapshot.cxx | 4 ++-- stella/src/ui/sdl/FrameBufferGL.cxx | 21 ++++++++++++++++++++- stella/src/ui/sdl/mainSDL.cxx | 7 ++++++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/stella/src/ui/common/Snapshot.cxx b/stella/src/ui/common/Snapshot.cxx index 60ba09028..93f5e89c2 100644 --- a/stella/src/ui/common/Snapshot.cxx +++ b/stella/src/ui/common/Snapshot.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Snapshot.cxx,v 1.8 2003-11-19 15:57:10 stephena Exp $ +// $Id: Snapshot.cxx,v 1.9 2003-12-06 00:17:28 stephena Exp $ //============================================================================ #include @@ -88,7 +88,7 @@ uInt32 Snapshot::savePNG(string filename, uInt32 multiplier) uInt32 width = myMediaSource->width(); uInt32 height = myMediaSource->height(); - ofstream* out = new ofstream(filename.c_str()); + ofstream* out = new ofstream(filename.c_str(), ios_base::binary); if(!out) return 0; diff --git a/stella/src/ui/sdl/FrameBufferGL.cxx b/stella/src/ui/sdl/FrameBufferGL.cxx index 2dd18f5ea..fbcff6851 100644 --- a/stella/src/ui/sdl/FrameBufferGL.cxx +++ b/stella/src/ui/sdl/FrameBufferGL.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: FrameBufferGL.cxx,v 1.11 2003-12-03 18:11:25 stephena Exp $ +// $Id: FrameBufferGL.cxx,v 1.12 2003-12-06 00:17:29 stephena Exp $ //============================================================================ #include @@ -71,6 +71,17 @@ bool FrameBufferGL::createScreen() glPushMatrix(); glLoadIdentity(); +#ifdef TEXTURES_ARE_LOST + createTextures(); + + glDisable(GL_DEPTH_TEST); + glDisable(GL_CULL_FACE); + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_TEXTURE_2D); +#endif + theRedrawEntireFrameIndicator = true; return true; } @@ -194,8 +205,10 @@ bool FrameBufferGL::init() SDL_GL_GetAttribute( SDL_GL_BLUE_SIZE, (int*)&myRGB[2] ); SDL_GL_GetAttribute( SDL_GL_ALPHA_SIZE, (int*)&myRGB[3] ); +#ifndef TEXTURES_ARE_LOST // Create the texture surface and texture fonts createTextures(); +#endif // Set up the palette *after* we know the color components // and the textures @@ -349,6 +362,12 @@ void FrameBufferGL::drawChar(uInt32 x, uInt32 y, uInt32 c) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool FrameBufferGL::createTextures() { + if(myTexture) + SDL_FreeSurface(myTexture); + + glDeleteTextures(1, &myTextureID); + glDeleteTextures(256, myFontTextureID); + uInt32 w = power_of_two(myWidth); uInt32 h = power_of_two(myHeight); diff --git a/stella/src/ui/sdl/mainSDL.cxx b/stella/src/ui/sdl/mainSDL.cxx index 26e1bd0b5..96b020dce 100644 --- a/stella/src/ui/sdl/mainSDL.cxx +++ b/stella/src/ui/sdl/mainSDL.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: mainSDL.cxx,v 1.65 2003-12-05 19:51:09 stephena Exp $ +// $Id: mainSDL.cxx,v 1.66 2003-12-06 00:17:29 stephena Exp $ //============================================================================ #include @@ -342,7 +342,12 @@ void handleEvents() else if(key == SDLK_MINUS) theDisplay->resize(-1); else if(key == SDLK_RETURN) + { theDisplay->toggleFullscreen(); + // Pause when switching modes + if(!theConsole->eventHandler().doPause()) + theConsole->eventHandler().sendEvent(Event::Pause, 1); + } #ifdef DISPLAY_OPENGL else if(key == SDLK_f && theUseOpenGLFlag) ((FrameBufferGL*)theDisplay)->toggleFilter();