Skip to content

Commit 97a23e4

Browse files
committed
feat(ww3d2): add DX8Backend adapter forwarding to DX8Wrapper statics
1 parent 42f2aea commit 97a23e4

3 files changed

Lines changed: 446 additions & 0 deletions

File tree

Core/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ set(WW3D2_SRC
4343
distlod.cpp
4444
distlod.h
4545
dllist.h
46+
DX8Backend.cpp
47+
DX8Backend.h
4648
dx8caps.cpp
4749
dx8caps.h
4850
#dx8fvf.cpp
Lines changed: 321 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,321 @@
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+
// TheSuperHackers @refactor bobtista 10/04/2026 DX8Backend forwarding adapter.
20+
// Every method in this file is a one-line trampoline to the existing
21+
// DX8Wrapper static API. Keep it that way — if behavior needs to change it
22+
// should change in DX8Wrapper, not here.
23+
24+
#include "DX8Backend.h"
25+
26+
#include "dx8wrapper.h"
27+
#include "vector3.h"
28+
#include "matrix4.h"
29+
#include "matrix3d.h"
30+
#include "light.h"
31+
#include "lightenvironment.h"
32+
33+
DX8Backend::DX8Backend()
34+
{
35+
}
36+
37+
DX8Backend::~DX8Backend()
38+
{
39+
}
40+
41+
// -- Device state queries ----------------------------------------------------
42+
43+
bool DX8Backend::Is_Device_Lost() const
44+
{
45+
return DX8Wrapper::Is_Device_Lost();
46+
}
47+
48+
bool DX8Backend::Has_Stencil()
49+
{
50+
return DX8Wrapper::Has_Stencil();
51+
}
52+
53+
WW3DFormat DX8Backend::Get_Back_Buffer_Format()
54+
{
55+
return DX8Wrapper::getBackBufferFormat();
56+
}
57+
58+
SurfaceClass * DX8Backend::Get_Back_Buffer(unsigned int num)
59+
{
60+
return DX8Wrapper::_Get_DX8_Back_Buffer(num);
61+
}
62+
63+
void DX8Backend::Set_Gamma(float gamma, float bright, float contrast, bool calibrate, bool uselimit)
64+
{
65+
DX8Wrapper::Set_Gamma(gamma, bright, contrast, calibrate, uselimit);
66+
}
67+
68+
// -- Frame lifecycle ---------------------------------------------------------
69+
70+
void DX8Backend::Begin_Scene()
71+
{
72+
DX8Wrapper::Begin_Scene();
73+
}
74+
75+
void DX8Backend::End_Scene(bool flip_frame)
76+
{
77+
DX8Wrapper::End_Scene(flip_frame);
78+
}
79+
80+
void DX8Backend::Flip_To_Primary()
81+
{
82+
DX8Wrapper::Flip_To_Primary();
83+
}
84+
85+
void DX8Backend::Clear(bool clear_color, bool clear_z_stencil,
86+
const Vector3 & color,
87+
float dest_alpha, float z, unsigned int stencil)
88+
{
89+
DX8Wrapper::Clear(clear_color, clear_z_stencil, color, dest_alpha, z, stencil);
90+
}
91+
92+
void DX8Backend::Set_Viewport(const RenderBackendViewport & viewport)
93+
{
94+
D3DVIEWPORT8 vp;
95+
vp.X = viewport.x;
96+
vp.Y = viewport.y;
97+
vp.Width = viewport.width;
98+
vp.Height = viewport.height;
99+
vp.MinZ = viewport.min_z;
100+
vp.MaxZ = viewport.max_z;
101+
DX8Wrapper::Set_Viewport(&vp);
102+
}
103+
104+
// -- Vertex / index buffers --------------------------------------------------
105+
106+
void DX8Backend::Set_Vertex_Buffer(const VertexBufferClass * vb, unsigned int stream)
107+
{
108+
DX8Wrapper::Set_Vertex_Buffer(vb, stream);
109+
}
110+
111+
void DX8Backend::Set_Vertex_Buffer(const DynamicVBAccessClass & vba)
112+
{
113+
DX8Wrapper::Set_Vertex_Buffer(vba);
114+
}
115+
116+
void DX8Backend::Set_Index_Buffer(const IndexBufferClass * ib, unsigned short index_base_offset)
117+
{
118+
DX8Wrapper::Set_Index_Buffer(ib, index_base_offset);
119+
}
120+
121+
void DX8Backend::Set_Index_Buffer(const DynamicIBAccessClass & iba, unsigned short index_base_offset)
122+
{
123+
DX8Wrapper::Set_Index_Buffer(iba, index_base_offset);
124+
}
125+
126+
void DX8Backend::Set_Index_Buffer_Index_Offset(unsigned int offset)
127+
{
128+
DX8Wrapper::Set_Index_Buffer_Index_Offset(offset);
129+
}
130+
131+
// -- State: shaders, materials, textures ------------------------------------
132+
133+
void DX8Backend::Set_Shader(const ShaderClass & shader)
134+
{
135+
DX8Wrapper::Set_Shader(shader);
136+
}
137+
138+
void DX8Backend::Get_Shader(ShaderClass & shader)
139+
{
140+
DX8Wrapper::Get_Shader(shader);
141+
}
142+
143+
void DX8Backend::Set_Material(const VertexMaterialClass * material)
144+
{
145+
DX8Wrapper::Set_Material(material);
146+
}
147+
148+
void DX8Backend::Set_Texture(unsigned int stage, TextureBaseClass * texture)
149+
{
150+
DX8Wrapper::Set_Texture(stage, texture);
151+
}
152+
153+
void DX8Backend::Apply_Render_State_Changes()
154+
{
155+
DX8Wrapper::Apply_Render_State_Changes();
156+
}
157+
158+
void DX8Backend::Apply_Default_State()
159+
{
160+
DX8Wrapper::Apply_Default_State();
161+
}
162+
163+
void DX8Backend::Invalidate_Cached_Render_States()
164+
{
165+
DX8Wrapper::Invalidate_Cached_Render_States();
166+
}
167+
168+
// -- Transforms --------------------------------------------------------------
169+
170+
void DX8Backend::Set_Transform(TransformKind transform, const Matrix4x4 & m)
171+
{
172+
DX8Wrapper::Set_Transform(static_cast<D3DTRANSFORMSTATETYPE>(transform), m);
173+
}
174+
175+
void DX8Backend::Set_Transform(TransformKind transform, const Matrix3D & m)
176+
{
177+
DX8Wrapper::Set_Transform(static_cast<D3DTRANSFORMSTATETYPE>(transform), m);
178+
}
179+
180+
void DX8Backend::Get_Transform(TransformKind transform, Matrix4x4 & m)
181+
{
182+
DX8Wrapper::Get_Transform(static_cast<D3DTRANSFORMSTATETYPE>(transform), m);
183+
}
184+
185+
void DX8Backend::Set_World_Identity()
186+
{
187+
DX8Wrapper::Set_World_Identity();
188+
}
189+
190+
void DX8Backend::Set_View_Identity()
191+
{
192+
DX8Wrapper::Set_View_Identity();
193+
}
194+
195+
bool DX8Backend::Is_World_Identity()
196+
{
197+
return DX8Wrapper::Is_World_Identity();
198+
}
199+
200+
bool DX8Backend::Is_View_Identity()
201+
{
202+
return DX8Wrapper::Is_View_Identity();
203+
}
204+
205+
void DX8Backend::Set_Projection_Transform_With_Z_Bias(const Matrix4x4 & matrix, float znear, float zfar)
206+
{
207+
DX8Wrapper::Set_Projection_Transform_With_Z_Bias(matrix, znear, zfar);
208+
}
209+
210+
// -- Lighting and fog --------------------------------------------------------
211+
212+
void DX8Backend::Set_Light(unsigned int index, const LightClass & light)
213+
{
214+
DX8Wrapper::Set_Light(index, light);
215+
}
216+
217+
void DX8Backend::Set_Ambient(const Vector3 & color)
218+
{
219+
DX8Wrapper::Set_Ambient(color);
220+
}
221+
222+
const Vector3 & DX8Backend::Get_Ambient() const
223+
{
224+
return DX8Wrapper::Get_Ambient();
225+
}
226+
227+
void DX8Backend::Set_Fog(bool enable, const Vector3 & color, float start, float end)
228+
{
229+
DX8Wrapper::Set_Fog(enable, color, start, end);
230+
}
231+
232+
bool DX8Backend::Get_Fog_Enable() const
233+
{
234+
return DX8Wrapper::Get_Fog_Enable();
235+
}
236+
237+
void DX8Backend::Set_Light_Environment(LightEnvironmentClass * light_env)
238+
{
239+
DX8Wrapper::Set_Light_Environment(light_env);
240+
}
241+
242+
LightEnvironmentClass * DX8Backend::Get_Light_Environment() const
243+
{
244+
return DX8Wrapper::Get_Light_Environment();
245+
}
246+
247+
// -- Draw calls --------------------------------------------------------------
248+
249+
void DX8Backend::Draw_Triangles(unsigned short start_index,
250+
unsigned short polygon_count,
251+
unsigned short min_vertex_index,
252+
unsigned short vertex_count)
253+
{
254+
DX8Wrapper::Draw_Triangles(start_index, polygon_count, min_vertex_index, vertex_count);
255+
}
256+
257+
void DX8Backend::Draw_Triangles(unsigned int buffer_type,
258+
unsigned short start_index,
259+
unsigned short polygon_count,
260+
unsigned short min_vertex_index,
261+
unsigned short vertex_count)
262+
{
263+
DX8Wrapper::Draw_Triangles(buffer_type, start_index, polygon_count, min_vertex_index, vertex_count);
264+
}
265+
266+
void DX8Backend::Draw_Strip(unsigned short start_index,
267+
unsigned short index_count,
268+
unsigned short min_vertex_index,
269+
unsigned short vertex_count)
270+
{
271+
DX8Wrapper::Draw_Strip(start_index, index_count, min_vertex_index, vertex_count);
272+
}
273+
274+
// -- Programmable pipeline ---------------------------------------------------
275+
276+
void DX8Backend::Set_Vertex_Shader(unsigned long vertex_shader)
277+
{
278+
DX8Wrapper::Set_Vertex_Shader(static_cast<DWORD>(vertex_shader));
279+
}
280+
281+
void DX8Backend::Set_Pixel_Shader(unsigned long pixel_shader)
282+
{
283+
DX8Wrapper::Set_Pixel_Shader(static_cast<DWORD>(pixel_shader));
284+
}
285+
286+
void DX8Backend::Set_Vertex_Shader_Constant(int reg, const void * data, int count)
287+
{
288+
DX8Wrapper::Set_Vertex_Shader_Constant(reg, data, count);
289+
}
290+
291+
void DX8Backend::Set_Pixel_Shader_Constant(int reg, const void * data, int count)
292+
{
293+
DX8Wrapper::Set_Pixel_Shader_Constant(reg, data, count);
294+
}
295+
296+
// -- Render targets ----------------------------------------------------------
297+
298+
TextureClass * DX8Backend::Create_Render_Target(int width, int height, WW3DFormat format)
299+
{
300+
return DX8Wrapper::Create_Render_Target(width, height, format);
301+
}
302+
303+
void DX8Backend::Set_Render_Target_With_Z(TextureClass * texture, ZTextureClass * ztexture)
304+
{
305+
DX8Wrapper::Set_Render_Target_With_Z(texture, ztexture);
306+
}
307+
308+
bool DX8Backend::Is_Render_To_Texture()
309+
{
310+
return DX8Wrapper::Is_Render_To_Texture();
311+
}
312+
313+
void DX8Backend::Set_Shadow_Map(int idx, ZTextureClass * ztex)
314+
{
315+
DX8Wrapper::Set_Shadow_Map(idx, ztex);
316+
}
317+
318+
ZTextureClass * DX8Backend::Get_Shadow_Map(int idx)
319+
{
320+
return DX8Wrapper::Get_Shadow_Map(idx);
321+
}

0 commit comments

Comments
 (0)