Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
dx8renderer.h
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/dx8renderer.h $*
26 * *
27 * Original Author:: Jani Penttinen *
28 * *
29 * Author : Kenny Mitchell *
30 * *
31 * $Modtime:: 06/27/02 1:27p $*
32 * *
33 * $Revision:: 29 $*
34 * *
35 * 06/27/02 KM Changes to max texture stage caps *
36 *---------------------------------------------------------------------------------------------*
37 * Functions: *
38 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
39
40
41#if defined(_MSC_VER)
42#pragma once
43#endif
44
45#ifndef DX8_RENDERER_H
46#define DX8_RENDERER_H
47
48#include "always.h"
49#include "wwstring.h"
50#include "simplevec.h"
51#include "refcount.h"
52#include "vector.h"
53#include "dx8list.h"
54#include "shader.h"
55#include "dx8wrapper.h"
56#include "meshmatdesc.h"
57
60class DX8RenderTypeArrayClass;
61class MeshClass;
62class MeshModelClass;
66class DecalMeshClass;
70class TextureClass;
72class CameraClass;
73
74#define RECORD_RENDER(I,P) render_stats[I].count++; render_stats[I].polys+=P;
75
84{
85 int pass;
87 ShaderClass shader;
88 VertexMaterialClass * material;
89 DX8PolygonRendererList PolygonRendererList;
90 DX8FVFCategoryContainer* container;
91
92 PolyRenderTaskClass * render_task_head; // polygon renderers queued for rendering
93 static bool m_gForceMultiply; // Forces opaque materials to use the multiply blend - pseudo transparent effect. jba.
94
95public:
96
99
100 void Add_Render_Task(DX8PolygonRendererClass * p_renderer,MeshClass * p_mesh);
101
102 void Render(void);
103 bool Anything_To_Render() { return (render_task_head != NULL); }
104 void Clear_Render_List() { render_task_head = NULL; }
105
106 TextureClass * Peek_Texture(int stage) { return textures[stage]; }
107 const VertexMaterialClass * Peek_Material() { return material; }
108 ShaderClass Get_Shader() { return shader; }
109
110 DX8PolygonRendererList& Get_Polygon_Renderer_List() { return PolygonRendererList; }
111
112 unsigned Add_Mesh(
113 Vertex_Split_Table& split_buffer,
114 unsigned vertex_offset,
115 unsigned index_offset,
116 IndexBufferClass* index_buffer,
117 unsigned pass);
118 void Log(bool only_visible);
119
122
123
124 DX8FVFCategoryContainer * Get_Container(void) { return container; }
125
126 // Force multiply blend on all objects inserted from now on. (Doesn't affect the objects that are already in the lists)
127 static void SetForceMultiply(bool multiply) { m_gForceMultiply=multiply; }
128
129};
130
131// ----------------------------------------------------------------------------
132
136
138{
139public:
140 enum {
142 };
143protected:
144
147
150
153 unsigned FVF;
154 unsigned passes;
159
160 void Generate_Texture_Categories(Vertex_Split_Table& split_table,unsigned vertex_offset);
162 Vertex_Split_Table& split_table,
163 TextureClass** textures,
165 ShaderClass shader,
166 int pass,
167 unsigned vertex_offset);
168
169 inline bool Anything_To_Render() { return AnythingToRender; }
171
173
175 TextureClass* texture,
176 unsigned pass,
177 unsigned stage,
178 DX8TextureCategoryClass* ref_category);
179
182 unsigned pass,
183 DX8TextureCategoryClass* ref_category);
184
185public:
186
187 DX8FVFCategoryContainer(unsigned FVF,bool sorting);
188 virtual ~DX8FVFCategoryContainer();
189
190 static unsigned Define_FVF(MeshModelClass* mmc,bool enable_lighting);
191 bool Is_Sorting() const { return sorting; }
192
194 DX8PolygonRendererList& polygon_renderer_list,
195 TextureClass* texture,
196 TextureClass* new_texture,
197 unsigned pass,
198 unsigned stage);
199
201 DX8PolygonRendererList& polygon_renderer_list,
203 VertexMaterialClass* new_vmat,
204 unsigned pass);
205
207
208 virtual void Render(void)=0;
209 virtual void Add_Mesh(MeshModelClass* mmc)=0;
210 virtual void Log(bool only_visible)=0;
211 virtual bool Check_If_Mesh_Fits(MeshModelClass* mmc)=0;
212
213 inline unsigned Get_FVF() const { return FVF; }
214
215 inline void Add_Visible_Texture_Category(DX8TextureCategoryClass * tex_category,int pass)
216 {
217 WWASSERT(pass<MAX_PASSES);
218 WWASSERT(tex_category != NULL);
219 WWASSERT(texture_category_list[pass].Contains(tex_category));
220 visible_texture_category_list[pass].Add(tex_category);
221 AnythingToRender=true;
222 }
223
224 /*
225 ** Material pass rendering. The following two functions allow procedural material passes
226 ** to be applied to meshes in this FVF category. In certain cases, the game will *only* render
227 ** the procedural pass and not the base materials for the mesh. When this happens there can
228 ** be rendering errors unless these procedural passes are rendered after all of the meshes in
229 ** the scene. The virtual method Add_Delayed_Material_Pass is used in this case.
230 */
234};
235
236
242{
243public:
246
247 void Add_Mesh(MeshModelClass* mmc);
248 void Log(bool only_visible);
250
251 void Render(void); // Generic render function
252
253 /*
254 ** This method adds a material pass which must be rendered after all of the other rendering is complete.
255 ** This is needed whenever a mesh turns off its base passes and renders a translucent pass on its geometry.
256 */
259
260protected:
261
262
265
268
269};
270
271
277{
278public:
281
282 void Render(void);
283 void Add_Mesh(MeshModelClass* mmc);
284 void Log(bool only_visible);
286
287 void Add_Visible_Skin(MeshClass * mesh);
288
289 /*
290 ** Since skins are already rendered after the rigid meshes, the Add_Delayed_Material_Pass function simply
291 ** routes into the Add_Visible_Material_Pass method and no extra overhead is added.
292 */
295
296private:
297
298 void Reset();
299 void clearVisibleSkinList();
300
301 unsigned int VisibleVertexCount;
302 MeshClass * VisibleSkinHead;
303 MeshClass * VisibleSkinTail;
304
305};
306
307
308
317{
318public:
321
322 void Init();
323 void Shutdown();
324
325 void Flush();
327
328 void Log_Statistics_String(bool only_visible);
329 static void Request_Log_Statistics();
330
333 void Set_Camera(CameraClass* cam) { camera=cam; }
334 CameraClass * Peek_Camera(void) { return camera; }
335 void Add_To_Render_List(DecalMeshClass * decalmesh);
336
337 // Enable or disable lighting on all objects inserted from now on. (Doesn't affect the objects that are already in the lists)
338 void Enable_Lighting(bool enable) { enable_lighting=enable; }
339
340 // This should be called at the beginning of a game or menu or after a major modifications to the scene...
341 void Invalidate(bool shutdown=false); // Added flag so it doesn't allocate more mem when shutting down. -MW
342
343protected:
344
345 void Render_Decal_Meshes(void);
346
349
352
354
355
356};
357
359
360#endif
#define NULL
Definition BaseType.h:92
#define WWASSERT
IndexBufferClass * index_buffer
TextureCategoryList texture_category_list[MAX_PASSES]
virtual void Log(bool only_visible)=0
void Add_Visible_Material_Pass(MaterialPassClass *pass, MeshClass *mesh)
void Insert_To_Texture_Category(Vertex_Split_Table &split_table, TextureClass **textures, VertexMaterialClass *mat, ShaderClass shader, int pass, unsigned vertex_offset)
virtual void Add_Mesh(MeshModelClass *mmc)=0
virtual void Render_Delayed_Procedural_Material_Passes(void)=0
TextureCategoryList visible_texture_category_list[MAX_PASSES]
MatPassTaskClass * visible_matpass_tail
void Change_Polygon_Renderer_Texture(DX8PolygonRendererList &polygon_renderer_list, TextureClass *texture, TextureClass *new_texture, unsigned pass, unsigned stage)
MatPassTaskClass * visible_matpass_head
virtual void Render(void)=0
unsigned Get_FVF() const
void Render_Procedural_Material_Passes(void)
static unsigned Define_FVF(MeshModelClass *mmc, bool enable_lighting)
virtual void Add_Delayed_Visible_Material_Pass(MaterialPassClass *pass, MeshClass *mesh)=0
void Remove_Texture_Category(DX8TextureCategoryClass *tex_category)
virtual bool Check_If_Mesh_Fits(MeshModelClass *mmc)=0
void Add_Visible_Texture_Category(DX8TextureCategoryClass *tex_category, int pass)
DX8TextureCategoryClass * Find_Matching_Texture_Category(TextureClass *texture, unsigned pass, unsigned stage, DX8TextureCategoryClass *ref_category)
DX8FVFCategoryContainer(unsigned FVF, bool sorting)
void Generate_Texture_Categories(Vertex_Split_Table &split_table, unsigned vertex_offset)
void Change_Polygon_Renderer_Material(DX8PolygonRendererList &polygon_renderer_list, VertexMaterialClass *vmat, VertexMaterialClass *new_vmat, unsigned pass)
void Invalidate(bool shutdown=false)
void Set_Camera(CameraClass *cam)
DecalMeshClass * visible_decal_meshes
void Render_Decal_Meshes(void)
void Log_Statistics_String(bool only_visible)
CameraClass * camera
SimpleDynVecClass< FVFCategoryList * > texture_category_container_lists_rigid
FVFCategoryList * texture_category_container_list_skin
CameraClass * Peek_Camera(void)
static void Request_Log_Statistics()
void Add_To_Render_List(DecalMeshClass *decalmesh)
void Unregister_Mesh_Type(MeshModelClass *mmc)
void Enable_Lighting(bool enable)
void Register_Mesh_Type(MeshModelClass *mmc)
MatPassTaskClass * delayed_matpass_tail
void Add_Mesh(MeshModelClass *mmc)
virtual void Render_Delayed_Procedural_Material_Passes(void)
bool Check_If_Mesh_Fits(MeshModelClass *mmc)
VertexBufferClass * vertex_buffer
void Log(bool only_visible)
DX8RigidFVFCategoryContainer(unsigned FVF, bool sorting)
MatPassTaskClass * delayed_matpass_head
virtual void Add_Delayed_Visible_Material_Pass(MaterialPassClass *pass, MeshClass *mesh)
void Add_Visible_Skin(MeshClass *mesh)
virtual void Add_Delayed_Visible_Material_Pass(MaterialPassClass *pass, MeshClass *mesh)
virtual void Render_Delayed_Procedural_Material_Passes(void)
void Add_Mesh(MeshModelClass *mmc)
DX8SkinFVFCategoryContainer(bool sorting)
bool Check_If_Mesh_Fits(MeshModelClass *mmc)
void Log(bool only_visible)
void Add_Render_Task(DX8PolygonRendererClass *p_renderer, MeshClass *p_mesh)
DX8FVFCategoryContainer * Get_Container(void)
ShaderClass Get_Shader()
void Add_Polygon_Renderer(DX8PolygonRendererClass *p_renderer, DX8PolygonRendererClass *add_after_this=NULL)
unsigned Add_Mesh(Vertex_Split_Table &split_buffer, unsigned vertex_offset, unsigned index_offset, IndexBufferClass *index_buffer, unsigned pass)
DX8PolygonRendererList & Get_Polygon_Renderer_List()
DX8TextureCategoryClass(DX8FVFCategoryContainer *container, TextureClass **textures, ShaderClass shd, VertexMaterialClass *mat, int pass)
const VertexMaterialClass * Peek_Material()
void Log(bool only_visible)
void Remove_Polygon_Renderer(DX8PolygonRendererClass *p_renderer)
TextureClass * Peek_Texture(int stage)
static void SetForceMultiply(bool multiply)
MultiListClass< DX8TextureCategoryClass > TextureCategoryList
Definition dx8list.h:57
MultiListClass< DX8FVFCategoryContainer > FVFCategoryList
Definition dx8list.h:61
MultiListClass< DX8PolygonRendererClass > DX8PolygonRendererList
Definition dx8list.h:65
DX8MeshRendererClass TheDX8MeshRenderer