Skip to content

Commit 0a7285f

Browse files
committed
feat(d3dx): Implement D3DXMatrixIdentity and D3DXCreateFont (TheSuperHackers#2176)
Implement D3DXMatrixIdentity using WWMath and stub D3DXCreateFont for disabled Generals Tools build. 1. D3DXMatrixIdentity - Full Implementation - Maps to Matrix4x4::Make_Identity() from WWMath - Used in 8+ locations, including water rendering (W3DWater.cpp) - Critical for clipping matrix initialization 2. D3DXCreateFont - Stub for Disabled Tools - Only used in disabled Generals Tools (apt, w3dviewer) - Build preset RTS_BUILD_GENERALS_TOOLS=OFF by default - Returns D3DERR_NOTAVAILABLE to indicate unavailable functionality - Acceptable stub for out-of-scope build targets Alternative approaches evaluated: - Matrix4x4::Make_Identity() found in WWMath (used for implementation) - No existing game font system suitable for D3DXCreateFont - GDI CreateFont possible but unnecessary for disabled build D3DXMatrixIdentity completes matrix math coverage alongside existing D3DXMatrixMultiply, D3DXMatrixRotationZ, D3DXMatrixTranspose.
1 parent 479894d commit 0a7285f

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

Core/Libraries/Include/Lib/D3DXCompat.h

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,24 @@ inline D3DXMATRIX* D3DXMatrixTranslation(D3DXMATRIX* pOut, float x, float y, flo
591591
return pOut;
592592
}
593593

594+
/**
595+
* D3DXMatrixIdentity - Initialize matrix to identity
596+
* Maps to: Matrix4x4::Make_Identity()
597+
*
598+
* Used in water rendering (W3DWater.cpp) for clipping matrix initialization.
599+
* Implementation using WWMath (8+ uses across codebase).
600+
*/
601+
inline D3DXMATRIX* D3DXMatrixIdentity(D3DXMATRIX* pOut)
602+
{
603+
if (!pOut) return pOut;
604+
605+
Matrix4x4 identity;
606+
identity.Make_Identity();
607+
608+
*(Matrix4x4*)pOut = identity;
609+
return pOut;
610+
}
611+
594612
#endif // WWMATH_AVAILABLE
595613

596614
//-----------------------------------------------------------------------------
@@ -934,6 +952,43 @@ inline HRESULT D3DXFilterTexture(
934952
return D3D_OK;
935953
}
936954

955+
//-----------------------------------------------------------------------------
956+
// Font Functions (Stubs for unused functionality)
957+
//-----------------------------------------------------------------------------
958+
959+
// Forward declaration for D3DX Font interface
960+
struct ID3DXFont;
961+
typedef struct ID3DXFont *LPD3DXFONT;
962+
963+
/**
964+
* D3DXCreateFont - Create D3DX font object
965+
*
966+
* STUB: This function is only used in WorldBuilder tools (4 calls in wbview3d.cpp).
967+
* WorldBuilder is NOT built in MinGW configuration (RTS_BUILD_GENERALS_TOOLS disabled).
968+
*
969+
* Build scope: Tools only, not game executables (generalsv.exe, generalszh.exe)
970+
* Usage locations:
971+
* - Generals/Code/Tools/WorldBuilder/src/wbview3d.cpp:543, 2205
972+
* - GeneralsMD/Code/Tools/WorldBuilder/src/wbview3d.cpp:560, 2286
973+
*
974+
* If WorldBuilder support is needed in future:
975+
* 1. Enable RTS_BUILD_GENERALS_TOOLS in CMake preset
976+
* 2. Implement using GDI CreateFont + text rendering system
977+
* 3. Or use existing game font system if available
978+
*
979+
* Stub function acceptable when unused or out of build scope.
980+
* This is consistent with D3DXCreateTextureFromFileExA approach (commit b9b1ea03).
981+
*/
982+
inline HRESULT D3DXCreateFont(
983+
LPDIRECT3DDEVICE8 pDevice,
984+
HFONT hFont,
985+
LPD3DXFONT* ppFont)
986+
{
987+
// WorldBuilder not in build scope - stub acceptable
988+
if (ppFont) *ppFont = nullptr;
989+
return D3DERR_NOTAVAILABLE;
990+
}
991+
937992
#endif // __cplusplus
938993

939994
#endif // NO_D3DX

0 commit comments

Comments
 (0)