Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ include(FetchContent)
if((WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows") AND ${CMAKE_SIZEOF_VOID_P} EQUAL 4)
include(cmake/miles.cmake)
include(cmake/bink.cmake)
include(cmake/dx8.cmake)

# Include DirectX SDK based on user selection
if(RTS_USE_DIRECTX9)
include(cmake/dx9.cmake)
else()
include(cmake/dx8.cmake)
endif()
endif()

# Define a dummy stlport target when not on VC6.
Expand Down
13 changes: 12 additions & 1 deletion Core/Libraries/Source/WWVegas/WW3D2/formconv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ D3DFORMAT WW3DFormatToD3DFormatConversionArray[WW3D_FORMAT_COUNT] = {
D3DFMT_UNKNOWN,
D3DFMT_R8G8B8,
D3DFMT_A8R8G8B8,
D3DFMT_X8R8G8B8,
// TheSuperHackers @feature JohnsterID 14/09/2025 D3DFMT_X8R8G8B8 replaced with D3DFMT_A8R8G8B8 in DX9
#if RTS_USE_DIRECTX9
D3DFMT_A8R8G8B8, // WW3D_FORMAT_X8R8G8B8 -> D3DFMT_A8R8G8B8 (X8R8G8B8 not available in DX9)
#else
D3DFMT_X8R8G8B8, // WW3D_FORMAT_X8R8G8B8 -> D3DFMT_X8R8G8B8 (DX8)
#endif
D3DFMT_R5G6B5,
D3DFMT_X1R5G5B5,
D3DFMT_A1R5G5B5,
Expand Down Expand Up @@ -212,7 +217,13 @@ void Init_D3D_To_WW3_Conversion()

D3DFormatToWW3DFormatConversionArray[D3DFMT_R8G8B8]=WW3D_FORMAT_R8G8B8;
D3DFormatToWW3DFormatConversionArray[D3DFMT_A8R8G8B8]=WW3D_FORMAT_A8R8G8B8;
// TheSuperHackers @feature JohnsterID 14/09/2025 D3DFMT_X8R8G8B8 replaced with D3DFMT_A8R8G8B8 in DX9
#if !RTS_USE_DIRECTX9
// In DX8, X8R8G8B8 format exists and maps to WW3D_FORMAT_X8R8G8B8
D3DFormatToWW3DFormatConversionArray[D3DFMT_X8R8G8B8]=WW3D_FORMAT_X8R8G8B8;
#endif
// In DX9, X8R8G8B8 format doesn't exist, so WW3D_FORMAT_X8R8G8B8 maps to D3DFMT_A8R8G8B8
// but reverse mapping prioritizes WW3D_FORMAT_A8R8G8B8
D3DFormatToWW3DFormatConversionArray[D3DFMT_R5G6B5]=WW3D_FORMAT_R5G6B5;
D3DFormatToWW3DFormatConversionArray[D3DFMT_X1R5G5B5]=WW3D_FORMAT_X1R5G5B5;
D3DFormatToWW3DFormatConversionArray[D3DFMT_A1R5G5B5]=WW3D_FORMAT_A1R5G5B5;
Expand Down
5 changes: 5 additions & 0 deletions GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,12 @@ static void Log_Textures(bool inited,unsigned& total_count, unsigned& total_mem)
case D3DFMT_L8: tex_format="D3DFMT_L8"; break;
case D3DFMT_A8: tex_format="D3DFMT_A8"; break;
case D3DFMT_P8: tex_format="D3DFMT_P8"; break;
// TheSuperHackers @feature JohnsterID 14/09/2025 D3DFMT_X8R8G8B8 not available in DX9
#if RTS_USE_DIRECTX9
case D3DFMT_A8R8G8B8: tex_format="D3DFMT_A8R8G8B8 (X8R8G8B8)"; break;
#else
case D3DFMT_X8R8G8B8: tex_format="D3DFMT_X8R8G8B8"; break;
#endif
case D3DFMT_X1R5G5B5: tex_format="D3DFMT_X1R5G5B5"; break;
case D3DFMT_R3G3B2: tex_format="D3DFMT_R3G3B2"; break;
case D3DFMT_A8R3G3B2: tex_format="D3DFMT_A8R3G3B2"; break;
Expand Down
48 changes: 33 additions & 15 deletions GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,27 @@

#pragma once

// TheSuperHackers @feature JohnsterID 14/09/2025 Migrate from DirectX 8 to DirectX 9 API while keeping existing class names
#include "always.h"
#include "ww3dformat.h"
#if RTS_USE_DIRECTX9
#include <d3d9.h>
#else
#include <d3d8.h>
#endif

// TheSuperHackers @feature JohnsterID 14/09/2025 Type aliases for DX8/DX9 compatibility
#if RTS_USE_DIRECTX9
typedef IDirect3D9 DXInterface;
typedef IDirect3DDevice9 DXDevice;
typedef D3DCAPS9 DXCaps;
typedef D3DADAPTER_IDENTIFIER9 DXAdapterIdentifier;
#else
typedef IDirect3D8 DXInterface;
typedef IDirect3DDevice8 DXDevice;
typedef D3DCAPS8 DXCaps;
typedef D3DADAPTER_IDENTIFIER8 DXAdapterIdentifier;
#endif

class DX8Caps
{
Expand Down Expand Up @@ -204,11 +222,11 @@ class DX8Caps
};


DX8Caps(IDirect3D8* direct3d, const D3DCAPS8& caps,WW3DFormat display_format, const D3DADAPTER_IDENTIFIER8& adapter_id);
DX8Caps(IDirect3D8* direct3d, IDirect3DDevice8* D3DDevice,WW3DFormat display_format, const D3DADAPTER_IDENTIFIER8& adapter_id);
DX8Caps(DXInterface* direct3d, const DXCaps& caps,WW3DFormat display_format, const DXAdapterIdentifier& adapter_id);
DX8Caps(DXInterface* direct3d, DXDevice* D3DDevice,WW3DFormat display_format, const DXAdapterIdentifier& adapter_id);
static void Shutdown(void);

void Compute_Caps(WW3DFormat display_format, const D3DADAPTER_IDENTIFIER8& adapter_id);
void Compute_Caps(WW3DFormat display_format, const DXAdapterIdentifier& adapter_id);
bool Support_TnL() const { return SupportTnL; };
bool Support_DXTC() const { return SupportDXTC; }
bool Support_Gamma() const { return supportGamma; }
Expand Down Expand Up @@ -245,7 +263,7 @@ class DX8Caps
bool Support_Render_To_Texture_Format(WW3DFormat format) const { return SupportRenderToTextureFormat[format]; }
bool Support_Depth_Stencil_Format(WW3DZFormat format) const { return SupportDepthStencilFormat[format]; }

D3DCAPS8 const & Get_DX8_Caps() const { return Caps; }
DXCaps const & Get_DX8_Caps() const { return Caps; }

const StringClass& Get_Log() const { return CapsLog; }
const StringClass& Get_Compact_Log() const { return CompactLog; }
Expand All @@ -269,21 +287,21 @@ class DX8Caps
static DeviceTypeS3 Get_S3_Device(unsigned device_id);
static DeviceTypeIntel Get_Intel_Device(unsigned device_id);

void Init_Caps(IDirect3DDevice8* D3DDevice);
void Check_Texture_Format_Support(WW3DFormat display_format,const D3DCAPS8& caps);
void Check_Render_To_Texture_Support(WW3DFormat display_format,const D3DCAPS8& caps);
void Check_Depth_Stencil_Support(WW3DFormat display_format, const D3DCAPS8& caps);
void Check_Texture_Compression_Support(const D3DCAPS8& caps);
void Check_Bumpmap_Support(const D3DCAPS8& caps);
void Check_Shader_Support(const D3DCAPS8& caps);
void Check_Maximum_Texture_Support(const D3DCAPS8& caps);
void Init_Caps(DXDevice* D3DDevice);
void Check_Texture_Format_Support(WW3DFormat display_format,const DXCaps& caps);
void Check_Render_To_Texture_Support(WW3DFormat display_format,const DXCaps& caps);
void Check_Depth_Stencil_Support(WW3DFormat display_format, const DXCaps& caps);
void Check_Texture_Compression_Support(const DXCaps& caps);
void Check_Bumpmap_Support(const DXCaps& caps);
void Check_Shader_Support(const DXCaps& caps);
void Check_Maximum_Texture_Support(const DXCaps& caps);
void Check_Driver_Version_Status();
void Vendor_Specific_Hacks(const D3DADAPTER_IDENTIFIER8& adapter_id);
void Vendor_Specific_Hacks(const DXAdapterIdentifier& adapter_id);

int MaxDisplayWidth;
int MaxDisplayHeight;

D3DCAPS8 Caps;
DXCaps Caps;
bool SupportTnL;
bool SupportDXTC;
bool supportGamma;
Expand All @@ -310,7 +328,7 @@ class DX8Caps
DriverVersionStatusType DriverVersionStatus;
VendorIdType VendorId;
StringClass DriverDLL;
IDirect3D8* Direct3D; // warning XDK name conflict KJM
DXInterface* Direct3D; // warning XDK name conflict KJM
StringClass CapsLog;
StringClass CompactLog;
};
Loading
Loading