| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- /*
- ** Command & Conquer Generals(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /***********************************************************************************************
- *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
- ***********************************************************************************************
- * *
- * Project Name : DX8 Texture Manager *
- * *
- * $Archive:: /Commando/Code/ww3d2/dx8texman.cpp $*
- * *
- * Original Author:: Hector Yee *
- * *
- * $Author:: Hector_y $*
- * *
- * $Modtime:: 4/26/01 1:41p $*
- * *
- * $Revision:: 3 $*
- * *
- *---------------------------------------------------------------------------------------------*
- * Functions: *
- * DX8TextureManagerClass::Shutdown -- Shuts down the texture manager *
- * DX8TextureManagerClass::Add -- Adds a texture to be managed *
- * DX8TextureManagerClass::Remove -- Removes a texture from being managed *
- * DX8TextureManagerClass::Release_Textures -- Releases the internal d3d texture *
- * DX8TextureManagerClass::Recreate_Textures -- Reallocates lost textures *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- // This class manages textures that are in the default pool
- // ensuring that they are released on device loss
- // and created on device reset
- // Note: It does NOT addref to textures because it is called in the texture
- // destructor
- #include "dx8texman.h"
- DX8TextureTrackerList DX8TextureManagerClass::Managed_Textures;
- /***********************************************************************************************
- * DX8TextureManagerClass::Shutdown -- Shuts down the texture manager *
- * *
- * *
- * *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 4/25/2001 hy : Created. *
- *=============================================================================================*/
- void DX8TextureManagerClass::Shutdown()
- {
- while (!Managed_Textures.Is_Empty())
- {
- DX8TextureTrackerClass *track=Managed_Textures.Remove_Head();
- delete track;
- track=NULL;
- }
- }
- /***********************************************************************************************
- * DX8TextureManagerClass::Add -- Adds a texture to be managed *
- * *
- * *
- * *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 4/25/2001 hy : Created. *
- *=============================================================================================*/
- void DX8TextureManagerClass::Add(DX8TextureTrackerClass *track)
- {
- // this function should only be called by the texture constructor
- Managed_Textures.Add(track);
- }
- /***********************************************************************************************
- * DX8TextureManagerClass::Remove -- Removes a texture from being managed *
- * *
- * *
- * *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 4/25/2001 hy : Created. *
- *=============================================================================================*/
- void DX8TextureManagerClass::Remove(TextureClass *tex)
- {
- // this function should only be called by the texture destructor
- DX8TextureTrackerListIterator it(&Managed_Textures);
- while (!it.Is_Done())
- {
- DX8TextureTrackerClass *track=it.Peek_Obj();
- if (track->Texture==tex)
- {
- it.Remove_Current_Object();
- delete track;
- break;
- }
- it.Next();
- }
- }
- /***********************************************************************************************
- * DX8TextureManagerClass::Release_Textures -- Releases the internal d3d texture *
- * *
- * *
- * *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 4/25/2001 hy : Created. *
- *=============================================================================================*/
- void DX8TextureManagerClass::Release_Textures()
- {
- DX8TextureTrackerListIterator it(&Managed_Textures);
- while (!it.Is_Done())
- {
- DX8TextureTrackerClass *track=it.Peek_Obj();
- WWASSERT(track->Texture->D3DTexture);
- track->Texture->D3DTexture->Release();
- track->Texture->D3DTexture=NULL;
- it.Next();
- }
- }
- /***********************************************************************************************
- * DX8TextureManagerClass::Recreate_Textures -- Reallocates lost textures *
- * *
- * *
- * *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 4/25/2001 hy : Created. *
- *=============================================================================================*/
- void DX8TextureManagerClass::Recreate_Textures()
- {
- DX8TextureTrackerListIterator it(&Managed_Textures);
- while (!it.Is_Done())
- {
- DX8TextureTrackerClass *track=it.Peek_Obj();
- WWASSERT(track->Texture->D3DTexture==NULL);
- track->Texture->D3DTexture=DX8Wrapper::_Create_DX8_Texture(track->Width,track->Height,
- track->Format,track->Mip_level_count,D3DPOOL_DEFAULT,track->RenderTarget);
- track->Texture->Dirty=true;
- it.Next();
- }
- }
|