Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
shdinterface.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 : WWSHADE *
24 * *
25 * $Archive:: wwshade/shdinterface.h $*
26 * *
27 * $Org Author:: Jani_p
28 *
29 * $Author:: Kenny_m
30 *
31 * $Modtime:: 6/05/02 3:12p $*
32 * *
33 * $Revision:: 2 $*
34 * *
35 * 6/05/02 KJM : Added texture info functions
36 *---------------------------------------------------------------------------------------------*
37 * Functions: *
38 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
39
40#ifndef SHDINTERFACE_H
41#define SHDINTERFACE_H
42
43#include "always.h"
44#include "refcount.h"
45#include "dx8wrapper.h"
46
47class ShdDefClass;
48class ShdMeshClass;
49class RenderInfoClass;
50class TextureClass;
51
52/*
53** Maximum passes allowed for any shader implementation!
54*/
55const int SHD_MAX_PASSES = 4;
56
64{
66 : Locations(0),
67 Normals(0),
68 DiffuseInt(0),
70 {
71 for (int i=0;i<MAX_TEXTURE_STAGES;++i)
72 {
73 UV[i]=0;
74 }
75 }
76
80 const unsigned* DiffuseInt;
82 const Vector3* S;
83 const Vector3* T;
84 const Vector3* SxT;
85};
86
87
94{
95public:
96 ShdInterfaceClass(const ShdDefClass * def,int class_id);
97 virtual ~ShdInterfaceClass(void);
98
99 const ShdDefClass * Peek_Definition(void);
100
101 WWINLINE int Get_Class_ID() const { return ClassID; }
102
103 // For rendering efficiency, all shaders should implement comparison operator that the renderer
104 // can use to sort the meshes.
105 virtual bool Greater_Than (const ShdInterfaceClass& s,int pass) const { return true; }
106 virtual bool Similar_Enough (const ShdInterfaceClass& s,int pass) const { return true; }
107
108 virtual int Get_Pass_Count(void) = 0;
109 virtual bool Pass_Selection(ShdMeshClass*, RenderInfoClass*,int) { return true; }
110
111 virtual void Apply_Shared(int cur_pass, RenderInfoClass& rinfo) = 0;
112 virtual void Apply_Instance(int cur_pass, RenderInfoClass& rinfo) = 0;
113
114 // The shader needs to tell how many vertex streams it needs and what are the sizes of vertices
115 // in each stream.
116 virtual unsigned Get_Vertex_Stream_Count() const = 0;
117 virtual unsigned Get_Vertex_Size(unsigned stream) const = 0;
118
119 virtual bool Use_HW_Vertex_Processing() const = 0;
120
121 virtual int Get_Texture_Count() const = 0;
122 virtual TextureClass* Peek_Texture(int idx) const = 0;
123
124 // The shader needs to construct each vertex stream as requested. The data comes in a standard
125 // VertexStreamStruct, and the shader can format it as it wishes (nothing else will be using
126 // the buffer than the shader itself.
127 virtual void Copy_Vertex_Stream(unsigned stream, void* dest_buffer, const VertexStreamStruct& vss, unsigned vertex_count) = 0;
128
129 // Return whether this shader is opaque. This property is used to determine whether
130 // geometric shadows should be cast from an object for example. Alpha-Test shaders should
131 // return false to Is_Opaque.
132 virtual bool Is_Opaque(void) const { return true; }
133
134protected:
135
138
139};
140
141
142#endif //SHDINTERFACE_H
#define WWINLINE
Definition always.h:172
RefCountClass(void)
Definition refcount.h:108
virtual ~ShdInterfaceClass(void)
Destructor.
virtual int Get_Pass_Count(void)=0
ShdInterfaceClass(const ShdDefClass *def, int class_id)
Constructor.
WWINLINE int Get_Class_ID() const
virtual bool Is_Opaque(void) const
const ShdDefClass * Peek_Definition(void)
returns a pointer to the definition for this shader
virtual bool Pass_Selection(ShdMeshClass *, RenderInfoClass *, int)
virtual void Apply_Instance(int cur_pass, RenderInfoClass &rinfo)=0
virtual TextureClass * Peek_Texture(int idx) const =0
virtual bool Similar_Enough(const ShdInterfaceClass &s, int pass) const
virtual unsigned Get_Vertex_Size(unsigned stream) const =0
virtual bool Greater_Than(const ShdInterfaceClass &s, int pass) const
virtual void Apply_Shared(int cur_pass, RenderInfoClass &rinfo)=0
virtual unsigned Get_Vertex_Stream_Count() const =0
const ShdDefClass * Definition
virtual void Copy_Vertex_Stream(unsigned stream, void *dest_buffer, const VertexStreamStruct &vss, unsigned vertex_count)=0
virtual bool Use_HW_Vertex_Processing() const =0
virtual int Get_Texture_Count() const =0
const unsigned MAX_TEXTURE_STAGES
Definition dx8wrapper.h:76
const int SHD_MAX_PASSES
const Vector3 * Normals
const Vector2 * UV[MAX_TEXTURE_STAGES]
const Vector3 * S
const Vector4 * DiffuseFloat
const Vector3 * SxT
const Vector3 * T
const unsigned * DiffuseInt
const Vector3 * Locations