ZImage::Reload
This commit is contained in:
parent
4fbdebfe78
commit
6d5c0637be
@ -13,7 +13,7 @@
|
|||||||
File: ZE_ZImage.h <br>
|
File: ZE_ZImage.h <br>
|
||||||
Description: Header file for core ZEngine Image and Texture Object. <br>
|
Description: Header file for core ZEngine Image and Texture Object. <br>
|
||||||
Author(s): James Turk, Gamer Tazar <br>
|
Author(s): James Turk, Gamer Tazar <br>
|
||||||
$Id: ZE_ZImage.h,v 1.4 2002/12/02 05:18:52 cozman Exp $<br>
|
$Id: ZE_ZImage.h,v 1.5 2002/12/27 18:56:17 cozman Exp $<br>
|
||||||
|
|
||||||
\file ZE_ZImage.h
|
\file ZE_ZImage.h
|
||||||
\brief Definition file for ZImage.
|
\brief Definition file for ZImage.
|
||||||
@ -132,6 +132,13 @@ class ZImage : public ZObject
|
|||||||
**/
|
**/
|
||||||
void Attach(SDL_Surface *surface);
|
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.
|
\brief Releases image.
|
||||||
|
|
||||||
@ -214,7 +221,7 @@ class ZImage : public ZObject
|
|||||||
/*!
|
/*!
|
||||||
\brief Check if file is loaded.
|
\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.
|
\return Loaded or Unloaded state of data.
|
||||||
**/
|
**/
|
||||||
bool IsLoaded();
|
bool IsLoaded();
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
File: ZE_ZImage.cpp <br>
|
File: ZE_ZImage.cpp <br>
|
||||||
Description: Implementation source file for core ZEngine Image or Texture Object. <br>
|
Description: Implementation source file for core ZEngine Image or Texture Object. <br>
|
||||||
Author(s): James Turk, Gamer Tazar <br>
|
Author(s): James Turk, Gamer Tazar <br>
|
||||||
$Id: ZE_ZImage.cpp,v 1.8 2002/12/22 04:31:15 cozman Exp $<br>
|
$Id: ZE_ZImage.cpp,v 1.9 2002/12/27 18:56:17 cozman Exp $<br>
|
||||||
|
|
||||||
\file ZE_ZImage.cpp
|
\file ZE_ZImage.cpp
|
||||||
\brief Source file for ZImage.
|
\brief Source file for ZImage.
|
||||||
@ -112,6 +112,13 @@ void ZImage::Attach(SDL_Surface *surface)
|
|||||||
LogError("Invalid surface passed to ZImage::Attach.");
|
LogError("Invalid surface passed to ZImage::Attach.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ZImage::Reload()
|
||||||
|
{
|
||||||
|
SDL_Surface *temp = rImage;
|
||||||
|
rImage = NULL;
|
||||||
|
Attach(temp);
|
||||||
|
}
|
||||||
|
|
||||||
void ZImage::Release()
|
void ZImage::Release()
|
||||||
{
|
{
|
||||||
if(glIsTexture(rTexID))
|
if(glIsTexture(rTexID))
|
||||||
|
@ -41,11 +41,18 @@ void Test()
|
|||||||
ZImage image1, image2, image3, textImage;
|
ZImage image1, image2, image3, textImage;
|
||||||
ZFont font("data/almontew.ttf",30);
|
ZFont font("data/almontew.ttf",30);
|
||||||
|
|
||||||
engine->SetReloadNeed(true); //start off needing the reload
|
|
||||||
|
|
||||||
font.SetColor(0,255,0);
|
font.SetColor(0,255,0);
|
||||||
font.SetBGColor(0,0,255);
|
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
|
do
|
||||||
{
|
{
|
||||||
//In the active loop, check events first//
|
//In the active loop, check events first//
|
||||||
@ -53,14 +60,10 @@ void Test()
|
|||||||
|
|
||||||
if(engine->ImagesNeedReload())
|
if(engine->ImagesNeedReload())
|
||||||
{
|
{
|
||||||
temp = SDL_LoadBMP("data/test02.bmp"); //this is a separate surface
|
image1.Reload();
|
||||||
image1.Attach(temp); //this attaches the surface into itself
|
image2.Reload();
|
||||||
image2.Open("data/test01.bmp");
|
image3.Reload();
|
||||||
image3.OpenFromImage(image2.Surface(),5,5,20,20);
|
textImage.Reload();
|
||||||
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
|
engine->SetReloadNeed(false); //very important for speed, without this you'd be reloading every frame
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user