diff --git a/changelog.txt b/changelog.txt index 6b53ff5..51c0fae 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,11 +1,15 @@ ZEngine Version Log for Version 0.8.0-rc4 -$Id: changelog.txt,v 1.16 2002/12/22 06:07:56 cozman Exp $ +$Id: changelog.txt,v 1.17 2002/12/27 03:15:33 cozman Exp $ + +0.8.0 + -Added Surface Loss Protection. + -Utilized Surface Loss Protection in ZImageTest for a demo. 0.8.0-rc4 (AKA "what rc3 should have been") -Fixed ZImage::SetColorKey for new Attach behavior. -Fixed ZMusicTest GL screen error if music fails to open. -Fixed VC7 "Release" Project files. - -Removed switch option from tests. + -Removed switch option from tests due to surface loss. 0.8.0-rc3 -Fixed MAJOR memory leak when using ZImage::Attach, and in ZFont. diff --git a/include/ZE_ZEngine.h b/include/ZE_ZEngine.h index d2cda73..4a0834d 100644 --- a/include/ZE_ZEngine.h +++ b/include/ZE_ZEngine.h @@ -13,7 +13,7 @@ File: ZE_ZEngine.h
Description: Header file for ZEngine class, the core of the ZEngine.
Author(s): James Turk
-$Id: ZE_ZEngine.h,v 1.6 2002/12/12 02:50:35 cozman Exp $
+$Id: ZE_ZEngine.h,v 1.7 2002/12/27 03:15:33 cozman Exp $
\file ZE_ZEngine.h \brief Definition file for core ZEngine class. @@ -268,8 +268,9 @@ class ZEngine //////////////////////////// //Event and Input Handling// //////////////////////////// - private: + //! bool which is only set to true if the engine thinks the images need to be reloaded (loss of focus in fullscreen). + bool mNeedReload; //! bool describing Active or Inactive State of Game bool mActive; //! bool for checking if a Quit event has been detected @@ -310,6 +311,21 @@ class ZEngine \return bool telling if quit has been requested. **/ bool QuitRequested(); + + /*! + \brief Set State of ImagesNeedReload. + \param state False if images need to be reloaded, True if images have been reloaded. + **/ + void SetReloadNeed(bool state); + + /*! + \brief Find out if images should be reloaded. + + Function that is good to call every frame to check if images should be reloaded, usually only caused by loss of focus in + fullscreen. + \return bool, True if images should be reloaded, false otherwise. + **/ + bool ImagesNeedReload(); /*! \brief Set Key repeat rate. diff --git a/include/ZEngine.h b/include/ZEngine.h index a691d9f..e0ba3e9 100644 --- a/include/ZEngine.h +++ b/include/ZEngine.h @@ -3,7 +3,7 @@ File: ZEngine.h
Description: Public Header File for ZEngine.
Author(s): James Turk
-$Id: ZEngine.h,v 1.10 2002/12/12 04:33:18 cozman Exp $
+$Id: ZEngine.h,v 1.11 2002/12/27 03:15:33 cozman Exp $
\file ZEngine.h \brief Header file for ZEngine. @@ -16,8 +16,8 @@ $Id: ZEngine.h,v 1.10 2002/12/12 04:33:18 cozman Exp $
\mainpage ZEngine Documentation \author James Turk - \version 0.8.0-rc2 - \date December 12, 2002 + \version 0.8.0-rc4 + \date December 26, 2002 \section ZEngine About ZEngine
diff --git a/src/ZE_ZEngine.cpp b/src/ZE_ZEngine.cpp index 5a0192f..4521895 100644 --- a/src/ZE_ZEngine.cpp +++ b/src/ZE_ZEngine.cpp @@ -13,7 +13,7 @@ File: ZE_ZEngine.cpp
Description: Implementation source file for ZEngine library main singleton class.
Author(s): James Turk
-$Id: ZE_ZEngine.cpp,v 1.7 2002/12/12 02:50:35 cozman Exp $
+$Id: ZE_ZEngine.cpp,v 1.8 2002/12/27 03:15:33 cozman Exp $
\file ZE_ZEngine.cpp \brief Central source file for ZEngine. @@ -39,6 +39,7 @@ ZEngine::ZEngine() mRate = 22050; mStereo = false; #endif + mNeedReload = false; mScreen = NULL; @@ -298,6 +299,16 @@ bool ZEngine::QuitRequested() return mQuit; } +void ZEngine::SetReloadNeed(bool state) +{ + mNeedReload = state; +} + +bool ZEngine::ImagesNeedReload() +{ + return mNeedReload; +} + void ZEngine::SetKeyRepeatRate(int rate) { SDL_EnableKeyRepeat(rate,rate); @@ -368,6 +379,8 @@ void ZEngine::CheckEvents() mActive = true; if(mUnpauseOnActive) UnpauseTimer(); + if(mFullscreen) + mNeedReload = true; } else { diff --git a/test/ZImageTest.cpp b/test/ZImageTest.cpp index e478b29..eb5d113 100644 --- a/test/ZImageTest.cpp +++ b/test/ZImageTest.cpp @@ -24,7 +24,7 @@ void Initialize() w = cfg.GetInt("ZImageTest","width",800); h = cfg.GetInt("ZImageTest","height",600); bpp = cfg.GetInt("ZImageTest","bpp",32); - fs = cfg.GetBool("ZImageTest","fullscreen",false); + fs = cfg.GetBool("ZImageTest","fullscreen",true); title = cfg.GetString("ZImageTest","title","ZImage Test"); engine->SetupDisplay(w,h,bpp,fs); @@ -38,22 +38,39 @@ void Test() //Open and Setup all the Images// SDL_Surface *temp; - ZImage image1, image2("data/test01.bmp"), image3(image2.Surface(),5,5,20,20), textImage; + ZImage image1, image2, image3, textImage; ZFont font("data/almontew.ttf",30); - temp = SDL_LoadBMP("data/test02.bmp"); //this is a separate surface - image1.Attach(temp); //this attaches the surface into itself - temp = NULL; //and temp will now be controlled and freed by image1 - image1.SetColorKey(255,0,255); - image2.SetColorKey(255,0,255); + engine->SetReloadNeed(true); //start off needing the reload + font.SetColor(0,255,0); font.SetBGColor(0,0,255); - font.DrawShadedText("ZImage Test.",textImage); do { //In the active loop, check events first// engine->CheckEvents(); + + if(engine->ImagesNeedReload()) + { + temp = SDL_LoadBMP("data/test02.bmp"); //this is a separate surface + image1.Attach(temp); //this attaches the surface into itself + image2.Open("data/test01.bmp"); + image3.OpenFromImage(image2.Surface(),5,5,20,20); + temp = NULL; //and temp will now be controlled and freed by image1 + image1.SetColorKey(255,0,255); + image2.SetColorKey(255,0,255); + font.DrawShadedText("ZImage Test.",textImage); + engine->SetReloadNeed(false); //very important for speed, without this you'd be reloading every frame + } + + if(engine->KeyIsPressed(SDLK_s)) + { + //code to toggle screen// + engine->SetupDisplay(engine->Width(),engine->Height(),engine->BPP(),!engine->IsFullscreen()); + engine->CreateDisplay("ZImage Test"); + engine->SetReloadNeed(true); + } if(engine->KeyIsPressed(SDLK_ESCAPE)) engine->RequestQuit();