Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
dx8texman.cpp
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19/***********************************************************************************************
20 *** 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 ***
21 ***********************************************************************************************
22 * *
23 * Project Name : DX8 Texture Manager *
24 * *
25 * $Archive:: /Commando/Code/ww3d2/dx8texman.cpp $*
26 * *
27 * Original Author:: Hector Yee *
28 * *
29 * Author : Kenny Mitchell *
30 * *
31 * $Modtime:: 06/27/02 1:27p $*
32 * *
33 * $Revision:: 4 $*
34 * *
35 * 06/27/02 KM Texture class abstraction *
36 *---------------------------------------------------------------------------------------------*
37 * Functions: *
38 * DX8TextureManagerClass::Shutdown -- Shuts down the texture manager *
39 * DX8TextureManagerClass::Add -- Adds a texture to be managed *
40 * DX8TextureManagerClass::Remove -- Removes a texture from being managed *
41 * DX8TextureManagerClass::Release_Textures -- Releases the internal d3d texture *
42 * DX8TextureManagerClass::Recreate_Textures -- Reallocates lost textures *
43 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
44
45
46// This class manages textures that are in the default pool
47// ensuring that they are released on device loss
48// and created on device reset
49
50// Note: It does NOT addref to textures because it is called in the texture
51// destructor
52
53#include "dx8texman.h"
54
55TextureTrackerList DX8TextureManagerClass::Managed_Textures;
56
57
58/***********************************************************************************************
59 * DX8TextureManagerClass::Shutdown -- Shuts down the texture manager *
60 * *
61 * *
62 * *
63 * *
64 * INPUT: *
65 * *
66 * OUTPUT: *
67 * *
68 * WARNINGS: *
69 * *
70 * HISTORY: *
71 * 4/25/2001 hy : Created. *
72 * 5/16/2002 km : Added depth stencil texture tracking and abstraction *
73 *=============================================================================================*/
75{
76 while (!Managed_Textures.Is_Empty())
77 {
78 TextureTrackerClass *track=Managed_Textures.Remove_Head();
79 delete track;
80 track=NULL;
81 }
82}
83
84/***********************************************************************************************
85 * DX8TextureManagerClass::Add -- Adds a texture to be managed *
86 * *
87 * *
88 * *
89 * *
90 * INPUT: *
91 * *
92 * OUTPUT: *
93 * *
94 * WARNINGS: *
95 * *
96 * HISTORY: *
97 * 4/25/2001 hy : Created. *
98 * 5/16/2002 km : Added depth stencil texture tracking and abstraction *
99 *=============================================================================================*/
101{
102 // this function should only be called by the texture constructor
103 Managed_Textures.Add(track);
104}
105
106
107/***********************************************************************************************
108 * DX8TextureManagerClass::Remove -- Removes a texture from being managed *
109 * *
110 * *
111 * *
112 * *
113 * INPUT: *
114 * *
115 * OUTPUT: *
116 * *
117 * WARNINGS: *
118 * *
119 * HISTORY: *
120 * 4/25/2001 hy : Created. *
121 * 5/16/2002 km : Added depth stencil texture tracking and abstraction *
122 *=============================================================================================*/
124{
125 // this function should only be called by the texture destructor
126 TextureTrackerListIterator it(&Managed_Textures);
127
128 while (!it.Is_Done())
129 {
130 TextureTrackerClass *track=it.Peek_Obj();
131 if (track->Get_Texture()==tex)
132 {
134 delete track;
135 break;
136 }
137 it.Next();
138 }
139}
140
141
142/***********************************************************************************************
143 * DX8TextureManagerClass::Release_Textures -- Releases the internal d3d texture *
144 * *
145 * *
146 * *
147 * *
148 * INPUT: *
149 * *
150 * OUTPUT: *
151 * *
152 * WARNINGS: *
153 * *
154 * HISTORY: *
155 * 4/25/2001 hy : Created. *
156 * 5/16/2002 km : Added depth stencil texture tracking and abstraction *
157 *=============================================================================================*/
159{
160 TextureTrackerListIterator it(&Managed_Textures);
161
162 while (!it.Is_Done())
163 {
164 TextureTrackerClass *track=it.Peek_Obj();
165 track->Release();
166 it.Next();
167 }
168}
169
170
171/***********************************************************************************************
172 * DX8TextureManagerClass::Recreate_Textures -- Reallocates lost textures *
173 * *
174 * *
175 * *
176 * *
177 * INPUT: *
178 * *
179 * OUTPUT: *
180 * *
181 * WARNINGS: *
182 * *
183 * HISTORY: *
184 * 4/25/2001 hy : Created. *
185 * 5/16/2002 km : Added depth stencil texture tracking and abstraction *
186 *=============================================================================================*/
188{
189 TextureTrackerListIterator it(&Managed_Textures);
190
191 while (!it.Is_Done())
192 {
193 TextureTrackerClass *track=it.Peek_Obj();
194 track->Recreate();
195 track->Get_Texture()->Set_Dirty();
196 it.Next();
197 }
198}
199
#define NULL
Definition BaseType.h:92
static void Remove(TextureBaseClass *tex)
static void Recreate_Textures()
static void Shutdown()
Definition dx8texman.cpp:74
static void Release_Textures()
static void Add(TextureTrackerClass *track)
void Remove_Current_Object(void)
Definition multilist.h:311
ObjectType * Peek_Obj(void)
Definition multilist.h:306
void Set_Dirty()
Definition texture.h:174
TextureBaseClass * Get_Texture() const
Definition dx8texman.h:81
virtual void Recreate() const =0
MultiListIterator< TextureTrackerClass > TextureTrackerListIterator
Definition dx8list.h:70
MultiListClass< TextureTrackerClass > TextureTrackerList
Definition dx8list.h:69