Skip to content

Commit 19fe4f3

Browse files
committed
dx9 test, programs compile, don't launch yet
1 parent d31c6c5 commit 19fe4f3

266 files changed

Lines changed: 8637 additions & 7853 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ endif()
3333
# Top level project, doesn't really affect anything.
3434
project(genzh LANGUAGES C CXX)
3535

36+
if(WIN32)
37+
add_definitions(-D_WIN32_WINNT=0x0601)
38+
endif()
39+
3640
# This file handles extra settings wanted/needed for different compilers.
3741
include(cmake/compilers.cmake)
3842

@@ -52,7 +56,7 @@ endif()
5256
if((WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows") AND ${CMAKE_SIZEOF_VOID_P} EQUAL 4)
5357
include(cmake/miles.cmake)
5458
include(cmake/bink.cmake)
55-
include(cmake/dx8.cmake)
59+
include(cmake/DX9.cmake)
5660
endif()
5761

5862
# Define a dummy stlport target when not on VC6.

Core/GameEngine/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set(GAMEENGINE_SRC
1+
set(GAMEENGINE_SRC
22
# Include/Common/AcademyStats.h
33
# Include/Common/ActionManager.h
44
Include/Common/AddonCompat.h
@@ -1195,7 +1195,7 @@ target_link_libraries(corei_gameengine_public INTERFACE
11951195
core_compression
11961196
core_browserdispatch
11971197
#core_wwvegas
1198-
d3d8lib
1198+
d3d9lib
11991199
gamespy::gamespy
12001200
stlport
12011201
)

Core/GameEngine/Include/GameClient/Mouse.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
** Command & Conquer Generals Zero Hour(tm)
33
** Copyright 2025 Electronic Arts Inc.
44
**
@@ -255,7 +255,7 @@ class Mouse : public SubsystemInterface
255255
RM_WINDOWS=0, //default Windows cursor - very fast.
256256
RM_W3D, //W3D model tied to frame rate.
257257
RM_POLYGON, //alpha blended polygon tied to frame rate.
258-
RM_DX8, //hardware cursor independent of frame rate.
258+
RM_DX9, //hardware cursor independent of frame rate.
259259

260260
RM_MAX
261261
};

Core/GameEngine/Source/Common/System/Debug.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
** Command & Conquer Generals Zero Hour(tm)
33
** Copyright 2025 Electronic Arts Inc.
44
**
@@ -74,7 +74,7 @@
7474
#endif
7575

7676
// Horrible reference, but we really, really need to know if we are windowed.
77-
extern bool DX8Wrapper_IsWindowed;
77+
extern bool DX9Wrapper_IsWindowed;
7878
extern HWND ApplicationHWnd;
7979

8080
extern const char *gAppPrefix; /// So WB can have a different log file name.
@@ -151,7 +151,7 @@ static void doStackDump();
151151
// ----------------------------------------------------------------------------
152152
inline Bool ignoringAsserts()
153153
{
154-
if (!DX8Wrapper_IsWindowed)
154+
if (!DX9Wrapper_IsWindowed)
155155
return true;
156156
if (TheGlobalData && TheGlobalData->m_headless)
157157
return true;
@@ -749,7 +749,7 @@ void ReleaseCrash(const char *reason)
749749
{
750750
/// do additional reporting on the crash, if possible
751751

752-
if (!DX8Wrapper_IsWindowed) {
752+
if (!DX9Wrapper_IsWindowed) {
753753
if (ApplicationHWnd) {
754754
ShowWindow(ApplicationHWnd, SW_HIDE);
755755
}
@@ -799,7 +799,7 @@ void ReleaseCrash(const char *reason)
799799
theReleaseCrashLogFile = nullptr;
800800
}
801801

802-
if (!DX8Wrapper_IsWindowed) {
802+
if (!DX9Wrapper_IsWindowed) {
803803
if (ApplicationHWnd) {
804804
ShowWindow(ApplicationHWnd, SW_HIDE);
805805
}
@@ -841,7 +841,7 @@ void ReleaseCrashLocalized(const AsciiString& p, const AsciiString& m)
841841

842842
/// do additional reporting on the crash, if possible
843843

844-
if (!DX8Wrapper_IsWindowed) {
844+
if (!DX9Wrapper_IsWindowed) {
845845
if (ApplicationHWnd) {
846846
ShowWindow(ApplicationHWnd, SW_HIDE);
847847
}

Core/GameEngine/Source/GameClient/Input/Mouse.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
** Command & Conquer Generals Zero Hour(tm)
33
** Copyright 2025 Electronic Arts Inc.
44
**
@@ -57,7 +57,7 @@ const char *const Mouse::RedrawModeName[] = {
5757
"Mouse:Windows",
5858
"Mouse:W3D",
5959
"Mouse:Poly",
60-
"Mouse:DX8",
60+
"Mouse:DX9",
6161
};
6262

6363
const char *const Mouse::CursorCaptureBlockReasonNames[] = {

Core/GameEngineDevice/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ target_link_libraries(corei_gameenginedevice_private INTERFACE
223223
target_link_libraries(corei_gameenginedevice_public INTERFACE
224224
binkstub
225225
corei_gameengine_public
226-
d3d8lib
226+
d3d9lib
227+
dinput8
228+
dxguid
227229
milesstub
228230
)
229231

Core/GameEngineDevice/Include/W3DDevice/GameClient/BaseHeightMap.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,24 +79,24 @@ typedef struct {
7979
#endif
8080

8181
#define VERTEX_FORMAT VertexFormatXYZDUV2
82-
#define DX8_VERTEX_FORMAT DX8_FVF_XYZDUV2
82+
#define DX9_VERTEX_FORMAT DX9_FVF_XYZDUV2
8383

8484
/// Custom render object that draws the heightmap and handles intersection tests.
8585
/**
8686
Custom W3D render object that's used to process the terrain. It handles
8787
virtually everything to do with the terrain, including: drawing, lighting,
8888
scorchmarks and intersection tests.
8989
*/
90-
class BaseHeightMapRenderObjClass : public RenderObjClass, public DX8_CleanupHook, public Snapshot
90+
class BaseHeightMapRenderObjClass : public RenderObjClass, public DX9_CleanupHook, public Snapshot
9191
{
9292

9393
public:
9494

9595
BaseHeightMapRenderObjClass();
9696
virtual ~BaseHeightMapRenderObjClass() override;
9797

98-
// DX8_CleanupHook methods
99-
virtual void ReleaseResources() override; ///< Release all dx8 resources so the device can be reset.
98+
// DX9_CleanupHook methods
99+
virtual void ReleaseResources() override; ///< Release all DX9 resources so the device can be reset.
100100
virtual void ReAcquireResources() override; ///< Reacquire all resources after device reset.
101101

102102

@@ -243,8 +243,8 @@ class BaseHeightMapRenderObjClass : public RenderObjClass, public DX8_CleanupHoo
243243
MAX_SCORCH_MARKS=500,
244244
SCORCH_MARKS_IN_TEXTURE=9,
245245
SCORCH_PER_ROW = 3};
246-
DX8VertexBufferClass *m_vertexScorch; ///<Scorch vertex buffer.
247-
DX8IndexBufferClass *m_indexScorch; ///<indices defining a triangles for the scorch drawing.
246+
DX9VertexBufferClass *m_vertexScorch; ///<Scorch vertex buffer.
247+
DX9IndexBufferClass *m_indexScorch; ///<indices defining a triangles for the scorch drawing.
248248
TextureClass *m_scorchTexture; ///<Scorch mark texture
249249
Int m_curNumScorchVertices; ///<number of vertices used in m_vertexScorch.
250250
Int m_curNumScorchIndices; ///<number of indices used in m_indexScorch.

Core/GameEngineDevice/Include/W3DDevice/GameClient/FlatHeightMap.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ class FlatHeightMapRenderObjClass : public BaseHeightMapRenderObjClass
5252
FlatHeightMapRenderObjClass();
5353
virtual ~FlatHeightMapRenderObjClass() override;
5454

55-
// DX8_CleanupHook methods
56-
virtual void ReleaseResources() override; ///< Release all dx8 resources so the device can be reset.
55+
// DX9_CleanupHook methods
56+
virtual void ReleaseResources() override; ///< Release all DX9 resources so the device can be reset.
5757
virtual void ReAcquireResources() override; ///< Reacquire all resources after device reset.
5858

5959

Core/GameEngineDevice/Include/W3DDevice/GameClient/HeightMap.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ class HeightMapRenderObjClass : public BaseHeightMapRenderObjClass
5959
HeightMapRenderObjClass();
6060
virtual ~HeightMapRenderObjClass() override;
6161

62-
// DX8_CleanupHook methods
63-
virtual void ReleaseResources() override; ///< Release all dx8 resources so the device can be reset.
62+
// DX9_CleanupHook methods
63+
virtual void ReleaseResources() override; ///< Release all DX9 resources so the device can be reset.
6464
virtual void ReAcquireResources() override; ///< Reacquire all resources after device reset.
6565

6666

@@ -89,27 +89,27 @@ class HeightMapRenderObjClass : public BaseHeightMapRenderObjClass
8989
Int m_numExtraBlendTiles; ///<number of blend tiles in m_extraBlendTilePositions.
9090
Int m_numVisibleExtraBlendTiles; ///<number rendered last frame.
9191
Int m_extraBlendTilePositionsSize; //<total size of array including unused memory.
92-
DX8VertexBufferClass **m_vertexBufferTiles; ///<collection of smaller vertex buffers that make up 1 heightmap
92+
DX9VertexBufferClass **m_vertexBufferTiles; ///<collection of smaller vertex buffers that make up 1 heightmap
9393
VERTEX_FORMAT *m_vertexBufferBackup; ///< In memory copy of the vertex buffer data for quick update of dynamic lighting.
9494
Int m_originX; ///< Origin point in the grid. Slides around.
9595
Int m_originY; ///< Origin point in the grid. Slides around.
96-
DX8IndexBufferClass *m_indexBuffer; ///<indices defining triangles in a VB tile.
96+
DX9IndexBufferClass *m_indexBuffer; ///<indices defining triangles in a VB tile.
9797
Int m_numVBTilesX; ///<dimensions of array containing all the vertex buffers
9898
Int m_numVBTilesY; ///<dimensions of array containing all the vertex buffers
9999
Int m_numVertexBufferTiles; ///<number of vertex buffers needed to store this heightmap
100100
Int m_numBlockColumnsInLastVB;///<a VB tile may be partially filled, this indicates how many 2x2 vertex blocks are filled.
101101
Int m_numBlockRowsInLastVB;///<a VB tile may be partially filled, this indicates how many 2x2 vertex blocks are filled.
102102

103-
DX8VertexBufferClass *getVertexBufferTile(Int x, Int y);
103+
DX9VertexBufferClass *getVertexBufferTile(Int x, Int y);
104104
VERTEX_FORMAT *getVertexBufferBackup(Int x, Int y);
105105
UnsignedInt doTheDynamicLight(VERTEX_FORMAT *vb, VERTEX_FORMAT *vbMirror, Vector3*light, Vector3*normal, W3DDynamicLight *pLights[], Int numLights);
106106
Int getXWithOrigin(Int x);
107107
Int getYWithOrigin(Int x);
108108
///update vertex diffuse color for dynamic lights inside given rectangle
109-
Int updateVBForLight(DX8VertexBufferClass *pVB, VERTEX_FORMAT *data, Int x0, Int y0, Int x1, Int y1, Int originX, Int originY, W3DDynamicLight *pLights[], Int numLights);
110-
Int updateVBForLightOptimized(DX8VertexBufferClass *pVB, VERTEX_FORMAT *data, Int x0, Int y0, Int x1, Int y1, Int originX, Int originY, W3DDynamicLight *pLights[], Int numLights);
109+
Int updateVBForLight(DX9VertexBufferClass *pVB, VERTEX_FORMAT *data, Int x0, Int y0, Int x1, Int y1, Int originX, Int originY, W3DDynamicLight *pLights[], Int numLights);
110+
Int updateVBForLightOptimized(DX9VertexBufferClass *pVB, VERTEX_FORMAT *data, Int x0, Int y0, Int x1, Int y1, Int originX, Int originY, W3DDynamicLight *pLights[], Int numLights);
111111
///update vertex buffer vertices inside given rectangle
112-
Int updateVB(DX8VertexBufferClass *pVB, VERTEX_FORMAT *data, Int x0, Int y0, Int x1, Int y1, Int originX, Int originY, WorldHeightMap *pMap, RefRenderObjListIterator *pLightsIterator);
112+
Int updateVB(DX9VertexBufferClass *pVB, VERTEX_FORMAT *data, Int x0, Int y0, Int x1, Int y1, Int originX, Int originY, WorldHeightMap *pMap, RefRenderObjListIterator *pLightsIterator);
113113
///update vertex buffers associated with the given rectangle
114114
void initDestAlphaLUT(); ///<initialize water depth LUT stored in m_destAlphaTexture
115115
void renderTerrainPass(CameraClass *pCamera); ///< renders additional terrain pass.

Core/GameEngineDevice/Include/W3DDevice/GameClient/W3DShaderManager.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ enum ChipsetType CPP_11(: Int);
4242
enum CpuType CPP_11(: Int);
4343
enum GraphicsVenderID CPP_11(: Int);
4444

45+
struct IDirect3DPixelShader9;
46+
struct IDirect3DVertexShader9;
47+
4548
class TextureClass; ///forward reference
4649
/** System for managing complex rendering settings which are either not handled by
4750
WW3D2 or need custom paths depending on the video card. This system will determine
@@ -94,7 +97,7 @@ class W3DShaderManager
9497
///Return last activated shader.
9598
static ShaderTypes getCurrentShader() {return m_currentShader;}
9699
/// Loads a .vso file and creates a vertex shader for it
97-
static HRESULT LoadAndCreateD3DShader(const char* strFilePath, const DWORD* pDeclaration, DWORD Usage, Bool ShaderType, DWORD* pHandle);
100+
static HRESULT LoadAndCreateD3DShader(const char* strFilePath, const struct _D3DVERTEXELEMENT9* pDeclaration, DWORD Usage, Bool ShaderType, void** pHandle);
98101

99102
static Bool testMinimumRequirements(ChipsetType *videoChipType, CpuType *cpuType, Int *cpuFreq, MemValueType *numRAM, Real *intBenchIndex, Real *floatBenchIndex, Real *memBenchIndex);
100103
static StaticGameLODLevel getGPUPerformanceIndex();
@@ -108,8 +111,8 @@ class W3DShaderManager
108111
// Support routines for filter methods.
109112
static Bool canRenderToTexture() { return (m_oldRenderSurface && m_newRenderSurface);}
110113
static void startRenderToTexture(); ///< Sets render target to texture.
111-
static IDirect3DTexture8 * endRenderToTexture(); ///< Ends render to texture, & returns texture.
112-
static IDirect3DTexture8 * getRenderTexture(); ///< returns last used render target texture
114+
static IDirect3DTexture9 * endRenderToTexture(); ///< Ends render to texture, & returns texture.
115+
static IDirect3DTexture9 * getRenderTexture(); ///< returns last used render target texture
113116
static Bool isRenderingToTexture() {return m_renderingToTexture; }
114117
static void drawViewport(Int color); ///<draws 2 triangles covering the current tactical viewport
115118

@@ -125,10 +128,10 @@ class W3DShaderManager
125128
static FilterTypes m_currentFilter; ///< Last filter that was set.
126129
// Info for a render to texture surface for special effects.
127130
static Bool m_renderingToTexture;
128-
static IDirect3DSurface8 *m_oldRenderSurface; ///<previous render target
129-
static IDirect3DTexture8 *m_renderTexture; ///<texture into which rendering will be redirected.
130-
static IDirect3DSurface8 *m_newRenderSurface; ///<new render target inside m_renderTexture
131-
static IDirect3DSurface8 *m_oldDepthSurface; ///<previous depth buffer surface
131+
static IDirect3DSurface9 *m_oldRenderSurface; ///<previous render target
132+
static IDirect3DTexture9 *m_renderTexture; ///<texture into which rendering will be redirected.
133+
static IDirect3DSurface9 *m_newRenderSurface; ///<new render target inside m_renderTexture
134+
static IDirect3DSurface9 *m_oldDepthSurface; ///<previous depth buffer surface
132135

133136

134137
};
@@ -187,7 +190,7 @@ class ScreenMotionBlurFilter : public W3DFilterInterface
187190
///converts viewport to black & white.
188191
class ScreenBWFilter : public W3DFilterInterface
189192
{
190-
DWORD m_dwBWPixelShader; ///<D3D handle to pixel shader which tints texture to black & white.
193+
IDirect3DPixelShader9* m_dwBWPixelShader; ///<D3D handle to pixel shader which tints texture to black & white.
191194
public:
192195
virtual Int init() override; ///<perform any one time initialization and validation
193196
virtual Int shutdown() override; ///<release resources used by shader

0 commit comments

Comments
 (0)