ZImage::Reload
This commit is contained in:
		
							parent
							
								
									4fbdebfe78
								
							
						
					
					
						commit
						6d5c0637be
					
				
					 3 changed files with 30 additions and 13 deletions
				
			
		|  | @ -13,7 +13,7 @@ | |||
| File: ZE_ZImage.h <br> | ||||
| Description: Header file for core ZEngine Image and Texture Object. <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 | ||||
|     \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(); | ||||
|  |  | |||
|  | @ -13,7 +13,7 @@ | |||
| File: ZE_ZImage.cpp <br> | ||||
| Description: Implementation source file for core ZEngine Image or Texture Object. <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 | ||||
|     \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)) | ||||
|  |  | |||
|  | @ -41,18 +41,9 @@ 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); | ||||
| 
 | ||||
|     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"); | ||||
|  | @ -61,6 +52,18 @@ void Test() | |||
|     image1.SetColorKey(255,0,255); | ||||
|     image2.SetColorKey(255,0,255); | ||||
|     font.DrawShadedText("ZImage Test.",textImage); | ||||
| 
 | ||||
|     do | ||||
|     { | ||||
|         //In the active loop, check events first//
 | ||||
|         engine->CheckEvents(); | ||||
| 
 | ||||
|         if(engine->ImagesNeedReload()) | ||||
|         { | ||||
|             image1.Reload(); | ||||
|             image2.Reload(); | ||||
|             image3.Reload(); | ||||
|             textImage.Reload(); | ||||
|             engine->SetReloadNeed(false);   //very important for speed, without this you'd be reloading every frame
 | ||||
|         } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 James Turk
						James Turk