diff --git a/include/ZE_ZImage.h b/include/ZE_ZImage.h
index 19f74a7..5047494 100644
--- a/include/ZE_ZImage.h
+++ b/include/ZE_ZImage.h
@@ -13,7 +13,7 @@
File: ZE_ZImage.h
Description: Header file for core ZEngine Image and Texture Object.
Author(s): James Turk, Gamer Tazar
-$Id: ZE_ZImage.h,v 1.4 2002/12/02 05:18:52 cozman Exp $
+$Id: ZE_ZImage.h,v 1.5 2002/12/27 18:56:17 cozman Exp $
\file ZE_ZImage.h
\brief Definition file for ZImage.
@@ -132,6 +132,13 @@ class ZImage : public ZObject
**/
void Attach(SDL_Surface *surface);
+ /*
+ \brief Reattach a preloaded texture that has been lost.
+
+ Attach loaded textures which have been lost due to loss of focus, should be called when ZEngine::ImagesNeedReload is true.
+ **/
+ void Reload();
+
/*!
\brief Releases image.
@@ -214,7 +221,7 @@ class ZImage : public ZObject
/*!
\brief Check if file is loaded.
- Check if file is loaded and pointer to data is non-NULL.
+ Check if surface is a valid GL texture. (does not detect surface loss)
\return Loaded or Unloaded state of data.
**/
bool IsLoaded();
diff --git a/src/ZE_ZImage.cpp b/src/ZE_ZImage.cpp
index 16c65cd..ff0ce66 100644
--- a/src/ZE_ZImage.cpp
+++ b/src/ZE_ZImage.cpp
@@ -13,7 +13,7 @@
File: ZE_ZImage.cpp
Description: Implementation source file for core ZEngine Image or Texture Object.
Author(s): James Turk, Gamer Tazar
-$Id: ZE_ZImage.cpp,v 1.8 2002/12/22 04:31:15 cozman Exp $
+$Id: ZE_ZImage.cpp,v 1.9 2002/12/27 18:56:17 cozman Exp $
\file ZE_ZImage.cpp
\brief Source file for ZImage.
@@ -112,6 +112,13 @@ void ZImage::Attach(SDL_Surface *surface)
LogError("Invalid surface passed to ZImage::Attach.");
}
+void ZImage::Reload()
+{
+ SDL_Surface *temp = rImage;
+ rImage = NULL;
+ Attach(temp);
+}
+
void ZImage::Release()
{
if(glIsTexture(rTexID))
diff --git a/test/ZImageTest.cpp b/test/ZImageTest.cpp
index eb5d113..805384d 100644
--- a/test/ZImageTest.cpp
+++ b/test/ZImageTest.cpp
@@ -41,11 +41,18 @@ void Test()
ZImage image1, image2, image3, textImage;
ZFont font("data/almontew.ttf",30);
- engine->SetReloadNeed(true); //start off needing the reload
-
font.SetColor(0,255,0);
font.SetBGColor(0,0,255);
+ 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);
+
do
{
//In the active loop, check events first//
@@ -53,14 +60,10 @@ void Test()
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);
+ image1.Reload();
+ image2.Reload();
+ image3.Reload();
+ textImage.Reload();
engine->SetReloadNeed(false); //very important for speed, without this you'd be reloading every frame
}