From 590cdeb13060ad73e6a4d4214548db9cdc9f716f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 Oct 2017 21:52:10 +0200 Subject: [PATCH] Convert d3d_w32_font to C --- .../{d3d_w32_font.cpp => d3d_w32_font.c} | 0 gfx/include/d3d9/d3dx9math.h | 195 +++++++++--------- griffin/griffin.c | 4 + griffin/griffin_cpp.cpp | 5 - 4 files changed, 100 insertions(+), 104 deletions(-) rename gfx/drivers_font/{d3d_w32_font.cpp => d3d_w32_font.c} (100%) diff --git a/gfx/drivers_font/d3d_w32_font.cpp b/gfx/drivers_font/d3d_w32_font.c similarity index 100% rename from gfx/drivers_font/d3d_w32_font.cpp rename to gfx/drivers_font/d3d_w32_font.c diff --git a/gfx/include/d3d9/d3dx9math.h b/gfx/include/d3d9/d3dx9math.h index 512070665e..165014b0df 100644 --- a/gfx/include/d3d9/d3dx9math.h +++ b/gfx/include/d3d9/d3dx9math.h @@ -57,25 +57,26 @@ public: D3DXFLOAT16( FLOAT ); D3DXFLOAT16( CONST D3DXFLOAT16& ); - // casting + /* casting */ operator FLOAT (); - // binary operators + /* binary operators */ BOOL operator == ( CONST D3DXFLOAT16& ) const; BOOL operator != ( CONST D3DXFLOAT16& ) const; protected: -#endif //__cplusplus +#endif /*__cplusplus */ WORD value; } D3DXFLOAT16, *LPD3DXFLOAT16; -//=========================================================================== -// -// Vectors -// -//=========================================================================== +/*=========================================================================== + * + * Vectors + * + *=========================================================================== + */ //-------------------------- @@ -90,21 +91,21 @@ public: D3DXVECTOR2( CONST D3DXFLOAT16 * ); D3DXVECTOR2( FLOAT x, FLOAT y ); - // casting + /* casting */ operator FLOAT* (); operator CONST FLOAT* () const; - // assignment operators + /* assignment operators */ D3DXVECTOR2& operator += ( CONST D3DXVECTOR2& ); D3DXVECTOR2& operator -= ( CONST D3DXVECTOR2& ); D3DXVECTOR2& operator *= ( FLOAT ); D3DXVECTOR2& operator /= ( FLOAT ); - // unary operators + /* unary operators */ D3DXVECTOR2 operator + () const; D3DXVECTOR2 operator - () const; - // binary operators + /* binary operators */ D3DXVECTOR2 operator + ( CONST D3DXVECTOR2& ) const; D3DXVECTOR2 operator - ( CONST D3DXVECTOR2& ) const; D3DXVECTOR2 operator * ( FLOAT ) const; @@ -117,7 +118,7 @@ public: public: -#endif //__cplusplus +#endif /*__cplusplus */ FLOAT x, y; } D3DXVECTOR2, *LPD3DXVECTOR2; @@ -136,25 +137,24 @@ public: D3DXVECTOR2_16F( CONST D3DXFLOAT16 * ); D3DXVECTOR2_16F( CONST D3DXFLOAT16 &x, CONST D3DXFLOAT16 &y ); - // casting + /* casting */ operator D3DXFLOAT16* (); operator CONST D3DXFLOAT16* () const; - // binary operators + /* binary operators */ BOOL operator == ( CONST D3DXVECTOR2_16F& ) const; BOOL operator != ( CONST D3DXVECTOR2_16F& ) const; public: -#endif //__cplusplus +#endif /*__cplusplus */ D3DXFLOAT16 x, y; } D3DXVECTOR2_16F, *LPD3DXVECTOR2_16F; - - -//-------------------------- -// 3D Vector -//-------------------------- +/*-------------------------- + * 3D Vector + *-------------------------- + */ #ifdef __cplusplus typedef struct D3DXVECTOR3 : public D3DVECTOR { @@ -165,21 +165,21 @@ public: D3DXVECTOR3( CONST D3DXFLOAT16 * ); D3DXVECTOR3( FLOAT x, FLOAT y, FLOAT z ); - // casting + /* casting */ operator FLOAT* (); operator CONST FLOAT* () const; - // assignment operators + /* assignment operators */ D3DXVECTOR3& operator += ( CONST D3DXVECTOR3& ); D3DXVECTOR3& operator -= ( CONST D3DXVECTOR3& ); D3DXVECTOR3& operator *= ( FLOAT ); D3DXVECTOR3& operator /= ( FLOAT ); - // unary operators + /* unary operators */ D3DXVECTOR3 operator + () const; D3DXVECTOR3 operator - () const; - // binary operators + /* binary operators */ D3DXVECTOR3 operator + ( CONST D3DXVECTOR3& ) const; D3DXVECTOR3 operator - ( CONST D3DXVECTOR3& ) const; D3DXVECTOR3 operator * ( FLOAT ) const; @@ -192,15 +192,15 @@ public: } D3DXVECTOR3, *LPD3DXVECTOR3; -#else //!__cplusplus +#else /* !__cplusplus */ typedef struct _D3DVECTOR D3DXVECTOR3, *LPD3DXVECTOR3; -#endif //!__cplusplus +#endif /* !__cplusplus */ +/*-------------------------- + * 3D Vector (16 bit) + *-------------------------- + */ - -//-------------------------- -// 3D Vector (16 bit) -//-------------------------- typedef struct D3DXVECTOR3_16F { #ifdef __cplusplus @@ -211,25 +211,24 @@ public: D3DXVECTOR3_16F( CONST D3DXFLOAT16 * ); D3DXVECTOR3_16F( CONST D3DXFLOAT16 &x, CONST D3DXFLOAT16 &y, CONST D3DXFLOAT16 &z ); - // casting + /* casting */ operator D3DXFLOAT16* (); operator CONST D3DXFLOAT16* () const; - // binary operators + /* binary operators */ BOOL operator == ( CONST D3DXVECTOR3_16F& ) const; BOOL operator != ( CONST D3DXVECTOR3_16F& ) const; public: -#endif //__cplusplus +#endif /*__cplusplus */ D3DXFLOAT16 x, y, z; } D3DXVECTOR3_16F, *LPD3DXVECTOR3_16F; - - -//-------------------------- -// 4D Vector -//-------------------------- +/*-------------------------- + * 4D Vector + *-------------------------- + */ typedef struct D3DXVECTOR4 { #ifdef __cplusplus @@ -240,21 +239,21 @@ public: D3DXVECTOR4( CONST D3DVECTOR& xyz, FLOAT w ); D3DXVECTOR4( FLOAT x, FLOAT y, FLOAT z, FLOAT w ); - // casting + /* casting */ operator FLOAT* (); operator CONST FLOAT* () const; - // assignment operators + /* assignment operators */ D3DXVECTOR4& operator += ( CONST D3DXVECTOR4& ); D3DXVECTOR4& operator -= ( CONST D3DXVECTOR4& ); D3DXVECTOR4& operator *= ( FLOAT ); D3DXVECTOR4& operator /= ( FLOAT ); - // unary operators + /* unary operators */ D3DXVECTOR4 operator + () const; D3DXVECTOR4 operator - () const; - // binary operators + /* binary operators */ D3DXVECTOR4 operator + ( CONST D3DXVECTOR4& ) const; D3DXVECTOR4 operator - ( CONST D3DXVECTOR4& ) const; D3DXVECTOR4 operator * ( FLOAT ) const; @@ -266,14 +265,15 @@ public: BOOL operator != ( CONST D3DXVECTOR4& ) const; public: -#endif //__cplusplus +#endif /*__cplusplus */ FLOAT x, y, z, w; } D3DXVECTOR4, *LPD3DXVECTOR4; -//-------------------------- -// 4D Vector (16 bit) -//-------------------------- +/*-------------------------- + * 4D Vector (16 bit) + *-------------------------- + */ typedef struct D3DXVECTOR4_16F { #ifdef __cplusplus @@ -284,27 +284,26 @@ public: D3DXVECTOR4_16F( CONST D3DXVECTOR3_16F& xyz, CONST D3DXFLOAT16& w ); D3DXVECTOR4_16F( CONST D3DXFLOAT16& x, CONST D3DXFLOAT16& y, CONST D3DXFLOAT16& z, CONST D3DXFLOAT16& w ); - // casting + /* casting */ operator D3DXFLOAT16* (); operator CONST D3DXFLOAT16* () const; - // binary operators + /* binary operators */ BOOL operator == ( CONST D3DXVECTOR4_16F& ) const; BOOL operator != ( CONST D3DXVECTOR4_16F& ) const; public: -#endif //__cplusplus +#endif /* __cplusplus */ D3DXFLOAT16 x, y, z, w; } D3DXVECTOR4_16F, *LPD3DXVECTOR4_16F; - - -//=========================================================================== -// -// Matrices -// -//=========================================================================== +/*=========================================================================== + * + * Matrices + * + *=========================================================================== + */ #ifdef __cplusplus typedef struct D3DXMATRIX : public D3DMATRIX { @@ -319,26 +318,26 @@ public: FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ); - // access grants + /* access grants */ FLOAT& operator () ( UINT Row, UINT Col ); FLOAT operator () ( UINT Row, UINT Col ) const; - // casting operators + /* casting operators */ operator FLOAT* (); operator CONST FLOAT* () const; - // assignment operators + /* assignment operators */ D3DXMATRIX& operator *= ( CONST D3DXMATRIX& ); D3DXMATRIX& operator += ( CONST D3DXMATRIX& ); D3DXMATRIX& operator -= ( CONST D3DXMATRIX& ); D3DXMATRIX& operator *= ( FLOAT ); D3DXMATRIX& operator /= ( FLOAT ); - // unary operators + /* unary operators */ D3DXMATRIX operator + () const; D3DXMATRIX operator - () const; - // binary operators + /* binary operators */ D3DXMATRIX operator * ( CONST D3DXMATRIX& ) const; D3DXMATRIX operator + ( CONST D3DXMATRIX& ) const; D3DXMATRIX operator - ( CONST D3DXMATRIX& ) const; @@ -352,27 +351,28 @@ public: } D3DXMATRIX, *LPD3DXMATRIX; -#else //!__cplusplus +#else /* !__cplusplus */ typedef struct _D3DMATRIX D3DXMATRIX, *LPD3DXMATRIX; -#endif //!__cplusplus +#endif /* !__cplusplus */ -//--------------------------------------------------------------------------- -// Aligned Matrices -// -// This class helps keep matrices 16-byte aligned as preferred by P4 cpus. -// It aligns matrices on the stack and on the heap or in global scope. -// It does this using __declspec(align(16)) which works on VC7 and on VC 6 -// with the processor pack. Unfortunately there is no way to detect the -// latter so this is turned on only on VC7. On other compilers this is the -// the same as D3DXMATRIX. -// -// Using this class on a compiler that does not actually do the alignment -// can be dangerous since it will not expose bugs that ignore alignment. -// E.g if an object of this class in inside a struct or class, and some code -// memcopys data in it assuming tight packing. This could break on a compiler -// that eventually start aligning the matrix. -//--------------------------------------------------------------------------- +/*--------------------------------------------------------------------------- + * Aligned Matrices + * + * This class helps keep matrices 16-byte aligned as preferred by P4 cpus. + * It aligns matrices on the stack and on the heap or in global scope. + * It does this using __declspec(align(16)) which works on VC7 and on VC 6 + * with the processor pack. Unfortunately there is no way to detect the + * latter so this is turned on only on VC7. On other compilers this is the + * the same as D3DXMATRIX. + * + * Using this class on a compiler that does not actually do the alignment + * can be dangerous since it will not expose bugs that ignore alignment. + * E.g if an object of this class in inside a struct or class, and some code + * memcopys data in it assuming tight packing. This could break on a compiler + * that eventually start aligning the matrix. + *--------------------------------------------------------------------------- + */ #ifdef __cplusplus typedef struct _D3DXMATRIXA16 : public D3DXMATRIX { @@ -385,35 +385,31 @@ typedef struct _D3DXMATRIXA16 : public D3DXMATRIX FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ); - // new operators + /* new operators */ void* operator new ( size_t ); void* operator new[] ( size_t ); - // delete operators - void operator delete ( void* ); // These are NOT virtual; Do not - void operator delete[] ( void* ); // cast to D3DXMATRIX and delete. + /* delete operators */ + void operator delete ( void* ); /* These are NOT virtual; Do not */ + void operator delete[] ( void* ); /* cast to D3DXMATRIX and delete. */ - // assignment operators + /* assignment operators */ _D3DXMATRIXA16& operator = ( CONST D3DXMATRIX& ); } _D3DXMATRIXA16; -#else //!__cplusplus +#else /* !__cplusplus */ typedef D3DXMATRIX _D3DXMATRIXA16; -#endif //!__cplusplus +#endif /* !__cplusplus */ - - -#if _MSC_VER >= 1300 // VC7 +#if _MSC_VER >= 1300 /* VC7 */ #define D3DX_ALIGN16 __declspec(align(16)) #else -#define D3DX_ALIGN16 // Earlier compiler may not understand this, do nothing. +#define D3DX_ALIGN16 /* Earlier compiler may not understand this, do nothing. */ #endif typedef D3DX_ALIGN16 _D3DXMATRIXA16 D3DXMATRIXA16, *LPD3DXMATRIXA16; - - //=========================================================================== // // Quaternions @@ -898,7 +894,7 @@ BOOL D3DXMatrixIsIdentity ( CONST D3DXMATRIX *pM ); -// non-inline +/* non-inline */ #ifdef __cplusplus extern "C" { #endif @@ -1062,19 +1058,19 @@ D3DXMATRIX* WINAPI D3DXMatrixReflect // Quaternion //-------------------------- -// inline +/* inline */ FLOAT D3DXQuaternionLength ( CONST D3DXQUATERNION *pQ ); -// Length squared, or "norm" +/* Length squared, or "norm" */ FLOAT D3DXQuaternionLengthSq ( CONST D3DXQUATERNION *pQ ); FLOAT D3DXQuaternionDot ( CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 ); -// (0, 0, 0, 1) +/* (0, 0, 0, 1) */ D3DXQUATERNION* D3DXQuaternionIdentity ( D3DXQUATERNION *pOut ); @@ -1513,11 +1509,12 @@ HRESULT WINAPI D3DXSHProjectCubeMap } #endif - +#if 0 #include "d3dx9math.inl" +#endif #if _MSC_VER >= 1200 #pragma warning(pop) #endif -#endif // __D3DX9MATH_H__ +#endif /* __D3DX9MATH_H__ */ diff --git a/griffin/griffin.c b/griffin/griffin.c index 02a466773b..7f76bc0a12 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -404,6 +404,10 @@ FONTS #include "../gfx/drivers_font_renderer/bitmapfont.c" #include "../gfx/font_driver.c" +#if defined(HAVE_D3D9) && !defined(_XBOX) +#include "../gfx/drivers_font/d3d_w32_font.c" +#endif + #if defined(HAVE_STB_FONT) #include "../gfx/drivers_font_renderer/stb_unicode.c" #include "../gfx/drivers_font_renderer/stb.c" diff --git a/griffin/griffin_cpp.cpp b/griffin/griffin_cpp.cpp index 9e8530344c..8aa44dce0c 100644 --- a/griffin/griffin_cpp.cpp +++ b/griffin/griffin_cpp.cpp @@ -154,11 +154,6 @@ VIDEO DRIVER /*============================================================ FONTS ============================================================ */ - -#if defined(HAVE_D3D9) && !defined(_XBOX) -#include "../gfx/drivers_font/d3d_w32_font.cpp" -#endif - #if defined(_XBOX360) #include "../gfx/drivers_font/xdk360_fonts.cpp" #endif