Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
shdrenderer.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/shdrenderer.h $*
26 *
27 * Org Author:: Jani_p
28 * *
29 * $Author:: Kenny_m
30 *
31 * $Modtime:: 6/06/02 3:04p $*
32 * *
33 * $Revision:: 3 $*
34 * *
35 *---------------------------------------------------------------------------------------------*
36 * Functions: *
37 * 6/02/02 5:59p KM Added render info and light environment support $*
38 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
39
40#ifndef SHDRENDERER_H
41#define SHDRENDERER_H
42
43#include "multilist.h"
44#include "refcount.h"
45#include "shdinterface.h"
46
47class ShdSubMeshClass;
48class ShdMeshClass;
49class RenderInfoClass;
50
53
58
60{
61 int Pass;
62 ShdRendererNodeList LinkedNodes;
63 ShdRendererNodeList VisibleNodes;
64public:
67
69 VisibleNodes.Add_Tail(node);
70 }
71
72 ShdRendererNodeList& Peek_Linked_Nodes() { return LinkedNodes; }
73
74 void Flush();
75
77 void Unregister_All();
78
79};
80
87{
88 RendererListContainerClass* RendererListContainer[SHD_MAX_PASSES];
89 int MaxPass;
90public:
91 ShdRendererNodeClass() : MaxPass(0)
92 {
93 for (int a=0;a<SHD_MAX_PASSES;++a) {
94 RendererListContainer[a]=0;
95 }
96 }
98 {
99 for (int a=0;a<SHD_MAX_PASSES;++a) {
100 REF_PTR_RELEASE(RendererListContainer[a]);
101 }
102 }
103
104 virtual void Render(RenderInfoClass& rinfo)=0;
105 virtual void Flush(int pass)=0;
106 virtual void Apply_Shared_Shader_Settings(ShdRendererNodeClass* prev_node, int pass)=0;
107
108 virtual bool Greater_Than(const ShdRendererNodeClass&, int pass) const =0;
109
110 void Connect()
111 {
112 for (int pass=0;pass<=MaxPass;++pass) {
113 WWASSERT(RendererListContainer[pass]);
114 if (RendererListContainer[pass]) RendererListContainer[pass]->Add_Visible_Node(this);
115 }
116 }
117
119 {
120 REF_PTR_SET(RendererListContainer[pass],cont);
121 if (cont) MaxPass=max(MaxPass,pass);
122 }
123 RendererListContainerClass* Peek_Renderer_List_Container(int pass) { return RendererListContainer[pass]; }
124};
125
126
131{
132 static ShdRendererClass* ShdRenderer;
133
134protected:
136 virtual ~ShdRendererClass();
137public:
138
140 // Init must be called before any objects can be rendered and Release() must be called
141 // at the end to release all references to the rendering API. Working through a static
142 // pointer instead of calling static functions will later allow us to switch to another
143 // rendering API implementation of the renderer.
145 static void Init();
146 static void Shutdown();
147
148 static void Init_Shaders();
149 static void Shutdown_Shaders();
150
151 static ShdRendererClass* Peek_Instance() { return ShdRenderer; }
152
154 // Register initialized a mesh for rendering.
157
159 // Flush all linked meshes to the rendering system
161 virtual void Flush()=0;
162};
163
164
169{
170public:
172 virtual ~ShdDX8RendererClass();
173
175 // Register initialized a mesh for rendering. Note, these will need to be virtual
176 // if new types of renderers are created.
179
181 // Flush all linked meshes to the rendering system
183 virtual void Flush();
184
185 class MeshContainerClass;
186private:
187 MeshContainerClass** MeshCategories;
188
189};
190
191#endif //SHDRENDERER_H
#define max(x, y)
Definition BaseType.h:105
#define WWASSERT
RefCountClass(void)
Definition refcount.h:108
void Add_Visible_Node(ShdRendererNodeClass *node)
Definition shdrenderer.h:68
ShdRendererNodeList & Peek_Linked_Nodes()
Definition shdrenderer.h:72
void Register_Renderer(ShdRendererNodeClass *node)
virtual ~ShdDX8RendererClass()
virtual ShdRendererNodeClass * Register_Mesh(ShdMeshClass *mesh, ShdSubMeshClass *sub_mesh)
virtual void Flush()
static void Shutdown()
static void Init()
virtual ShdRendererNodeClass * Register_Mesh(ShdMeshClass *mesh, ShdSubMeshClass *sub_mesh)=0
virtual ~ShdRendererClass()
static ShdRendererClass * Peek_Instance()
static void Init_Shaders()
static void Shutdown_Shaders()
virtual void Flush()=0
void Set_Renderer_List_Container(RendererListContainerClass *cont, int pass)
virtual ~ShdRendererNodeClass()
Definition shdrenderer.h:97
virtual bool Greater_Than(const ShdRendererNodeClass &, int pass) const =0
virtual void Render(RenderInfoClass &rinfo)=0
virtual void Apply_Shared_Shader_Settings(ShdRendererNodeClass *prev_node, int pass)=0
virtual void Flush(int pass)=0
RendererListContainerClass * Peek_Renderer_List_Container(int pass)
#define REF_PTR_RELEASE(x)
Definition refcount.h:80
#define REF_PTR_SET(dst, src)
Definition refcount.h:79
const int SHD_MAX_PASSES
MultiListIterator< ShdRendererNodeClass > ShdRendererNodeListIterator
Definition shdrenderer.h:55
MultiListClass< ShdRendererNodeClass > ShdRendererNodeList
Definition shdrenderer.h:54
MultiListClass< RendererListContainerClass > RendererListContainerList
Definition shdrenderer.h:56
MultiListIterator< RendererListContainerClass > RendererListContainerIterator
Definition shdrenderer.h:57