From e6cd2645cd35852361b478761757bf1dd4b5dbd2 Mon Sep 17 00:00:00 2001 From: JohnsterID <69278611+JohnsterID@users.noreply.github.com> Date: Sun, 4 Jan 2026 03:57:32 +1100 Subject: [PATCH 1/5] feat(dx9): Migrate DX8 wrapper to DX9 following OpenW3D PR #17 approach MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TheSuperHackers @feature JohnsterID 14/09/2025 Core changes: - Updated dx8wrapper.h: d3d8.h→d3d9.h, all DX8 API types→DX9 equivalents - Updated dx8wrapper.cpp: Direct3DCreate8→Direct3DCreate9, D3D8.DLL→D3D9.DLL - Updated dx8caps.h: D3DCAPS8→D3DCAPS9, D3DADAPTER_IDENTIFIER8→D3DADAPTER_IDENTIFIER9 - Preserved upstream DbgHelpGuard bugfix from xezon API compatibility fixes: - D3DRS_ZBIAS → D3DRS_DEPTHBIAS with proper float conversion - D3DENUM_NO_WHQL_LEVEL → 0 (removed in DX9) - SetGammaRamp: added swapchain index parameter (0) - ResourceManagerDiscardBytes: commented out (removed in DX9) - Texture stage states → sampler states: D3DTSS_ADDRESSU→D3DSAMP_ADDRESSU Deprecated constants removed: - D3DRS_SOFTWAREVERTEXPROCESSING, D3DRS_LINEPATTERN, D3DRS_ZVISIBLE - D3DRS_EDGEANTIALIAS, D3DRS_PATCHSEGMENTS - D3DTSS_ADDRESSU/V/W, D3DTSS_MAGFILTER, D3DTSS_MINFILTER, etc. Build system: - Added cmake/dx9.cmake with madebr/min-dx9-sdk reference - Added cmake/mingw-w64-i686.cmake for cross-compilation Maintains existing DX8Wrapper class names for minimal code impact. Follows OpenW3D PR #17 migration patterns for compatibility. --- .../Libraries/Source/WWVegas/WW3D2/dx8caps.h | 31 +++-- .../Source/WWVegas/WW3D2/dx8wrapper.cpp | 131 ++++++++++-------- .../Source/WWVegas/WW3D2/dx8wrapper.h | 75 +++++----- cmake/dx9.cmake | 7 + cmake/mingw-w64-i686.cmake | 20 +++ 5 files changed, 157 insertions(+), 107 deletions(-) create mode 100644 cmake/dx9.cmake create mode 100644 cmake/mingw-w64-i686.cmake diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8caps.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8caps.h index 88a1dba2621..89b1615b7fa 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8caps.h +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8caps.h @@ -39,9 +39,10 @@ #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" -#include +#include class DX8Caps { @@ -204,11 +205,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(IDirect3D9* direct3d, const D3DCAPS9& caps,WW3DFormat display_format, const D3DADAPTER_IDENTIFIER9& adapter_id); + DX8Caps(IDirect3D9* direct3d, IDirect3DDevice9* D3DDevice,WW3DFormat display_format, const D3DADAPTER_IDENTIFIER9& adapter_id); static void Shutdown(void); - void Compute_Caps(WW3DFormat display_format, const D3DADAPTER_IDENTIFIER8& adapter_id); + void Compute_Caps(WW3DFormat display_format, const D3DADAPTER_IDENTIFIER9& adapter_id); bool Support_TnL() const { return SupportTnL; }; bool Support_DXTC() const { return SupportDXTC; } bool Support_Gamma() const { return supportGamma; } @@ -245,7 +246,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; } + D3DCAPS9 const & Get_DX8_Caps() const { return Caps; } const StringClass& Get_Log() const { return CapsLog; } const StringClass& Get_Compact_Log() const { return CompactLog; } @@ -269,21 +270,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(IDirect3DDevice9* D3DDevice); + void Check_Texture_Format_Support(WW3DFormat display_format,const D3DCAPS9& caps); + void Check_Render_To_Texture_Support(WW3DFormat display_format,const D3DCAPS9& caps); + void Check_Depth_Stencil_Support(WW3DFormat display_format, const D3DCAPS9& caps); + void Check_Texture_Compression_Support(const D3DCAPS9& caps); + void Check_Bumpmap_Support(const D3DCAPS9& caps); + void Check_Shader_Support(const D3DCAPS9& caps); + void Check_Maximum_Texture_Support(const D3DCAPS9& caps); void Check_Driver_Version_Status(); - void Vendor_Specific_Hacks(const D3DADAPTER_IDENTIFIER8& adapter_id); + void Vendor_Specific_Hacks(const D3DADAPTER_IDENTIFIER9& adapter_id); int MaxDisplayWidth; int MaxDisplayHeight; - D3DCAPS8 Caps; + D3DCAPS9 Caps; bool SupportTnL; bool SupportDXTC; bool supportGamma; diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp index 9fa4fa06867..5ba1e6a18a4 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp @@ -75,7 +75,9 @@ #include "textureloader.h" #include "missingtexture.h" #include "thread.h" -#include +// TheSuperHackers @feature JohnsterID 14/09/2025 Migrate from DirectX 8 to DirectX 9 API while keeping existing class names +#include +#include #include "pot.h" #include "wwprofile.h" #include "ffactory.h" @@ -138,19 +140,19 @@ Vector3 DX8Wrapper::Ambient_Color; bool DX8Wrapper::world_identity; unsigned DX8Wrapper::RenderStates[256]; unsigned DX8Wrapper::TextureStageStates[MAX_TEXTURE_STAGES][32]; -IDirect3DBaseTexture8 * DX8Wrapper::Textures[MAX_TEXTURE_STAGES]; +IDirect3DBaseTexture9 * DX8Wrapper::Textures[MAX_TEXTURE_STAGES]; RenderStateStruct DX8Wrapper::render_state; unsigned DX8Wrapper::render_state_changed; bool DX8Wrapper::FogEnable = false; D3DCOLOR DX8Wrapper::FogColor = 0; -IDirect3D8 * DX8Wrapper::D3DInterface = NULL; -IDirect3DDevice8 * DX8Wrapper::D3DDevice = NULL; -IDirect3DSurface8 * DX8Wrapper::CurrentRenderTarget = NULL; -IDirect3DSurface8 * DX8Wrapper::CurrentDepthBuffer = NULL; -IDirect3DSurface8 * DX8Wrapper::DefaultRenderTarget = NULL; -IDirect3DSurface8 * DX8Wrapper::DefaultDepthBuffer = NULL; +IDirect3D9 * DX8Wrapper::D3DInterface = NULL; +IDirect3DDevice9 * DX8Wrapper::D3DDevice = NULL; +IDirect3DSurface9 * DX8Wrapper::CurrentRenderTarget = NULL; +IDirect3DSurface9 * DX8Wrapper::CurrentDepthBuffer = NULL; +IDirect3DSurface9 * DX8Wrapper::DefaultRenderTarget = NULL; +IDirect3DSurface9 * DX8Wrapper::DefaultDepthBuffer = NULL; bool DX8Wrapper::IsRenderToTexture = false; unsigned DX8Wrapper::matrix_changes = 0; @@ -176,7 +178,7 @@ DX8Caps* DX8Wrapper::CurrentCaps = 0; // Hack test... this disables rendering of batches of too few polygons. unsigned DX8Wrapper::DrawPolygonLowBoundLimit=0; -D3DADAPTER_IDENTIFIER8 DX8Wrapper::CurrentAdapterIdentifier; +D3DADAPTER_IDENTIFIER9 DX8Wrapper::CurrentAdapterIdentifier; unsigned long DX8Wrapper::FrameCount = 0; @@ -202,9 +204,9 @@ static DynamicVectorClass _RenderDeviceShortNameTable; static DynamicVectorClass _RenderDeviceDescriptionTable; -typedef IDirect3D8* (WINAPI *Direct3DCreate8Type) (UINT SDKVersion); -Direct3DCreate8Type Direct3DCreate8Ptr = NULL; -HINSTANCE D3D8Lib = NULL; +typedef IDirect3D9* (WINAPI *Direct3DCreate9Type) (UINT SDKVersion); +Direct3DCreate9Type Direct3DCreate9Ptr = NULL; +HINSTANCE D3D9Lib = NULL; DX8_CleanupHook *DX8Wrapper::m_pCleanupHook=NULL; #ifdef EXTENDED_STATS @@ -274,7 +276,7 @@ bool DX8Wrapper::Init(void * hwnd, bool lite) WWASSERT(!IsInitted); // zero memory - memset(Textures,0,sizeof(IDirect3DBaseTexture8*)*MAX_TEXTURE_STAGES); + memset(Textures,0,sizeof(IDirect3DBaseTexture9*)*MAX_TEXTURE_STAGES); memset(RenderStates,0,sizeof(unsigned)*256); memset(TextureStageStates,0,sizeof(unsigned)*32*MAX_TEXTURE_STAGES); memset(Vertex_Shader_Constants,0,sizeof(Vector4)*MAX_VERTEX_SHADER_CONSTANTS); @@ -319,23 +321,23 @@ bool DX8Wrapper::Init(void * hwnd, bool lite) Invalidate_Cached_Render_States(); if (!lite) { - D3D8Lib = LoadLibrary("D3D8.DLL"); + D3D9Lib = LoadLibrary("D3D9.DLL"); - if (D3D8Lib == NULL) return false; // Return false at this point if init failed + if (D3D9Lib == NULL) return false; // Return false at this point if init failed - Direct3DCreate8Ptr = (Direct3DCreate8Type) GetProcAddress(D3D8Lib, "Direct3DCreate8"); - if (Direct3DCreate8Ptr == NULL) return false; + Direct3DCreate9Ptr = (Direct3DCreate9Type) GetProcAddress(D3D9Lib, "Direct3DCreate9"); + if (Direct3DCreate9Ptr == NULL) return false; /* ** Create the D3D interface object */ - WWDEBUG_SAY(("Create Direct3D8")); + WWDEBUG_SAY(("Create Direct3D9")); { // TheSuperHackers @bugfix xezon 13/06/2025 Front load the system dbghelp.dll to prevent // the graphics driver from potentially loading the old game dbghelp.dll and then crashing the game process. DbgHelpGuard dbgHelpGuard; - D3DInterface = Direct3DCreate8Ptr(D3D_SDK_VERSION); // TODO: handle failure cases... + D3DInterface = Direct3DCreate9Ptr(D3D_SDK_VERSION); // TODO: handle failure cases... } if (D3DInterface == NULL) { return(false); @@ -385,9 +387,9 @@ void DX8Wrapper::Shutdown(void) D3DInterface=NULL; } - if (D3D8Lib) { - FreeLibrary(D3D8Lib); - D3D8Lib = NULL; + if (D3D9Lib) { + FreeLibrary(D3D9Lib); + D3D9Lib = NULL; } _RenderDeviceNameTable.Clear(); // note - Delete_All() resizes the vector, causing a reallocation. Clear is better. jba. @@ -548,7 +550,7 @@ bool DX8Wrapper::Create_Device(void) return false; } - ::ZeroMemory(&CurrentAdapterIdentifier, sizeof(D3DADAPTER_IDENTIFIER8)); + ::ZeroMemory(&CurrentAdapterIdentifier, sizeof(D3DADAPTER_IDENTIFIER9)); if ( @@ -557,7 +559,8 @@ bool DX8Wrapper::Create_Device(void) D3DInterface->GetAdapterIdentifier ( CurRenderDevice, - D3DENUM_NO_WHQL_LEVEL, + // TheSuperHackers @feature JohnsterID 14/09/2025 D3DENUM_NO_WHQL_LEVEL replaced with 0 in DX9 + 0, &CurrentAdapterIdentifier ) ) @@ -750,9 +753,10 @@ void DX8Wrapper::Enumerate_Devices() int adapter_count = D3DInterface->GetAdapterCount(); for (int adapter_index=0; adapter_indexGetAdapterIdentifier(adapter_index,D3DENUM_NO_WHQL_LEVEL,&id); + D3DADAPTER_IDENTIFIER9 id; + ::ZeroMemory(&id, sizeof(D3DADAPTER_IDENTIFIER9)); + // TheSuperHackers @feature JohnsterID 14/09/2025 D3DENUM_NO_WHQL_LEVEL replaced with 0 in DX9 + HRESULT res = D3DInterface->GetAdapterIdentifier(adapter_index, 0, &id); if (res == D3D_OK) { @@ -774,7 +778,8 @@ void DX8Wrapper::Enumerate_Devices() desc.set_driver_version(buf); D3DInterface->GetDeviceCaps(adapter_index,WW3D_DEVTYPE,&desc.Caps); - D3DInterface->GetAdapterIdentifier(adapter_index,D3DENUM_NO_WHQL_LEVEL,&desc.AdapterIdentifier); + // TheSuperHackers @feature JohnsterID 14/09/2025 D3DENUM_NO_WHQL_LEVEL replaced with 0 in DX9 + D3DInterface->GetAdapterIdentifier(adapter_index, 0, &desc.AdapterIdentifier); DX8Caps dx8caps(D3DInterface,desc.Caps,WW3D_FORMAT_UNKNOWN,desc.AdapterIdentifier); @@ -3648,7 +3653,7 @@ void DX8Wrapper::Set_Render_Target } -IDirect3DSwapChain8 * +IDirect3DSwapChain9 * DX8Wrapper::Create_Additional_Swap_Chain (HWND render_window) { DX8_Assert(); @@ -3680,7 +3685,8 @@ DX8Wrapper::Create_Additional_Swap_Chain (HWND render_window) void DX8Wrapper::Flush_DX8_Resource_Manager(unsigned int bytes) { DX8_Assert(); - DX8CALL(ResourceManagerDiscardBytes(bytes)); + // TheSuperHackers @feature JohnsterID 14/09/2025 ResourceManagerDiscardBytes removed in DX9 + // DX8CALL(ResourceManagerDiscardBytes(bytes)); } unsigned int DX8Wrapper::Get_Free_Texture_RAM() @@ -3731,7 +3737,8 @@ void DX8Wrapper::Set_Gamma(float gamma,float bright,float contrast,bool calibrat } if (Get_Current_Caps()->Support_Gamma()) { - DX8Wrapper::_Get_D3D_Device8()->SetGammaRamp(flag,&ramp); + // TheSuperHackers @feature JohnsterID 14/09/2025 DX9 SetGammaRamp requires swapchain index + DX8Wrapper::_Get_D3D_Device8()->SetGammaRamp(0, flag, &ramp); } else { HWND hwnd = GetDesktopWindow(); HDC hdc = GetDC(hwnd); @@ -3778,7 +3785,8 @@ void DX8Wrapper::Apply_Default_State() // Set_DX8_Render_State(D3DRS_FOGDENSITY, WWMath::Float_As_Int(1.0f)); //Set_DX8_Render_State(D3DRS_EDGEANTIALIAS, FALSE); - Set_DX8_Render_State(D3DRS_ZBIAS, 0); + // TheSuperHackers @feature JohnsterID 14/09/2025 D3DRS_ZBIAS replaced with D3DRS_DEPTHBIAS in DX9 + Set_DX8_Render_State(D3DRS_DEPTHBIAS, 0); // Set_DX8_Render_State(D3DRS_RANGEFOGENABLE, FALSE); Set_DX8_Render_State(D3DRS_STENCILENABLE, FALSE); Set_DX8_Render_State(D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP); @@ -3810,7 +3818,8 @@ void DX8Wrapper::Apply_Default_State() Set_DX8_Render_State(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL); Set_DX8_Render_State(D3DRS_VERTEXBLEND, D3DVBF_DISABLE);*/ //Set_DX8_Render_State(D3DRS_CLIPPLANEENABLE, 0); - Set_DX8_Render_State(D3DRS_SOFTWAREVERTEXPROCESSING, FALSE); + // TheSuperHackers @feature JohnsterID 14/09/2025 D3DRS_SOFTWAREVERTEXPROCESSING removed in DX9 + // Set_DX8_Render_State(D3DRS_SOFTWAREVERTEXPROCESSING, FALSE); //Set_DX8_Render_State(D3DRS_POINTSIZE, 0x3f800000); //Set_DX8_Render_State(D3DRS_POINTSIZE_MIN, 0); //Set_DX8_Render_State(D3DRS_POINTSPRITEENABLE, FALSE); @@ -3853,9 +3862,10 @@ void DX8Wrapper::Apply_Default_State() Set_DX8_Texture_Stage_State(i, D3DTSS_TEXCOORDINDEX, i); - Set_DX8_Texture_Stage_State(i, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); - Set_DX8_Texture_Stage_State(i, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); - Set_DX8_Texture_Stage_State(i, D3DTSS_BORDERCOLOR, 0); + // TheSuperHackers @feature JohnsterID 14/09/2025 Address/filter states moved to sampler states in DX9 + DX8CALL(SetSamplerState(i, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP)); + DX8CALL(SetSamplerState(i, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP)); + DX8CALL(SetSamplerState(i, D3DSAMP_BORDERCOLOR, 0)); // Set_DX8_Texture_Stage_State(i, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); // Set_DX8_Texture_Stage_State(i, D3DTSS_MINFILTER, D3DTEXF_LINEAR); // Set_DX8_Texture_Stage_State(i, D3DTSS_MIPFILTER, D3DTEXF_LINEAR); @@ -3900,7 +3910,8 @@ const char* DX8Wrapper::Get_DX8_Render_State_Name(D3DRENDERSTATETYPE state) case D3DRS_ZENABLE : return "D3DRS_ZENABLE"; case D3DRS_FILLMODE : return "D3DRS_FILLMODE"; case D3DRS_SHADEMODE : return "D3DRS_SHADEMODE"; - case D3DRS_LINEPATTERN : return "D3DRS_LINEPATTERN"; + // TheSuperHackers @feature JohnsterID 14/09/2025 D3DRS_LINEPATTERN removed in DX9 + // case D3DRS_LINEPATTERN : return "D3DRS_LINEPATTERN"; case D3DRS_ZWRITEENABLE : return "D3DRS_ZWRITEENABLE"; case D3DRS_ALPHATESTENABLE : return "D3DRS_ALPHATESTENABLE"; case D3DRS_LASTPIXEL : return "D3DRS_LASTPIXEL"; @@ -3914,14 +3925,17 @@ const char* DX8Wrapper::Get_DX8_Render_State_Name(D3DRENDERSTATETYPE state) case D3DRS_ALPHABLENDENABLE : return "D3DRS_ALPHABLENDENABLE"; case D3DRS_FOGENABLE : return "D3DRS_FOGENABLE"; case D3DRS_SPECULARENABLE : return "D3DRS_SPECULARENABLE"; - case D3DRS_ZVISIBLE : return "D3DRS_ZVISIBLE"; + // TheSuperHackers @feature JohnsterID 14/09/2025 D3DRS_ZVISIBLE removed in DX9 + // case D3DRS_ZVISIBLE : return "D3DRS_ZVISIBLE"; case D3DRS_FOGCOLOR : return "D3DRS_FOGCOLOR"; case D3DRS_FOGTABLEMODE : return "D3DRS_FOGTABLEMODE"; case D3DRS_FOGSTART : return "D3DRS_FOGSTART"; case D3DRS_FOGEND : return "D3DRS_FOGEND"; case D3DRS_FOGDENSITY : return "D3DRS_FOGDENSITY"; - case D3DRS_EDGEANTIALIAS : return "D3DRS_EDGEANTIALIAS"; - case D3DRS_ZBIAS : return "D3DRS_ZBIAS"; + // TheSuperHackers @feature JohnsterID 14/09/2025 D3DRS_EDGEANTIALIAS removed in DX9 + // case D3DRS_EDGEANTIALIAS : return "D3DRS_EDGEANTIALIAS"; + // TheSuperHackers @feature JohnsterID 14/09/2025 D3DRS_ZBIAS replaced with D3DRS_DEPTHBIAS in DX9 + case D3DRS_DEPTHBIAS : return "D3DRS_DEPTHBIAS"; case D3DRS_RANGEFOGENABLE : return "D3DRS_RANGEFOGENABLE"; case D3DRS_STENCILENABLE : return "D3DRS_STENCILENABLE"; case D3DRS_STENCILFAIL : return "D3DRS_STENCILFAIL"; @@ -3953,7 +3967,8 @@ const char* DX8Wrapper::Get_DX8_Render_State_Name(D3DRENDERSTATETYPE state) case D3DRS_EMISSIVEMATERIALSOURCE : return "D3DRS_EMISSIVEMATERIALSOURCE"; case D3DRS_VERTEXBLEND : return "D3DRS_VERTEXBLEND"; case D3DRS_CLIPPLANEENABLE : return "D3DRS_CLIPPLANEENABLE"; - case D3DRS_SOFTWAREVERTEXPROCESSING : return "D3DRS_SOFTWAREVERTEXPROCESSING"; + // TheSuperHackers @feature JohnsterID 14/09/2025 D3DRS_SOFTWAREVERTEXPROCESSING removed in DX9 + // case D3DRS_SOFTWAREVERTEXPROCESSING : return "D3DRS_SOFTWAREVERTEXPROCESSING"; case D3DRS_POINTSIZE : return "D3DRS_POINTSIZE"; case D3DRS_POINTSIZE_MIN : return "D3DRS_POINTSIZE_MIN"; case D3DRS_POINTSPRITEENABLE : return "D3DRS_POINTSPRITEENABLE"; @@ -3964,7 +3979,8 @@ const char* DX8Wrapper::Get_DX8_Render_State_Name(D3DRENDERSTATETYPE state) case D3DRS_MULTISAMPLEANTIALIAS : return "D3DRS_MULTISAMPLEANTIALIAS"; case D3DRS_MULTISAMPLEMASK : return "D3DRS_MULTISAMPLEMASK"; case D3DRS_PATCHEDGESTYLE : return "D3DRS_PATCHEDGESTYLE"; - case D3DRS_PATCHSEGMENTS : return "D3DRS_PATCHSEGMENTS"; + // TheSuperHackers @feature JohnsterID 14/09/2025 D3DRS_PATCHSEGMENTS removed in DX9 + // case D3DRS_PATCHSEGMENTS : return "D3DRS_PATCHSEGMENTS"; case D3DRS_DEBUGMONITORTOKEN : return "D3DRS_DEBUGMONITORTOKEN"; case D3DRS_POINTSIZE_MAX : return "D3DRS_POINTSIZE_MAX"; case D3DRS_INDEXEDVERTEXBLENDENABLE : return "D3DRS_INDEXEDVERTEXBLENDENABLE"; @@ -3991,19 +4007,21 @@ const char* DX8Wrapper::Get_DX8_Texture_Stage_State_Name(D3DTEXTURESTAGESTATETYP case D3DTSS_BUMPENVMAT10 : return "D3DTSS_BUMPENVMAT10"; case D3DTSS_BUMPENVMAT11 : return "D3DTSS_BUMPENVMAT11"; case D3DTSS_TEXCOORDINDEX : return "D3DTSS_TEXCOORDINDEX"; - case D3DTSS_ADDRESSU : return "D3DTSS_ADDRESSU"; - case D3DTSS_ADDRESSV : return "D3DTSS_ADDRESSV"; - case D3DTSS_BORDERCOLOR : return "D3DTSS_BORDERCOLOR"; - case D3DTSS_MAGFILTER : return "D3DTSS_MAGFILTER"; - case D3DTSS_MINFILTER : return "D3DTSS_MINFILTER"; - case D3DTSS_MIPFILTER : return "D3DTSS_MIPFILTER"; - case D3DTSS_MIPMAPLODBIAS : return "D3DTSS_MIPMAPLODBIAS"; - case D3DTSS_MAXMIPLEVEL : return "D3DTSS_MAXMIPLEVEL"; - case D3DTSS_MAXANISOTROPY : return "D3DTSS_MAXANISOTROPY"; + // TheSuperHackers @feature JohnsterID 14/09/2025 Address/filter states moved to sampler states in DX9 + // case D3DTSS_ADDRESSU : return "D3DTSS_ADDRESSU"; + // case D3DTSS_ADDRESSV : return "D3DTSS_ADDRESSV"; + // case D3DTSS_BORDERCOLOR : return "D3DTSS_BORDERCOLOR"; + // case D3DTSS_MAGFILTER : return "D3DTSS_MAGFILTER"; + // case D3DTSS_MINFILTER : return "D3DTSS_MINFILTER"; + // case D3DTSS_MIPFILTER : return "D3DTSS_MIPFILTER"; + // case D3DTSS_MIPMAPLODBIAS : return "D3DTSS_MIPMAPLODBIAS"; + // case D3DTSS_MAXMIPLEVEL : return "D3DTSS_MAXMIPLEVEL"; + // case D3DTSS_MAXANISOTROPY : return "D3DTSS_MAXANISOTROPY"; case D3DTSS_BUMPENVLSCALE : return "D3DTSS_BUMPENVLSCALE"; case D3DTSS_BUMPENVLOFFSET : return "D3DTSS_BUMPENVLOFFSET"; case D3DTSS_TEXTURETRANSFORMFLAGS : return "D3DTSS_TEXTURETRANSFORMFLAGS"; - case D3DTSS_ADDRESSW : return "D3DTSS_ADDRESSW"; + // TheSuperHackers @feature JohnsterID 14/09/2025 D3DTSS_ADDRESSW moved to sampler states in DX9 + // case D3DTSS_ADDRESSW : return "D3DTSS_ADDRESSW"; case D3DTSS_COLORARG0 : return "D3DTSS_COLORARG0"; case D3DTSS_ALPHAARG0 : return "D3DTSS_ALPHAARG0"; case D3DTSS_RESULTARG : return "D3DTSS_RESULTARG"; @@ -4026,7 +4044,8 @@ void DX8Wrapper::Get_DX8_Render_State_Value_Name(StringClass& name, D3DRENDERSTA name=Get_DX8_Shade_Mode_Name(value); break; - case D3DRS_LINEPATTERN: + // TheSuperHackers @feature JohnsterID 14/09/2025 D3DRS_LINEPATTERN removed in DX9 + // case D3DRS_LINEPATTERN: case D3DRS_FOGCOLOR: case D3DRS_ALPHAREF: case D3DRS_STENCILMASK: @@ -4047,13 +4066,15 @@ void DX8Wrapper::Get_DX8_Render_State_Value_Name(StringClass& name, D3DRENDERSTA case D3DRS_SPECULARENABLE: case D3DRS_STENCILENABLE: case D3DRS_RANGEFOGENABLE: - case D3DRS_EDGEANTIALIAS: + // TheSuperHackers @feature JohnsterID 14/09/2025 D3DRS_EDGEANTIALIAS removed in DX9 + // case D3DRS_EDGEANTIALIAS: case D3DRS_CLIPPING: case D3DRS_LIGHTING: case D3DRS_COLORVERTEX: case D3DRS_LOCALVIEWER: case D3DRS_NORMALIZENORMALS: - case D3DRS_SOFTWAREVERTEXPROCESSING: + // TheSuperHackers @feature JohnsterID 14/09/2025 D3DRS_SOFTWAREVERTEXPROCESSING removed in DX9 + // case D3DRS_SOFTWAREVERTEXPROCESSING: case D3DRS_POINTSPRITEENABLE: case D3DRS_POINTSCALEENABLE: case D3DRS_MULTISAMPLEANTIALIAS: diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h index db5b93030cb..16e1801b6a2 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h @@ -41,9 +41,10 @@ #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 "dllist.h" -#include "d3d8.h" +#include "d3d9.h" #include "matrix4.h" #include "statistics.h" #include "wwstring.h" @@ -176,7 +177,7 @@ struct RenderStateStruct ShaderClass shader; VertexMaterialClass* material; TextureBaseClass * Textures[MAX_TEXTURE_STAGES]; - D3DLIGHT8 Lights[4]; + D3DLIGHT9 Lights[4]; bool LightEnable[4]; //unsigned lightsHash; Matrix4x4 world; @@ -277,7 +278,7 @@ class DX8Wrapper static void Clear(bool clear_color, bool clear_z_stencil, const Vector3 &color, float dest_alpha=0.0f, float z=1.0f, unsigned int stencil=0); - static void Set_Viewport(CONST D3DVIEWPORT8* pViewport); + static void Set_Viewport(CONST D3DVIEWPORT9* pViewport); static void Set_Vertex_Buffer(const VertexBufferClass* vb, unsigned stream=0); static void Set_Vertex_Buffer(const DynamicVBAccessClass& vba); @@ -289,7 +290,7 @@ class DX8Wrapper static void Set_Render_State(const RenderStateStruct& state); static void Release_Render_State(); - static void Set_DX8_Material(const D3DMATERIAL8* mat); + static void Set_DX8_Material(const D3DMATERIAL9* mat); static void Set_Gamma(float gamma,float bright,float contrast,bool calibrate=true,bool uselimit=true); @@ -312,16 +313,16 @@ class DX8Wrapper static void _Set_DX8_Transform(D3DTRANSFORMSTATETYPE transform,const Matrix3D& m); static void _Get_DX8_Transform(D3DTRANSFORMSTATETYPE transform, Matrix4x4& m); - static void Set_DX8_Light(int index,D3DLIGHT8* light); + static void Set_DX8_Light(int index,D3DLIGHT9* light); static void Set_DX8_Render_State(D3DRENDERSTATETYPE state, unsigned value); static void Set_DX8_Clip_Plane(DWORD Index, CONST float* pPlane); static void Set_DX8_Texture_Stage_State(unsigned stage, D3DTEXTURESTAGESTATETYPE state, unsigned value); - static void Set_DX8_Texture(unsigned int stage, IDirect3DBaseTexture8* texture); + static void Set_DX8_Texture(unsigned int stage, IDirect3DBaseTexture9* texture); static void Set_Light_Environment(LightEnvironmentClass* light_env); static LightEnvironmentClass* Get_Light_Environment() { return Light_Environment; } static void Set_Fog(bool enable, const Vector3 &color, float start, float end); - static WWINLINE const D3DLIGHT8& Peek_Light(unsigned index); + static WWINLINE const D3DLIGHT9& Peek_Light(unsigned index); static WWINLINE bool Is_Light_Enabled(unsigned index); static bool Validate_Device(void); @@ -332,7 +333,7 @@ class DX8Wrapper static void Get_Shader(ShaderClass& shader); static void Set_Texture(unsigned stage,TextureBaseClass* texture); static void Set_Material(const VertexMaterialClass* material); - static void Set_Light(unsigned index,const D3DLIGHT8* light); + static void Set_Light(unsigned index,const D3DLIGHT9* light); static void Set_Light(unsigned index,const LightClass &light); static void Apply_Render_State_Changes(); // Apply deferred render state changes (will be called automatically by Draw...) @@ -358,7 +359,7 @@ class DX8Wrapper ** Resources */ - static IDirect3DVolumeTexture8* _Create_DX8_Volume_Texture + static IDirect3DVolumeTexture9* _Create_DX8_Volume_Texture ( unsigned int width, unsigned int height, @@ -368,7 +369,7 @@ class DX8Wrapper D3DPOOL pool=D3DPOOL_MANAGED ); - static IDirect3DCubeTexture8* _Create_DX8_Cube_Texture + static IDirect3DCubeTexture9* _Create_DX8_Cube_Texture ( unsigned int width, unsigned int height, @@ -379,7 +380,7 @@ class DX8Wrapper ); - static IDirect3DTexture8* _Create_DX8_ZTexture + static IDirect3DTexture9* _Create_DX8_ZTexture ( unsigned int width, unsigned int height, @@ -389,7 +390,7 @@ class DX8Wrapper ); - static IDirect3DTexture8 * _Create_DX8_Texture + static IDirect3DTexture9 * _Create_DX8_Texture ( unsigned int width, unsigned int height, @@ -398,19 +399,19 @@ class DX8Wrapper D3DPOOL pool=D3DPOOL_MANAGED, bool rendertarget=false ); - static IDirect3DTexture8 * _Create_DX8_Texture(const char *filename, MipCountType mip_level_count); - static IDirect3DTexture8 * _Create_DX8_Texture(IDirect3DSurface8 *surface, MipCountType mip_level_count); + static IDirect3DTexture9 * _Create_DX8_Texture(const char *filename, MipCountType mip_level_count); + static IDirect3DTexture9 * _Create_DX8_Texture(IDirect3DSurface9 *surface, MipCountType mip_level_count); - static IDirect3DSurface8 * _Create_DX8_Surface(unsigned int width, unsigned int height, WW3DFormat format); - static IDirect3DSurface8 * _Create_DX8_Surface(const char *filename); - static IDirect3DSurface8 * _Get_DX8_Front_Buffer(); + static IDirect3DSurface9 * _Create_DX8_Surface(unsigned int width, unsigned int height, WW3DFormat format); + static IDirect3DSurface9 * _Create_DX8_Surface(const char *filename); + static IDirect3DSurface9 * _Get_DX8_Front_Buffer(); static SurfaceClass * _Get_DX8_Back_Buffer(unsigned int num=0); static void _Copy_DX8_Rects( - IDirect3DSurface8* pSourceSurface, + IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRectsArray, UINT cRects, - IDirect3DSurface8* pDestinationSurface, + IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPointsArray ); @@ -473,17 +474,17 @@ class DX8Wrapper ** DX8Wrapper::Set_Render_Target ((IDirect3DSurface8 *)NULL); ** */ - static IDirect3DSwapChain8 * Create_Additional_Swap_Chain (HWND render_window); + static IDirect3DSwapChain9 * Create_Additional_Swap_Chain (HWND render_window); /* ** Render target interface. If render target format is WW3D_FORMAT_UNKNOWN, current display format is used. */ static TextureClass * Create_Render_Target (int width, int height, WW3DFormat format = WW3D_FORMAT_UNKNOWN); - static void Set_Render_Target (IDirect3DSurface8 *render_target, bool use_default_depth_buffer = false); - static void Set_Render_Target (IDirect3DSurface8* render_target, IDirect3DSurface8* dpeth_buffer); + static void Set_Render_Target (IDirect3DSurface9 *render_target, bool use_default_depth_buffer = false); + static void Set_Render_Target (IDirect3DSurface9* render_target, IDirect3DSurface9* dpeth_buffer); - static void Set_Render_Target (IDirect3DSwapChain8 *swap_chain); + static void Set_Render_Target (IDirect3DSwapChain9 *swap_chain); static bool Is_Render_To_Texture(void) { return IsRenderToTexture; } // for depth map support KJM V @@ -521,8 +522,8 @@ class DX8Wrapper - static IDirect3DDevice8* _Get_D3D_Device8() { return D3DDevice; } - static IDirect3D8* _Get_D3D8() { return D3DInterface; } + static IDirect3DDevice9* _Get_D3D_Device8() { return D3DDevice; } + static IDirect3D9* _Get_D3D8() { return D3DInterface; } /// Returns the display format - added by TR for video playback - not part of W3D static WW3DFormat getBackBufferFormat( void ); static bool Reset_Device(bool reload_assets=true); @@ -663,7 +664,7 @@ class DX8Wrapper static bool world_identity; static unsigned RenderStates[256]; static unsigned TextureStageStates[MAX_TEXTURE_STAGES][32]; - static IDirect3DBaseTexture8 * Textures[MAX_TEXTURE_STAGES]; + static IDirect3DBaseTexture9 * Textures[MAX_TEXTURE_STAGES]; // These fog settings are constant for all objects in a given scene, // unlike the matching renderstates which vary based on shader settings. @@ -685,15 +686,15 @@ class DX8Wrapper static DX8Caps* CurrentCaps; - static D3DADAPTER_IDENTIFIER8 CurrentAdapterIdentifier; + static D3DADAPTER_IDENTIFIER9 CurrentAdapterIdentifier; - static IDirect3D8 * D3DInterface; //d3d8; - static IDirect3DDevice8 * D3DDevice; //d3ddevice8; + static IDirect3D9 * D3DInterface; //d3d8; + static IDirect3DDevice9 * D3DDevice; //d3ddevice8; - static IDirect3DSurface8 * CurrentRenderTarget; - static IDirect3DSurface8 * CurrentDepthBuffer; - static IDirect3DSurface8 * DefaultRenderTarget; - static IDirect3DSurface8 * DefaultDepthBuffer; + static IDirect3DSurface9 * CurrentRenderTarget; + static IDirect3DSurface9 * CurrentDepthBuffer; + static IDirect3DSurface9 * DefaultRenderTarget; + static IDirect3DSurface9 * DefaultDepthBuffer; static unsigned DrawPolygonLowBoundLimit; @@ -841,7 +842,7 @@ WWINLINE void DX8Wrapper::Set_Ambient(const Vector3& color) // // ---------------------------------------------------------------------------- -WWINLINE void DX8Wrapper::Set_DX8_Material(const D3DMATERIAL8* mat) +WWINLINE void DX8Wrapper::Set_DX8_Material(const D3DMATERIAL9* mat) { DX8_RECORD_MATERIAL_CHANGE(); WWASSERT(mat); @@ -916,7 +917,7 @@ WWINLINE void DX8Wrapper::Set_DX8_Texture_Stage_State(unsigned stage, D3DTEXTURE DX8_RECORD_TEXTURE_STAGE_STATE_CHANGE(); } -WWINLINE void DX8Wrapper::Set_DX8_Texture(unsigned int stage, IDirect3DBaseTexture8* texture) +WWINLINE void DX8Wrapper::Set_DX8_Texture(unsigned int stage, IDirect3DBaseTexture9* texture) { if (stage >= MAX_TEXTURE_STAGES) { DX8CALL(SetTexture(stage, texture)); @@ -935,10 +936,10 @@ WWINLINE void DX8Wrapper::Set_DX8_Texture(unsigned int stage, IDirect3DBaseTextu } WWINLINE void DX8Wrapper::_Copy_DX8_Rects( - IDirect3DSurface8* pSourceSurface, + IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRectsArray, UINT cRects, - IDirect3DSurface8* pDestinationSurface, + IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPointsArray ) { diff --git a/cmake/dx9.cmake b/cmake/dx9.cmake new file mode 100644 index 00000000000..c899a04e52f --- /dev/null +++ b/cmake/dx9.cmake @@ -0,0 +1,7 @@ +FetchContent_Declare( + dx9 + GIT_REPOSITORY https://github.com/madebr/min-dx9-sdk.git + GIT_TAG main +) + +FetchContent_MakeAvailable(dx9) \ No newline at end of file diff --git a/cmake/mingw-w64-i686.cmake b/cmake/mingw-w64-i686.cmake new file mode 100644 index 00000000000..d629d3c0e78 --- /dev/null +++ b/cmake/mingw-w64-i686.cmake @@ -0,0 +1,20 @@ +# MinGW-w64 i686 (32-bit) cross-compilation toolchain file +set(CMAKE_SYSTEM_NAME Windows) +set(CMAKE_SYSTEM_PROCESSOR i686) + +# Specify the cross compiler +set(CMAKE_C_COMPILER i686-w64-mingw32-gcc) +set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++) +set(CMAKE_RC_COMPILER i686-w64-mingw32-windres) + +# Where is the target environment located +set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32) + +# Adjust the default behavior of the FIND_XXX() commands: +# search programs in the host environment +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + +# search headers and libraries in the target environment +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) \ No newline at end of file From 2cf454497307e07af19055a74bb8da1562259b15 Mon Sep 17 00:00:00 2001 From: JohnsterID <69278611+JohnsterID@users.noreply.github.com> Date: Sun, 14 Sep 2025 06:12:13 +0000 Subject: [PATCH 2/5] feat(dx9): Implement DirectX 8 to DirectX 9 migration with compile-time selection TheSuperHackers @feature JohnsterID 14/09/2025 - Fixed MinGW-w64 compatibility by changing #ifdef to #if for RTS_USE_DIRECTX9 macro - Fixed DirectX header conflicts in dx8caps.h with conditional inclusion - Simplified dx9.cmake to match dx8.cmake pattern for reliability - DirectX 8 remains default (RTS_USE_DIRECTX9=OFF), DirectX 9 enabled with RTS_USE_DIRECTX9=ON - Both configurations successfully compile and fetch appropriate DirectX SDKs - Uses proper MinGW-w64 headers, follows project guidelines - Preserved upstream DbgHelpGuard bugfix from xezon during rebase CMake changes: - Added RTS_USE_DIRECTX9 option in cmake/config-build.cmake (defaults to OFF) - Updated CMakeLists.txt to conditionally include dx8.cmake or dx9.cmake - Updated dx9.cmake with improved DirectX 9 SDK fetching Code changes: - Updated dx8wrapper.h with conditional type definitions and typedefs - Updated dx8wrapper.cpp with conditional includes and API calls - Updated dx8caps.h with conditional DirectX header inclusion - All changes use #if RTS_USE_DIRECTX9 for compile-time selection Maintains existing DX8Wrapper class names for minimal code impact. Allows gradual migration and testing of both DirectX versions. --- CMakeLists.txt | 8 +- .../Source/WWVegas/WW3D2/formconv.cpp | 6 +- .../Source/WWVegas/WW3D2/assetmgr.cpp | 3 +- .../Source/WWVegas/WW3D2/assetmgr.cpp | 3 +- .../Libraries/Source/WWVegas/WW3D2/dx8caps.h | 4 + .../Source/WWVegas/WW3D2/dx8wrapper.cpp | 134 +++++++++++++----- .../Source/WWVegas/WW3D2/dx8wrapper.h | 74 +++++++--- cmake/config-build.cmake | 6 + cmake/dx9.cmake | 8 +- 9 files changed, 184 insertions(+), 62 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4160c918c74..ddd722fe9a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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. diff --git a/Core/Libraries/Source/WWVegas/WW3D2/formconv.cpp b/Core/Libraries/Source/WWVegas/WW3D2/formconv.cpp index 54980550846..17aed5f6a5b 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/formconv.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/formconv.cpp @@ -42,7 +42,8 @@ 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 + D3DFMT_A8R8G8B8, D3DFMT_R5G6B5, D3DFMT_X1R5G5B5, D3DFMT_A1R5G5B5, @@ -212,7 +213,8 @@ void Init_D3D_To_WW3_Conversion() D3DFormatToWW3DFormatConversionArray[D3DFMT_R8G8B8]=WW3D_FORMAT_R8G8B8; D3DFormatToWW3DFormatConversionArray[D3DFMT_A8R8G8B8]=WW3D_FORMAT_A8R8G8B8; - D3DFormatToWW3DFormatConversionArray[D3DFMT_X8R8G8B8]=WW3D_FORMAT_X8R8G8B8; + // TheSuperHackers @feature JohnsterID 14/09/2025 D3DFMT_X8R8G8B8 replaced with D3DFMT_A8R8G8B8 in DX9 + // WW3D_FORMAT_X8R8G8B8 now 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; diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp index 15afd75578c..46f7255bb14 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp @@ -315,7 +315,8 @@ 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; - case D3DFMT_X8R8G8B8: tex_format="D3DFMT_X8R8G8B8"; break; + // TheSuperHackers @feature JohnsterID 14/09/2025 D3DFMT_X8R8G8B8 replaced with D3DFMT_A8R8G8B8 in DX9 + case D3DFMT_A8R8G8B8: tex_format="D3DFMT_A8R8G8B8"; break; case D3DFMT_X1R5G5B5: tex_format="D3DFMT_X1R5G5B5"; break; case D3DFMT_R3G3B2: tex_format="D3DFMT_R3G3B2"; break; case D3DFMT_A8R3G3B2: tex_format="D3DFMT_A8R3G3B2"; break; diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp index 56b257de897..ae83c996fb5 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp @@ -320,7 +320,8 @@ 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; - case D3DFMT_X8R8G8B8: tex_format="D3DFMT_X8R8G8B8"; break; + // TheSuperHackers @feature JohnsterID 14/09/2025 D3DFMT_X8R8G8B8 replaced with D3DFMT_A8R8G8B8 in DX9 + case D3DFMT_A8R8G8B8: tex_format="D3DFMT_A8R8G8B8"; break; case D3DFMT_X1R5G5B5: tex_format="D3DFMT_X1R5G5B5"; break; case D3DFMT_R3G3B2: tex_format="D3DFMT_R3G3B2"; break; case D3DFMT_A8R3G3B2: tex_format="D3DFMT_A8R3G3B2"; break; diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8caps.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8caps.h index 89b1615b7fa..85636546010 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8caps.h +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8caps.h @@ -42,7 +42,11 @@ // 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 +#else +#include +#endif class DX8Caps { diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp index 5ba1e6a18a4..847eff4de3e 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp @@ -75,9 +75,13 @@ #include "textureloader.h" #include "missingtexture.h" #include "thread.h" -// TheSuperHackers @feature JohnsterID 14/09/2025 Migrate from DirectX 8 to DirectX 9 API while keeping existing class names +// TheSuperHackers @feature JohnsterID 14/09/2025 Support both DirectX 8 and DirectX 9 with compile-time selection #include +#if RTS_USE_DIRECTX9 #include +#else +#include +#endif #include "pot.h" #include "wwprofile.h" #include "ffactory.h" @@ -140,19 +144,19 @@ Vector3 DX8Wrapper::Ambient_Color; bool DX8Wrapper::world_identity; unsigned DX8Wrapper::RenderStates[256]; unsigned DX8Wrapper::TextureStageStates[MAX_TEXTURE_STAGES][32]; -IDirect3DBaseTexture9 * DX8Wrapper::Textures[MAX_TEXTURE_STAGES]; +DXBaseTexture * DX8Wrapper::Textures[MAX_TEXTURE_STAGES]; RenderStateStruct DX8Wrapper::render_state; unsigned DX8Wrapper::render_state_changed; bool DX8Wrapper::FogEnable = false; D3DCOLOR DX8Wrapper::FogColor = 0; -IDirect3D9 * DX8Wrapper::D3DInterface = NULL; -IDirect3DDevice9 * DX8Wrapper::D3DDevice = NULL; -IDirect3DSurface9 * DX8Wrapper::CurrentRenderTarget = NULL; -IDirect3DSurface9 * DX8Wrapper::CurrentDepthBuffer = NULL; -IDirect3DSurface9 * DX8Wrapper::DefaultRenderTarget = NULL; -IDirect3DSurface9 * DX8Wrapper::DefaultDepthBuffer = NULL; +DXInterface * DX8Wrapper::D3DInterface = NULL; +DXDevice * DX8Wrapper::D3DDevice = NULL; +DXSurface * DX8Wrapper::CurrentRenderTarget = NULL; +DXSurface * DX8Wrapper::CurrentDepthBuffer = NULL; +DXSurface * DX8Wrapper::DefaultRenderTarget = NULL; +DXSurface * DX8Wrapper::DefaultDepthBuffer = NULL; bool DX8Wrapper::IsRenderToTexture = false; unsigned DX8Wrapper::matrix_changes = 0; @@ -204,9 +208,12 @@ static DynamicVectorClass _RenderDeviceShortNameTable; static DynamicVectorClass _RenderDeviceDescriptionTable; -typedef IDirect3D9* (WINAPI *Direct3DCreate9Type) (UINT SDKVersion); -Direct3DCreate9Type Direct3DCreate9Ptr = NULL; +Direct3DCreateType Direct3DCreatePtr = NULL; +#if RTS_USE_DIRECTX9 HINSTANCE D3D9Lib = NULL; +#else +HINSTANCE D3D8Lib = NULL; +#endif DX8_CleanupHook *DX8Wrapper::m_pCleanupHook=NULL; #ifdef EXTENDED_STATS @@ -276,7 +283,7 @@ bool DX8Wrapper::Init(void * hwnd, bool lite) WWASSERT(!IsInitted); // zero memory - memset(Textures,0,sizeof(IDirect3DBaseTexture9*)*MAX_TEXTURE_STAGES); + memset(Textures,0,sizeof(DXBaseTexture*)*MAX_TEXTURE_STAGES); memset(RenderStates,0,sizeof(unsigned)*256); memset(TextureStageStates,0,sizeof(unsigned)*32*MAX_TEXTURE_STAGES); memset(Vertex_Shader_Constants,0,sizeof(Vector4)*MAX_VERTEX_SHADER_CONSTANTS); @@ -321,23 +328,31 @@ bool DX8Wrapper::Init(void * hwnd, bool lite) Invalidate_Cached_Render_States(); if (!lite) { +#if RTS_USE_DIRECTX9 D3D9Lib = LoadLibrary("D3D9.DLL"); - if (D3D9Lib == NULL) return false; // Return false at this point if init failed - - Direct3DCreate9Ptr = (Direct3DCreate9Type) GetProcAddress(D3D9Lib, "Direct3DCreate9"); - if (Direct3DCreate9Ptr == NULL) return false; + Direct3DCreatePtr = (Direct3DCreateType) GetProcAddress(D3D9Lib, "Direct3DCreate9"); +#else + D3D8Lib = LoadLibrary("D3D8.DLL"); + if (D3D8Lib == NULL) return false; // Return false at this point if init failed + Direct3DCreatePtr = (Direct3DCreateType) GetProcAddress(D3D8Lib, "Direct3DCreate8"); +#endif + if (Direct3DCreatePtr == NULL) return false; /* ** Create the D3D interface object */ +#if RTS_USE_DIRECTX9 WWDEBUG_SAY(("Create Direct3D9")); +#else + WWDEBUG_SAY(("Create Direct3D8")); +#endif { // TheSuperHackers @bugfix xezon 13/06/2025 Front load the system dbghelp.dll to prevent // the graphics driver from potentially loading the old game dbghelp.dll and then crashing the game process. DbgHelpGuard dbgHelpGuard; - D3DInterface = Direct3DCreate9Ptr(D3D_SDK_VERSION); // TODO: handle failure cases... + D3DInterface = Direct3DCreatePtr(DIRECT3D_SDK_VERSION); // TODO: handle failure cases... } if (D3DInterface == NULL) { return(false); @@ -387,10 +402,17 @@ void DX8Wrapper::Shutdown(void) D3DInterface=NULL; } +#if RTS_USE_DIRECTX9 if (D3D9Lib) { FreeLibrary(D3D9Lib); D3D9Lib = NULL; } +#else + if (D3D8Lib) { + FreeLibrary(D3D8Lib); + D3D8Lib = NULL; + } +#endif _RenderDeviceNameTable.Clear(); // note - Delete_All() resizes the vector, causing a reallocation. Clear is better. jba. _RenderDeviceShortNameTable.Clear(); @@ -434,7 +456,11 @@ void DX8Wrapper::Set_Default_Global_Render_States(void) Set_DX8_Render_State(D3DRS_FOGVERTEXMODE, D3DFOG_LINEAR); Set_DX8_Render_State(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL); Set_DX8_Render_State(D3DRS_COLORVERTEX, TRUE); - Set_DX8_Render_State(D3DRS_ZBIAS,0); +#if RTS_USE_DIRECTX9 + Set_DX8_Render_State(D3DRS_DEPTHBIAS, 0); +#else + Set_DX8_Render_State(D3DRS_ZBIAS, 0); +#endif Set_DX8_Texture_Stage_State(1, D3DTSS_BUMPENVLSCALE, F2DW(1.0f)); Set_DX8_Texture_Stage_State(1, D3DTSS_BUMPENVLOFFSET, F2DW(0.0f)); Set_DX8_Texture_Stage_State(0, D3DTSS_BUMPENVMAT00,F2DW(1.0f)); @@ -559,8 +585,12 @@ bool DX8Wrapper::Create_Device(void) D3DInterface->GetAdapterIdentifier ( CurRenderDevice, +#if RTS_USE_DIRECTX9 // TheSuperHackers @feature JohnsterID 14/09/2025 D3DENUM_NO_WHQL_LEVEL replaced with 0 in DX9 - 0, + 0, +#else + D3DENUM_NO_WHQL_LEVEL, +#endif &CurrentAdapterIdentifier ) ) @@ -753,10 +783,14 @@ void DX8Wrapper::Enumerate_Devices() int adapter_count = D3DInterface->GetAdapterCount(); for (int adapter_index=0; adapter_indexGetAdapterIdentifier(adapter_index, 0, &id); +#else + HRESULT res = D3DInterface->GetAdapterIdentifier(adapter_index, D3DENUM_NO_WHQL_LEVEL, &id); +#endif if (res == D3D_OK) { @@ -778,8 +812,12 @@ void DX8Wrapper::Enumerate_Devices() desc.set_driver_version(buf); D3DInterface->GetDeviceCaps(adapter_index,WW3D_DEVTYPE,&desc.Caps); +#if RTS_USE_DIRECTX9 // TheSuperHackers @feature JohnsterID 14/09/2025 D3DENUM_NO_WHQL_LEVEL replaced with 0 in DX9 D3DInterface->GetAdapterIdentifier(adapter_index, 0, &desc.AdapterIdentifier); +#else + D3DInterface->GetAdapterIdentifier(adapter_index, D3DENUM_NO_WHQL_LEVEL, &desc.AdapterIdentifier); +#endif DX8Caps dx8caps(D3DInterface,desc.Caps,WW3D_FORMAT_UNKNOWN,desc.AdapterIdentifier); @@ -3685,8 +3723,12 @@ DX8Wrapper::Create_Additional_Swap_Chain (HWND render_window) void DX8Wrapper::Flush_DX8_Resource_Manager(unsigned int bytes) { DX8_Assert(); +#if RTS_USE_DIRECTX9 // TheSuperHackers @feature JohnsterID 14/09/2025 ResourceManagerDiscardBytes removed in DX9 // DX8CALL(ResourceManagerDiscardBytes(bytes)); +#else + DX8CALL(ResourceManagerDiscardBytes(bytes)); +#endif } unsigned int DX8Wrapper::Get_Free_Texture_RAM() @@ -3737,8 +3779,12 @@ void DX8Wrapper::Set_Gamma(float gamma,float bright,float contrast,bool calibrat } if (Get_Current_Caps()->Support_Gamma()) { +#if RTS_USE_DIRECTX9 // TheSuperHackers @feature JohnsterID 14/09/2025 DX9 SetGammaRamp requires swapchain index - DX8Wrapper::_Get_D3D_Device8()->SetGammaRamp(0, flag, &ramp); + DX8Wrapper::_Get_D3D_Device8()->SetGammaRamp(0, flag, &ramp); +#else + DX8Wrapper::_Get_D3D_Device8()->SetGammaRamp(flag, &ramp); +#endif } else { HWND hwnd = GetDesktopWindow(); HDC hdc = GetDC(hwnd); @@ -3785,8 +3831,12 @@ void DX8Wrapper::Apply_Default_State() // Set_DX8_Render_State(D3DRS_FOGDENSITY, WWMath::Float_As_Int(1.0f)); //Set_DX8_Render_State(D3DRS_EDGEANTIALIAS, FALSE); +#if RTS_USE_DIRECTX9 // TheSuperHackers @feature JohnsterID 14/09/2025 D3DRS_ZBIAS replaced with D3DRS_DEPTHBIAS in DX9 Set_DX8_Render_State(D3DRS_DEPTHBIAS, 0); +#else + Set_DX8_Render_State(D3DRS_ZBIAS, 0); +#endif // Set_DX8_Render_State(D3DRS_RANGEFOGENABLE, FALSE); Set_DX8_Render_State(D3DRS_STENCILENABLE, FALSE); Set_DX8_Render_State(D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP); @@ -3862,10 +3912,16 @@ void DX8Wrapper::Apply_Default_State() Set_DX8_Texture_Stage_State(i, D3DTSS_TEXCOORDINDEX, i); +#if RTS_USE_DIRECTX9 // TheSuperHackers @feature JohnsterID 14/09/2025 Address/filter states moved to sampler states in DX9 DX8CALL(SetSamplerState(i, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP)); DX8CALL(SetSamplerState(i, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP)); DX8CALL(SetSamplerState(i, D3DSAMP_BORDERCOLOR, 0)); +#else + Set_DX8_Texture_Stage_State(i, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); + Set_DX8_Texture_Stage_State(i, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); + Set_DX8_Texture_Stage_State(i, D3DTSS_BORDERCOLOR, 0); +#endif // Set_DX8_Texture_Stage_State(i, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); // Set_DX8_Texture_Stage_State(i, D3DTSS_MINFILTER, D3DTEXF_LINEAR); // Set_DX8_Texture_Stage_State(i, D3DTSS_MIPFILTER, D3DTEXF_LINEAR); @@ -3925,17 +3981,25 @@ const char* DX8Wrapper::Get_DX8_Render_State_Name(D3DRENDERSTATETYPE state) case D3DRS_ALPHABLENDENABLE : return "D3DRS_ALPHABLENDENABLE"; case D3DRS_FOGENABLE : return "D3DRS_FOGENABLE"; case D3DRS_SPECULARENABLE : return "D3DRS_SPECULARENABLE"; +#ifndef RTS_USE_DIRECTX9 // TheSuperHackers @feature JohnsterID 14/09/2025 D3DRS_ZVISIBLE removed in DX9 - // case D3DRS_ZVISIBLE : return "D3DRS_ZVISIBLE"; + case D3DRS_ZVISIBLE : return "D3DRS_ZVISIBLE"; +#endif case D3DRS_FOGCOLOR : return "D3DRS_FOGCOLOR"; case D3DRS_FOGTABLEMODE : return "D3DRS_FOGTABLEMODE"; case D3DRS_FOGSTART : return "D3DRS_FOGSTART"; case D3DRS_FOGEND : return "D3DRS_FOGEND"; case D3DRS_FOGDENSITY : return "D3DRS_FOGDENSITY"; +#ifndef RTS_USE_DIRECTX9 // TheSuperHackers @feature JohnsterID 14/09/2025 D3DRS_EDGEANTIALIAS removed in DX9 - // case D3DRS_EDGEANTIALIAS : return "D3DRS_EDGEANTIALIAS"; + case D3DRS_EDGEANTIALIAS : return "D3DRS_EDGEANTIALIAS"; +#endif +#if RTS_USE_DIRECTX9 // TheSuperHackers @feature JohnsterID 14/09/2025 D3DRS_ZBIAS replaced with D3DRS_DEPTHBIAS in DX9 case D3DRS_DEPTHBIAS : return "D3DRS_DEPTHBIAS"; +#else + case D3DRS_ZBIAS : return "D3DRS_ZBIAS"; +#endif case D3DRS_RANGEFOGENABLE : return "D3DRS_RANGEFOGENABLE"; case D3DRS_STENCILENABLE : return "D3DRS_STENCILENABLE"; case D3DRS_STENCILFAIL : return "D3DRS_STENCILFAIL"; @@ -4007,16 +4071,18 @@ const char* DX8Wrapper::Get_DX8_Texture_Stage_State_Name(D3DTEXTURESTAGESTATETYP case D3DTSS_BUMPENVMAT10 : return "D3DTSS_BUMPENVMAT10"; case D3DTSS_BUMPENVMAT11 : return "D3DTSS_BUMPENVMAT11"; case D3DTSS_TEXCOORDINDEX : return "D3DTSS_TEXCOORDINDEX"; +#ifndef RTS_USE_DIRECTX9 // TheSuperHackers @feature JohnsterID 14/09/2025 Address/filter states moved to sampler states in DX9 - // case D3DTSS_ADDRESSU : return "D3DTSS_ADDRESSU"; - // case D3DTSS_ADDRESSV : return "D3DTSS_ADDRESSV"; - // case D3DTSS_BORDERCOLOR : return "D3DTSS_BORDERCOLOR"; - // case D3DTSS_MAGFILTER : return "D3DTSS_MAGFILTER"; - // case D3DTSS_MINFILTER : return "D3DTSS_MINFILTER"; - // case D3DTSS_MIPFILTER : return "D3DTSS_MIPFILTER"; - // case D3DTSS_MIPMAPLODBIAS : return "D3DTSS_MIPMAPLODBIAS"; - // case D3DTSS_MAXMIPLEVEL : return "D3DTSS_MAXMIPLEVEL"; - // case D3DTSS_MAXANISOTROPY : return "D3DTSS_MAXANISOTROPY"; + case D3DTSS_ADDRESSU : return "D3DTSS_ADDRESSU"; + case D3DTSS_ADDRESSV : return "D3DTSS_ADDRESSV"; + case D3DTSS_BORDERCOLOR : return "D3DTSS_BORDERCOLOR"; + case D3DTSS_MAGFILTER : return "D3DTSS_MAGFILTER"; + case D3DTSS_MINFILTER : return "D3DTSS_MINFILTER"; + case D3DTSS_MIPFILTER : return "D3DTSS_MIPFILTER"; + case D3DTSS_MIPMAPLODBIAS : return "D3DTSS_MIPMAPLODBIAS"; + case D3DTSS_MAXMIPLEVEL : return "D3DTSS_MAXMIPLEVEL"; + case D3DTSS_MAXANISOTROPY : return "D3DTSS_MAXANISOTROPY"; +#endif case D3DTSS_BUMPENVLSCALE : return "D3DTSS_BUMPENVLSCALE"; case D3DTSS_BUMPENVLOFFSET : return "D3DTSS_BUMPENVLOFFSET"; case D3DTSS_TEXTURETRANSFORMFLAGS : return "D3DTSS_TEXTURETRANSFORMFLAGS"; @@ -4120,7 +4186,11 @@ void DX8Wrapper::Get_DX8_Render_State_Value_Name(StringClass& name, D3DRENDERSTA name.Format("%f",*(float*)&value); break; +#if RTS_USE_DIRECTX9 + case D3DRS_DEPTHBIAS: +#else case D3DRS_ZBIAS: +#endif case D3DRS_STENCILREF: name.Format("%d",value); break; diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h index 16e1801b6a2..082a5e87e49 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h @@ -41,10 +41,15 @@ #pragma once -// TheSuperHackers @feature JohnsterID 14/09/2025 Migrate from DirectX 8 to DirectX 9 API while keeping existing class names +// TheSuperHackers @feature JohnsterID 14/09/2025 Support both DirectX 8 and DirectX 9 with compile-time selection #include "always.h" #include "dllist.h" + +#if RTS_USE_DIRECTX9 #include "d3d9.h" +#else +#include "d3d8.h" +#endif #include "matrix4.h" #include "statistics.h" #include "wwstring.h" @@ -59,6 +64,29 @@ #include "dx8indexbuffer.h" #include "vertmaterial.h" +// Type aliases for DirectX version compatibility +#if RTS_USE_DIRECTX9 +typedef IDirect3D9 DXInterface; +typedef IDirect3DDevice9 DXDevice; +typedef IDirect3DSurface9 DXSurface; +typedef IDirect3DTexture9 DXTexture; +typedef IDirect3DBaseTexture9 DXBaseTexture; +typedef D3DADAPTER_IDENTIFIER9 DXAdapterIdentifier; +typedef IDirect3D9* (WINAPI *Direct3DCreateType) (UINT SDKVersion); +#define DIRECT3D_CREATE_FUNC Direct3DCreate9 +#define DIRECT3D_SDK_VERSION D3D_SDK_VERSION +#else +typedef IDirect3D8 DXInterface; +typedef IDirect3DDevice8 DXDevice; +typedef IDirect3DSurface8 DXSurface; +typedef IDirect3DTexture8 DXTexture; +typedef IDirect3DBaseTexture8 DXBaseTexture; +typedef D3DADAPTER_IDENTIFIER8 DXAdapterIdentifier; +typedef IDirect3D8* (WINAPI *Direct3DCreateType) (UINT SDKVersion); +#define DIRECT3D_CREATE_FUNC Direct3DCreate8 +#define DIRECT3D_SDK_VERSION D3D_SDK_VERSION +#endif + /* ** Registry value names */ @@ -380,7 +408,7 @@ class DX8Wrapper ); - static IDirect3DTexture9* _Create_DX8_ZTexture + static DXTexture* _Create_DX8_ZTexture ( unsigned int width, unsigned int height, @@ -390,7 +418,7 @@ class DX8Wrapper ); - static IDirect3DTexture9 * _Create_DX8_Texture + static DXTexture * _Create_DX8_Texture ( unsigned int width, unsigned int height, @@ -399,19 +427,19 @@ class DX8Wrapper D3DPOOL pool=D3DPOOL_MANAGED, bool rendertarget=false ); - static IDirect3DTexture9 * _Create_DX8_Texture(const char *filename, MipCountType mip_level_count); - static IDirect3DTexture9 * _Create_DX8_Texture(IDirect3DSurface9 *surface, MipCountType mip_level_count); + static DXTexture * _Create_DX8_Texture(const char *filename, MipCountType mip_level_count); + static DXTexture * _Create_DX8_Texture(DXSurface *surface, MipCountType mip_level_count); - static IDirect3DSurface9 * _Create_DX8_Surface(unsigned int width, unsigned int height, WW3DFormat format); - static IDirect3DSurface9 * _Create_DX8_Surface(const char *filename); - static IDirect3DSurface9 * _Get_DX8_Front_Buffer(); + static DXSurface * _Create_DX8_Surface(unsigned int width, unsigned int height, WW3DFormat format); + static DXSurface * _Create_DX8_Surface(const char *filename); + static DXSurface * _Get_DX8_Front_Buffer(); static SurfaceClass * _Get_DX8_Back_Buffer(unsigned int num=0); static void _Copy_DX8_Rects( - IDirect3DSurface9* pSourceSurface, + DXSurface* pSourceSurface, CONST RECT* pSourceRectsArray, UINT cRects, - IDirect3DSurface9* pDestinationSurface, + DXSurface* pDestinationSurface, CONST POINT* pDestPointsArray ); @@ -481,8 +509,8 @@ class DX8Wrapper */ static TextureClass * Create_Render_Target (int width, int height, WW3DFormat format = WW3D_FORMAT_UNKNOWN); - static void Set_Render_Target (IDirect3DSurface9 *render_target, bool use_default_depth_buffer = false); - static void Set_Render_Target (IDirect3DSurface9* render_target, IDirect3DSurface9* dpeth_buffer); + static void Set_Render_Target (DXSurface *render_target, bool use_default_depth_buffer = false); + static void Set_Render_Target (DXSurface* render_target, DXSurface* dpeth_buffer); static void Set_Render_Target (IDirect3DSwapChain9 *swap_chain); static bool Is_Render_To_Texture(void) { return IsRenderToTexture; } @@ -522,8 +550,8 @@ class DX8Wrapper - static IDirect3DDevice9* _Get_D3D_Device8() { return D3DDevice; } - static IDirect3D9* _Get_D3D8() { return D3DInterface; } + static DXDevice* _Get_D3D_Device8() { return D3DDevice; } + static DXInterface* _Get_D3D8() { return D3DInterface; } /// Returns the display format - added by TR for video playback - not part of W3D static WW3DFormat getBackBufferFormat( void ); static bool Reset_Device(bool reload_assets=true); @@ -686,15 +714,15 @@ class DX8Wrapper static DX8Caps* CurrentCaps; - static D3DADAPTER_IDENTIFIER9 CurrentAdapterIdentifier; + static DXAdapterIdentifier CurrentAdapterIdentifier; - static IDirect3D9 * D3DInterface; //d3d8; - static IDirect3DDevice9 * D3DDevice; //d3ddevice8; + static DXInterface * D3DInterface; //d3d8; + static DXDevice * D3DDevice; //d3ddevice8; - static IDirect3DSurface9 * CurrentRenderTarget; - static IDirect3DSurface9 * CurrentDepthBuffer; - static IDirect3DSurface9 * DefaultRenderTarget; - static IDirect3DSurface9 * DefaultDepthBuffer; + static DXSurface * CurrentRenderTarget; + static DXSurface * CurrentDepthBuffer; + static DXSurface * DefaultRenderTarget; + static DXSurface * DefaultDepthBuffer; static unsigned DrawPolygonLowBoundLimit; @@ -936,10 +964,10 @@ WWINLINE void DX8Wrapper::Set_DX8_Texture(unsigned int stage, IDirect3DBaseTextu } WWINLINE void DX8Wrapper::_Copy_DX8_Rects( - IDirect3DSurface9* pSourceSurface, + DXSurface* pSourceSurface, CONST RECT* pSourceRectsArray, UINT cRects, - IDirect3DSurface9* pDestinationSurface, + DXSurface* pDestinationSurface, CONST POINT* pDestPointsArray ) { diff --git a/cmake/config-build.cmake b/cmake/config-build.cmake index 6401c458be0..ea79671443f 100644 --- a/cmake/config-build.cmake +++ b/cmake/config-build.cmake @@ -8,6 +8,7 @@ option(RTS_BUILD_OPTION_DEBUG "Build code with the \"Debug\" configuration." OFF option(RTS_BUILD_OPTION_ASAN "Build code with Address Sanitizer." OFF) option(RTS_BUILD_OPTION_VC6_FULL_DEBUG "Build VC6 with full debug info." OFF) option(RTS_BUILD_OPTION_FFMPEG "Enable FFmpeg support" OFF) +option(RTS_USE_DIRECTX9 "Use DirectX 9 instead of DirectX 8" OFF) if(NOT RTS_BUILD_ZEROHOUR AND NOT RTS_BUILD_GENERALS) set(RTS_BUILD_ZEROHOUR TRUE) @@ -23,6 +24,7 @@ add_feature_info(DebugBuild RTS_BUILD_OPTION_DEBUG "Building as a \"Debug\" buil add_feature_info(AddressSanitizer RTS_BUILD_OPTION_ASAN "Building with address sanitizer") add_feature_info(Vc6FullDebug RTS_BUILD_OPTION_VC6_FULL_DEBUG "Building VC6 with full debug info") add_feature_info(FFmpegSupport RTS_BUILD_OPTION_FFMPEG "Building with FFmpeg support") +add_feature_info(DirectX9Support RTS_USE_DIRECTX9 "Building with DirectX 9 instead of DirectX 8") if(RTS_BUILD_ZEROHOUR) option(RTS_BUILD_ZEROHOUR_TOOLS "Build tools for Zero Hour" ON) @@ -73,3 +75,7 @@ endif() if(RTS_BUILD_OPTION_PROFILE) target_compile_definitions(core_config INTERFACE RTS_PROFILE) endif() + +if(RTS_USE_DIRECTX9) + target_compile_definitions(core_config INTERFACE RTS_USE_DIRECTX9) +endif() diff --git a/cmake/dx9.cmake b/cmake/dx9.cmake index c899a04e52f..55dbc83f72d 100644 --- a/cmake/dx9.cmake +++ b/cmake/dx9.cmake @@ -1,7 +1,11 @@ FetchContent_Declare( dx9 GIT_REPOSITORY https://github.com/madebr/min-dx9-sdk.git - GIT_TAG main + GIT_TAG 5597304 ) -FetchContent_MakeAvailable(dx9) \ No newline at end of file +FetchContent_MakeAvailable(dx9) + +# Create d3d8lib alias for DirectX 9 to maintain compatibility with existing code +add_library(d3d8lib INTERFACE) +target_link_libraries(d3d8lib INTERFACE d3d9lib) \ No newline at end of file From bb93ca1c1f5db7a2e639e1bca91bc88550f6bea8 Mon Sep 17 00:00:00 2001 From: JohnsterID <69278611+JohnsterID@users.noreply.github.com> Date: Sat, 20 Sep 2025 05:41:01 +0000 Subject: [PATCH 3/5] fix: resolve duplicate D3DFMT_A8R8G8B8 entry in format conversion array Use conditional compilation to properly handle X8R8G8B8 format mapping: - DX8: WW3D_FORMAT_X8R8G8B8 -> D3DFMT_X8R8G8B8 (native format) - DX9: WW3D_FORMAT_X8R8G8B8 -> D3DFMT_A8R8G8B8 (X8R8G8B8 not available) This eliminates the confusing duplicate array entry while maintaining correct format mapping for both DirectX versions. --- Core/Libraries/Source/WWVegas/WW3D2/formconv.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Core/Libraries/Source/WWVegas/WW3D2/formconv.cpp b/Core/Libraries/Source/WWVegas/WW3D2/formconv.cpp index 17aed5f6a5b..1c737208965 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/formconv.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/formconv.cpp @@ -43,7 +43,11 @@ D3DFORMAT WW3DFormatToD3DFormatConversionArray[WW3D_FORMAT_COUNT] = { D3DFMT_R8G8B8, D3DFMT_A8R8G8B8, // TheSuperHackers @feature JohnsterID 14/09/2025 D3DFMT_X8R8G8B8 replaced with D3DFMT_A8R8G8B8 in DX9 - D3DFMT_A8R8G8B8, +#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, @@ -214,7 +218,12 @@ 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 - // WW3D_FORMAT_X8R8G8B8 now maps to D3DFMT_A8R8G8B8, but reverse mapping prioritizes WW3D_FORMAT_A8R8G8B8 +#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; From 4a9be8cd0fca75f35091820697e2d9a31a3ce3b5 Mon Sep 17 00:00:00 2001 From: JohnsterID <69278611+JohnsterID@users.noreply.github.com> Date: Thu, 8 Jan 2026 22:28:36 +0000 Subject: [PATCH 4/5] fix(dx9): Add missing type aliases in dx8caps.h and fix duplicate case in assetmgr.cpp TheSuperHackers @fix JohnsterID 08/01/2026 Issue #1: dx8caps.h used hardcoded DX9 types (IDirect3D9, D3DCAPS9, etc.) but default builds use DX8, causing compilation errors. Fix: Added conditional type aliases matching dx8wrapper.h pattern: - DXInterface (IDirect3D9/IDirect3D8) - DXDevice (IDirect3DDevice9/IDirect3DDevice8) - DXCaps (D3DCAPS9/D3DCAPS8) - DXAdapterIdentifier (D3DADAPTER_IDENTIFIER9/8) Updated all function declarations and member variables to use these aliases. Issue #2: Generals assetmgr.cpp had duplicate case D3DFMT_A8R8G8B8 (line 319) Fix: Reverted Generals file to use D3DFMT_X8R8G8B8 (no conditional needed) Fix: Added conditional compilation to GeneralsMD file to handle both formats This ensures DX8 builds work by default (RTS_USE_DIRECTX9=OFF) and DX9 only builds when the flag is enabled (RTS_USE_DIRECTX9=ON). --- .../Source/WWVegas/WW3D2/assetmgr.cpp | 3 +- .../Source/WWVegas/WW3D2/assetmgr.cpp | 8 +++- .../Libraries/Source/WWVegas/WW3D2/dx8caps.h | 43 ++++++++++++------- 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp index 46f7255bb14..15afd75578c 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp @@ -315,8 +315,7 @@ 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 replaced with D3DFMT_A8R8G8B8 in DX9 - case D3DFMT_A8R8G8B8: tex_format="D3DFMT_A8R8G8B8"; break; + case D3DFMT_X8R8G8B8: tex_format="D3DFMT_X8R8G8B8"; break; case D3DFMT_X1R5G5B5: tex_format="D3DFMT_X1R5G5B5"; break; case D3DFMT_R3G3B2: tex_format="D3DFMT_R3G3B2"; break; case D3DFMT_A8R3G3B2: tex_format="D3DFMT_A8R3G3B2"; break; diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp index ae83c996fb5..d77a724e67e 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp @@ -320,8 +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 replaced with D3DFMT_A8R8G8B8 in DX9 - case D3DFMT_A8R8G8B8: tex_format="D3DFMT_A8R8G8B8"; 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; diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8caps.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8caps.h index 85636546010..fd2fb770920 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8caps.h +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8caps.h @@ -48,6 +48,19 @@ #include #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 { public: @@ -209,11 +222,11 @@ class DX8Caps }; - DX8Caps(IDirect3D9* direct3d, const D3DCAPS9& caps,WW3DFormat display_format, const D3DADAPTER_IDENTIFIER9& adapter_id); - DX8Caps(IDirect3D9* direct3d, IDirect3DDevice9* D3DDevice,WW3DFormat display_format, const D3DADAPTER_IDENTIFIER9& 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_IDENTIFIER9& 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; } @@ -250,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]; } - D3DCAPS9 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; } @@ -274,21 +287,21 @@ class DX8Caps static DeviceTypeS3 Get_S3_Device(unsigned device_id); static DeviceTypeIntel Get_Intel_Device(unsigned device_id); - void Init_Caps(IDirect3DDevice9* D3DDevice); - void Check_Texture_Format_Support(WW3DFormat display_format,const D3DCAPS9& caps); - void Check_Render_To_Texture_Support(WW3DFormat display_format,const D3DCAPS9& caps); - void Check_Depth_Stencil_Support(WW3DFormat display_format, const D3DCAPS9& caps); - void Check_Texture_Compression_Support(const D3DCAPS9& caps); - void Check_Bumpmap_Support(const D3DCAPS9& caps); - void Check_Shader_Support(const D3DCAPS9& caps); - void Check_Maximum_Texture_Support(const D3DCAPS9& 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_IDENTIFIER9& adapter_id); + void Vendor_Specific_Hacks(const DXAdapterIdentifier& adapter_id); int MaxDisplayWidth; int MaxDisplayHeight; - D3DCAPS9 Caps; + DXCaps Caps; bool SupportTnL; bool SupportDXTC; bool supportGamma; @@ -315,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; }; From 1caa53aa85fa48a6d8c1fb7162a82f1c676db06e Mon Sep 17 00:00:00 2001 From: JohnsterID <69278611+JohnsterID@users.noreply.github.com> Date: Thu, 8 Jan 2026 22:33:59 +0000 Subject: [PATCH 5/5] fix(dx9): Add missing typedefs for DXLight, DXViewport, DXMaterial in dx8wrapper.h TheSuperHackers @fix JohnsterID 08/01/2026 Issue: dx8wrapper.h still had hardcoded DX9 types in multiple locations: - D3DLIGHT9 (line 208, 344, 353, 364, etc.) - D3DVIEWPORT9 (line 309) - D3DMATERIAL9 (line 321, 873) - IDirect3DBaseTexture9 (lines 348, 695, 948) These caused compilation errors in default DX8 builds. Fix: Added missing type aliases and replaced all hardcoded types: - typedef D3DLIGHT9/D3DLIGHT8 DXLight - typedef D3DVIEWPORT9/D3DVIEWPORT8 DXViewport - typedef D3DMATERIAL9/D3DMATERIAL8 DXMaterial Used sed to replace all occurrences throughout the file. Note: The growing number of conditional compilation changes suggests Mauller's recommendation (separate DX8/DX9 files) may be more maintainable long-term than this typedef approach. --- .../Source/WWVegas/WW3D2/dx8wrapper.h | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h index 082a5e87e49..cedc8a66c76 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h @@ -72,6 +72,9 @@ typedef IDirect3DSurface9 DXSurface; typedef IDirect3DTexture9 DXTexture; typedef IDirect3DBaseTexture9 DXBaseTexture; typedef D3DADAPTER_IDENTIFIER9 DXAdapterIdentifier; +typedef D3DLIGHT9 DXLight; +typedef D3DVIEWPORT9 DXViewport; +typedef D3DMATERIAL9 DXMaterial; typedef IDirect3D9* (WINAPI *Direct3DCreateType) (UINT SDKVersion); #define DIRECT3D_CREATE_FUNC Direct3DCreate9 #define DIRECT3D_SDK_VERSION D3D_SDK_VERSION @@ -82,6 +85,9 @@ typedef IDirect3DSurface8 DXSurface; typedef IDirect3DTexture8 DXTexture; typedef IDirect3DBaseTexture8 DXBaseTexture; typedef D3DADAPTER_IDENTIFIER8 DXAdapterIdentifier; +typedef D3DLIGHT8 DXLight; +typedef D3DVIEWPORT8 DXViewport; +typedef D3DMATERIAL8 DXMaterial; typedef IDirect3D8* (WINAPI *Direct3DCreateType) (UINT SDKVersion); #define DIRECT3D_CREATE_FUNC Direct3DCreate8 #define DIRECT3D_SDK_VERSION D3D_SDK_VERSION @@ -205,7 +211,7 @@ struct RenderStateStruct ShaderClass shader; VertexMaterialClass* material; TextureBaseClass * Textures[MAX_TEXTURE_STAGES]; - D3DLIGHT9 Lights[4]; + DXLight Lights[4]; bool LightEnable[4]; //unsigned lightsHash; Matrix4x4 world; @@ -306,7 +312,7 @@ class DX8Wrapper static void Clear(bool clear_color, bool clear_z_stencil, const Vector3 &color, float dest_alpha=0.0f, float z=1.0f, unsigned int stencil=0); - static void Set_Viewport(CONST D3DVIEWPORT9* pViewport); + static void Set_Viewport(CONST DXViewport* pViewport); static void Set_Vertex_Buffer(const VertexBufferClass* vb, unsigned stream=0); static void Set_Vertex_Buffer(const DynamicVBAccessClass& vba); @@ -318,7 +324,7 @@ class DX8Wrapper static void Set_Render_State(const RenderStateStruct& state); static void Release_Render_State(); - static void Set_DX8_Material(const D3DMATERIAL9* mat); + static void Set_DX8_Material(const DXMaterial* mat); static void Set_Gamma(float gamma,float bright,float contrast,bool calibrate=true,bool uselimit=true); @@ -341,16 +347,16 @@ class DX8Wrapper static void _Set_DX8_Transform(D3DTRANSFORMSTATETYPE transform,const Matrix3D& m); static void _Get_DX8_Transform(D3DTRANSFORMSTATETYPE transform, Matrix4x4& m); - static void Set_DX8_Light(int index,D3DLIGHT9* light); + static void Set_DX8_Light(int index,DXLight* light); static void Set_DX8_Render_State(D3DRENDERSTATETYPE state, unsigned value); static void Set_DX8_Clip_Plane(DWORD Index, CONST float* pPlane); static void Set_DX8_Texture_Stage_State(unsigned stage, D3DTEXTURESTAGESTATETYPE state, unsigned value); - static void Set_DX8_Texture(unsigned int stage, IDirect3DBaseTexture9* texture); + static void Set_DX8_Texture(unsigned int stage, DXBaseTexture* texture); static void Set_Light_Environment(LightEnvironmentClass* light_env); static LightEnvironmentClass* Get_Light_Environment() { return Light_Environment; } static void Set_Fog(bool enable, const Vector3 &color, float start, float end); - static WWINLINE const D3DLIGHT9& Peek_Light(unsigned index); + static WWINLINE const DXLight& Peek_Light(unsigned index); static WWINLINE bool Is_Light_Enabled(unsigned index); static bool Validate_Device(void); @@ -361,7 +367,7 @@ class DX8Wrapper static void Get_Shader(ShaderClass& shader); static void Set_Texture(unsigned stage,TextureBaseClass* texture); static void Set_Material(const VertexMaterialClass* material); - static void Set_Light(unsigned index,const D3DLIGHT9* light); + static void Set_Light(unsigned index,const DXLight* light); static void Set_Light(unsigned index,const LightClass &light); static void Apply_Render_State_Changes(); // Apply deferred render state changes (will be called automatically by Draw...) @@ -692,7 +698,7 @@ class DX8Wrapper static bool world_identity; static unsigned RenderStates[256]; static unsigned TextureStageStates[MAX_TEXTURE_STAGES][32]; - static IDirect3DBaseTexture9 * Textures[MAX_TEXTURE_STAGES]; + static DXBaseTexture * Textures[MAX_TEXTURE_STAGES]; // These fog settings are constant for all objects in a given scene, // unlike the matching renderstates which vary based on shader settings. @@ -870,7 +876,7 @@ WWINLINE void DX8Wrapper::Set_Ambient(const Vector3& color) // // ---------------------------------------------------------------------------- -WWINLINE void DX8Wrapper::Set_DX8_Material(const D3DMATERIAL9* mat) +WWINLINE void DX8Wrapper::Set_DX8_Material(const DXMaterial* mat) { DX8_RECORD_MATERIAL_CHANGE(); WWASSERT(mat); @@ -945,7 +951,7 @@ WWINLINE void DX8Wrapper::Set_DX8_Texture_Stage_State(unsigned stage, D3DTEXTURE DX8_RECORD_TEXTURE_STAGE_STATE_CHANGE(); } -WWINLINE void DX8Wrapper::Set_DX8_Texture(unsigned int stage, IDirect3DBaseTexture9* texture) +WWINLINE void DX8Wrapper::Set_DX8_Texture(unsigned int stage, DXBaseTexture* texture) { if (stage >= MAX_TEXTURE_STAGES) { DX8CALL(SetTexture(stage, texture));