Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
shdlegacyw3d.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
21#ifndef SHDLEGACYW3D_H
22#define SHDLEGACYW3D_H
23
24#include "shdinterface.h"
25#include "shddef.h"
26#include "meshmatdesc.h"
27
35{
36public:
37
39 // Editable interface requirements
42
45 virtual ~ShdLegacyW3DDefClass();
46
47 virtual ShdDefClass* Clone() const { return new ShdLegacyW3DDefClass(*this); }
48
49 // Shader Creation (should create a shader compatible with the current hardware/API)
50 virtual void Init();
51 virtual void Shutdown();
52 virtual ShdInterfaceClass* Create() const;
53
54 // Validation methods
55 virtual bool Is_Valid_Config(StringClass &message);
56
57 // Requirements
58 virtual bool Requires_Normals() const { return true; }
59 virtual bool Requires_Tangent_Space_Vectors() const { return false; }
60 virtual bool Requires_Sorting() const { return false; }
61 virtual int Static_Sort_Index() const { return 0; }
62 virtual bool Uses_UV_Channel(int i) const;
63
64 // From PersistClass
65 virtual bool Save(ChunkSaveClass &csave);
66 virtual bool Load(ChunkLoadClass &cload);
67
68 // Accessors
69 int Get_Pass_Count() { return PassCount; }
70 const StringClass& Get_Texture_Name(int pass, int stage) { return TextureNames[pass][stage]; }
71 int Get_Texture_Attributes(int pass,int stage) { return TextureAttributes[pass][stage]; }
72 const W3dShaderStruct& Get_Shader(int pass) { return Shaders[pass]; }
73 const W3dVertexMaterialStruct & Get_Material(int pass) { return Materials[pass]; }
74 StringClass & Get_Mapper_Args(int pass,int stage) { return MapperArgs[pass][stage]; }
75 int Get_Map_Channel(int pass,int stage) { return MapChannel[pass][stage]; }
76
77 void Set_Pass_Count(int passes) { PassCount=passes; }
78 void Set_Texture_Name(int pass, int stage, const StringClass& name) { TextureNames[pass][stage]=name; }
79 void Set_Texture_Attributes(int pass, int stage, unsigned int attributes) { TextureAttributes[pass][stage] = attributes; }
80 void Set_Shader(int pass, const W3dShaderStruct& shader) { Shaders[pass] = shader; }
81 void Set_Material(int pass, const W3dVertexMaterialStruct& mat) { Materials[pass] = mat; }
82 void Set_Mapper_Args(int pass, int stage,const char * args) { MapperArgs[pass][stage] = args; }
83 void Set_Map_Channel(int pass, int stage, int channel) { MapChannel[pass][stage] = channel; }
84
85private:
86
87 bool Save_Variables(ChunkSaveClass &csave);
88 bool Load_Variables(ChunkLoadClass &cload);
89
90 int PassCount;
91
92 // Textures
95
96 // Shaders
98
99 // Materials
103
104};
105
106
107
109{
110public:
112 virtual ~Shd6LegacyW3DClass();
113
114 static void Init();
115 static void Shutdown();
116
117 virtual bool Greater_Than(const ShdInterfaceClass& s,int pass) const;
118
119 virtual int Get_Pass_Count() { return PassCount; }
120 void Set_Pass_Count(int pass_count) { PassCount=pass_count; }
121
122 virtual int Get_Texture_Count() const { return 0; }
123 virtual TextureClass* Peek_Texture(int idx) const { return NULL; }
124
125 virtual void Apply_Shared(int cur_pass, RenderInfoClass& rinfo);
126 virtual void Apply_Instance(int cur_pass, RenderInfoClass& rinfo);
127
128 virtual unsigned Get_Vertex_Stream_Count() const;
129 virtual unsigned Get_Vertex_Size(unsigned stream) const;
130 virtual bool Use_HW_Vertex_Processing() const { return true; }
131
132 virtual void Copy_Vertex_Stream
133 (
134 unsigned stream,
135 void* dest_buffer,
136 const VertexStreamStruct& vss,
137 unsigned vertex_count
138 );
139
140 virtual bool Is_Opaque(void) const { return (Shaders[0].Get_Dst_Blend_Func() == ShaderClass::DSTBLEND_ZERO); }
141
142 // Shd6LegacyW3DClass Accessors
143 VertexMaterialClass* Get_Material(int pass) { if (Materials[pass]) Materials[pass]->Add_Ref(); return Materials[pass]; }
144 void Set_Material(int pass,VertexMaterialClass* mat) { REF_PTR_SET(Materials[pass],mat); }
145 const ShaderClass& Get_Shader(int pass) { return Shaders[pass]; }
146 void Set_Shader(int pass,const ShaderClass& shader) { Shaders[pass]=shader; }
147 void Set_Texture(int pass,int stage,TextureClass* texture) { REF_PTR_SET(Textures[pass][stage],texture); }
148 void Set_FVF(unsigned fvf) { FVF=fvf; }
149
150protected:
151
152 unsigned FVF;
157
158};
159
160#endif //SHDLEGACYW3D_H
#define NULL
Definition BaseType.h:92
@ DSTBLEND_ZERO
Definition shader.h:172
virtual ~Shd6LegacyW3DClass()
virtual bool Use_HW_Vertex_Processing() const
virtual bool Is_Opaque(void) const
virtual void Copy_Vertex_Stream(unsigned stream, void *dest_buffer, const VertexStreamStruct &vss, unsigned vertex_count)
const ShaderClass & Get_Shader(int pass)
static void Shutdown()
void Set_Pass_Count(int pass_count)
virtual void Apply_Instance(int cur_pass, RenderInfoClass &rinfo)
Apply per instance states for 1 pass DX6.
Shd6LegacyW3DClass(const ShdDefClass *def)
virtual TextureClass * Peek_Texture(int idx) const
virtual bool Greater_Than(const ShdInterfaceClass &s, int pass) const
VertexMaterialClass * Materials[MeshMatDescClass::MAX_PASSES]
virtual unsigned Get_Vertex_Stream_Count() const
ShaderClass Shaders[MeshMatDescClass::MAX_PASSES]
void Set_Texture(int pass, int stage, TextureClass *texture)
void Set_Material(int pass, VertexMaterialClass *mat)
virtual void Apply_Shared(int cur_pass, RenderInfoClass &rinfo)
virtual int Get_Pass_Count()
VertexMaterialClass * Get_Material(int pass)
void Set_Shader(int pass, const ShaderClass &shader)
TextureClass * Textures[MeshMatDescClass::MAX_PASSES][MeshMatDescClass::MAX_TEX_STAGES]
virtual unsigned Get_Vertex_Size(unsigned stream) const
void Set_FVF(unsigned fvf)
virtual int Get_Texture_Count() const
ShdDefClass(uint32 class_id)
Definition shddef.cpp:45
ShdInterfaceClass(const ShdDefClass *def, int class_id)
Constructor.
virtual bool Uses_UV_Channel(int i) const
virtual ShdDefClass * Clone() const
virtual bool Load(ChunkLoadClass &cload)
Load this ShdDef from a chunk loader.
virtual bool Requires_Tangent_Space_Vectors() const
StringClass & Get_Mapper_Args(int pass, int stage)
void Set_Shader(int pass, const W3dShaderStruct &shader)
int Get_Texture_Attributes(int pass, int stage)
void Set_Map_Channel(int pass, int stage, int channel)
const W3dVertexMaterialStruct & Get_Material(int pass)
int Get_Map_Channel(int pass, int stage)
virtual bool Save(ChunkSaveClass &csave)
Serialize this ShdDef into a chunk saver.
virtual int Static_Sort_Index() const
void Set_Material(int pass, const W3dVertexMaterialStruct &mat)
virtual ShdInterfaceClass * Create() const
virtual bool Requires_Sorting() const
DECLARE_EDITABLE(ShdLegacyW3DDefClass, ShdDefClass)
virtual void Shutdown()
void Set_Texture_Attributes(int pass, int stage, unsigned int attributes)
void Set_Pass_Count(int passes)
void Set_Mapper_Args(int pass, int stage, const char *args)
virtual bool Is_Valid_Config(StringClass &message)
const StringClass & Get_Texture_Name(int pass, int stage)
const W3dShaderStruct & Get_Shader(int pass)
virtual ~ShdLegacyW3DDefClass()
virtual bool Requires_Normals() const
void Set_Texture_Name(int pass, int stage, const StringClass &name)
#define REF_PTR_SET(dst, src)
Definition refcount.h:79