Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
matpass.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 : WW3d *
24 * *
25 * $Archive:: /Commando/Code/ww3d2/matpass.cpp $*
26 * *
27 * Original Author:: Greg Hjelstrom *
28 * *
29 * Author : Kenny Mitchell *
30 * *
31 * $Modtime:: 06/27/02 1:27p $*
32 * *
33 * $Revision:: 8 $*
34 * *
35 * 06/27/02 KM Changes to max texture stage caps *
36 *---------------------------------------------------------------------------------------------*
37 * Functions: *
38 * MaterialPassClass::MaterialPassClass -- Constructor *
39 * MaterialPassClass::~MaterialPassClass -- Destructor *
40 * MaterialPassClass::Install_Materials -- Plug our material settings into D3D *
41 * MaterialPassClass::Set_Texture -- Set texture to use *
42 * MaterialPassClass::Set_Shader -- Set the shader to use *
43 * MaterialPassClass::Set_Material -- set vertex material to use *
44 * MaterialPassClass::Get_Texture -- Get a pointer to the texture *
45 * MaterialPassClass::Get_Material -- get the vertex material *
46 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
47
48
49#include "matpass.h"
50#include "vertmaterial.h"
51#include "shader.h"
52#include "texture.h"
53#include "statistics.h"
54#include "dx8wrapper.h"
55
56
58
59
60/***********************************************************************************************
61 * MaterialPassClass::MaterialPassClass -- Constructor *
62 * *
63 * INPUT: *
64 * *
65 * OUTPUT: *
66 * *
67 * WARNINGS: *
68 * *
69 * HISTORY: *
70 * 2/26/2001 gth : Created. *
71 *=============================================================================================*/
73 Shader(0),
77{
78 for (int i=0; i<MAX_TEX_STAGES; i++) {
79 Texture[i] = NULL;
80 }
81}
82
83/***********************************************************************************************
84 * MaterialPassClass::~MaterialPassClass -- Destructor *
85 * *
86 * INPUT: *
87 * *
88 * OUTPUT: *
89 * *
90 * WARNINGS: *
91 * *
92 * HISTORY: *
93 * 12/9/99 gth : Created. *
94 * 06/27/02 kjm : Changes to max texture stage caps *
95 *=============================================================================================*/
97{
98 for (int i=0; i<MAX_TEX_STAGES; i++) {
100 }
102}
103
104
105/***********************************************************************************************
106 * MaterialPassClass::Install_Materials -- Plug our material settings into D3D *
107 * *
108 * INPUT: *
109 * *
110 * OUTPUT: *
111 * *
112 * WARNINGS: *
113 * *
114 * HISTORY: *
115 * 12/9/99 gth : Created. *
116 * 2/26/2001 gth : Changed to Install_Materials *
117 *=============================================================================================*/
127
128
129/***********************************************************************************************
130 * MaterialPassClass::Set_Texture -- Set texture to use *
131 * *
132 * INPUT: *
133 * tex - pointer to the texture for this material pass (or NULL) *
134 * *
135 * OUTPUT: *
136 * *
137 * WARNINGS: *
138 * *
139 * HISTORY: *
140 * 12/9/99 gth : Created. *
141 *=============================================================================================*/
143{
144 WWASSERT(stage >= 0);
145 WWASSERT(stage < MAX_TEX_STAGES);
146
147 REF_PTR_SET(Texture[stage],tex);
148}
149
150
151/***********************************************************************************************
152 * MaterialPassClass::Set_Shader -- Set the shader to use *
153 * *
154 * INPUT: *
155 * shader - shader for this material pass *
156 * *
157 * OUTPUT: *
158 * *
159 * WARNINGS: *
160 * *
161 * HISTORY: *
162 * 12/9/99 gth : Created. *
163 *=============================================================================================*/
165{
166 Shader = shader;
167 Shader.Enable_Fog ("MaterialPassClass");
168}
169
170
171/***********************************************************************************************
172 * MaterialPassClass::Set_Material -- set vertex material to use *
173 * *
174 * INPUT: *
175 * mat - pointer to the vertex material this material pass uses *
176 * *
177 * OUTPUT: *
178 * *
179 * WARNINGS: *
180 * *
181 * HISTORY: *
182 * 12/9/99 gth : Created. *
183 *=============================================================================================*/
188
189
190/***********************************************************************************************
191 * MaterialPassClass::Get_Texture -- Get a pointer to the texture *
192 * *
193 * INPUT: *
194 * *
195 * OUTPUT: *
196 * reference counted pointer to the texture this material pass is using *
197 * *
198 * WARNINGS: *
199 * *
200 * HISTORY: *
201 * 12/9/99 gth : Created. *
202 *=============================================================================================*/
204{
205 WWASSERT(stage >= 0);
206 WWASSERT(stage < MAX_TEX_STAGES);
207
208 if (Texture[stage]) {
209 Texture[stage]->Add_Ref();
210 }
211 return Texture[stage];
212}
213
214
215/***********************************************************************************************
216 * MaterialPassClass::Get_Material -- get the vertex material *
217 * *
218 * INPUT: *
219 * *
220 * OUTPUT: *
221 * reference counted pointer to the vertex material being used by this material pass *
222 * *
223 * WARNINGS: *
224 * *
225 * HISTORY: *
226 * 12/9/99 gth : Created. *
227 *=============================================================================================*/
229{
230 if (Material) {
231 Material->Add_Ref();
232 }
233 return Material;
234}
#define NULL
Definition BaseType.h:92
#define WWASSERT
@ true
Definition bool.h:59
int Get_Max_Textures_Per_Pass() const
Definition dx8caps.h:232
static void Set_Texture(unsigned stage, TextureBaseClass *texture)
static const DX8Caps * Get_Current_Caps()
Definition dx8wrapper.h:536
static void Set_Material(const VertexMaterialClass *material)
static void Set_Shader(const ShaderClass &shader)
void Set_Texture(TextureClass *Texture, int stage=0)
reset/cleanup D3D states
Definition matpass.cpp:142
void Set_Shader(ShaderClass shader)
Definition matpass.cpp:164
VertexMaterialClass * Peek_Material(void) const
Definition matpass.h:98
OBBoxClass * CullVolume
Definition matpass.h:118
ShaderClass Peek_Shader(void) const
Definition matpass.h:97
virtual void Install_Materials(void) const
MW: Had to make this virtual so app can perform direct/custom D3D setup.
Definition matpass.cpp:118
static bool EnablePerPolygonCulling
Definition matpass.h:119
TextureClass * Texture[MAX_TEX_STAGES]
Definition matpass.h:113
bool EnableOnTranslucentMeshes
Definition matpass.h:116
TextureClass * Peek_Texture(int stage=0) const
Definition matpass.h:124
VertexMaterialClass * Get_Material(void) const
Definition matpass.cpp:228
void Set_Material(VertexMaterialClass *mat)
Definition matpass.cpp:184
MaterialPassClass(void)
Definition matpass.cpp:72
VertexMaterialClass * Material
Definition matpass.h:115
~MaterialPassClass(void)
Definition matpass.cpp:96
TextureClass * Get_Texture(int stage=0) const
Definition matpass.cpp:203
ShaderClass Shader
Definition matpass.h:114
#define REF_PTR_RELEASE(x)
Definition refcount.h:80
#define REF_PTR_SET(dst, src)
Definition refcount.h:79