Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- include/d3dx10math.h | 165 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 165 insertions(+)
diff --git a/include/d3dx10math.h b/include/d3dx10math.h index c8bcfd2ce4e..adc7adab9fd 100644 --- a/include/d3dx10math.h +++ b/include/d3dx10math.h @@ -24,6 +24,35 @@
#include <math.h>
+#ifndef D3DVECTOR_DEFINED +typedef struct _D3DVECTOR +{ + float x; + float y; + float z; +} D3DVECTOR; +#define D3DVECTOR_DEFINED +#endif + +#ifndef D3DMATRIX_DEFINED +typedef struct _D3DMATRIX +{ + union + { + struct + { + float _11, _12, _13, _14; + float _21, _22, _23, _24; + float _31, _32, _33, _34; + float _41, _42, _43, _44; + + }; + float m[4][4]; + }; +} D3DMATRIX; +#define D3DMATRIX_DEFINED +#endif + typedef enum _D3DX_CPU_OPTIMIZATION { D3DX_NOT_OPTIMIZED, @@ -82,6 +111,142 @@ public: float r, g, b, a; } D3DXCOLOR, *LPD3DXCOLOR;
+typedef struct D3DXVECTOR2 +{ +#ifdef __cplusplus + D3DXVECTOR2(); + D3DXVECTOR2(const FLOAT *pf); + D3DXVECTOR2(FLOAT fx, FLOAT fy); + + operator FLOAT* (); + operator const FLOAT* () const; + + D3DXVECTOR2& operator += (const D3DXVECTOR2&); + D3DXVECTOR2& operator -= (const D3DXVECTOR2&); + D3DXVECTOR2& operator *= (FLOAT); + D3DXVECTOR2& operator /= (FLOAT); + + D3DXVECTOR2 operator + () const; + D3DXVECTOR2 operator - () const; + + D3DXVECTOR2 operator + (const D3DXVECTOR2&) const; + D3DXVECTOR2 operator - (const D3DXVECTOR2&) const; + D3DXVECTOR2 operator * (FLOAT) const; + D3DXVECTOR2 operator / (FLOAT) const; + + friend D3DXVECTOR2 operator * (FLOAT, const D3DXVECTOR2&); + + BOOL operator == (const D3DXVECTOR2&) const; + BOOL operator != (const D3DXVECTOR2&) const; +#endif /* __cplusplus */ + FLOAT x, y; +} D3DXVECTOR2, *LPD3DXVECTOR2; + +#ifdef __cplusplus +typedef struct D3DXVECTOR3 : public D3DVECTOR +{ + D3DXVECTOR3(); + D3DXVECTOR3(const FLOAT *pf); + D3DXVECTOR3(const D3DVECTOR& v); + D3DXVECTOR3(FLOAT fx, FLOAT fy, FLOAT fz); + + operator FLOAT* (); + operator const FLOAT* () const; + + D3DXVECTOR3& operator += (const D3DXVECTOR3&); + D3DXVECTOR3& operator -= (const D3DXVECTOR3&); + D3DXVECTOR3& operator *= (FLOAT); + D3DXVECTOR3& operator /= (FLOAT); + + D3DXVECTOR3 operator + () const; + D3DXVECTOR3 operator - () const; + + D3DXVECTOR3 operator + (const D3DXVECTOR3&) const; + D3DXVECTOR3 operator - (const D3DXVECTOR3&) const; + D3DXVECTOR3 operator * (FLOAT) const; + D3DXVECTOR3 operator / (FLOAT) const; + + friend D3DXVECTOR3 operator * (FLOAT, const struct D3DXVECTOR3&); + + BOOL operator == (const D3DXVECTOR3&) const; + BOOL operator != (const D3DXVECTOR3&) const; +} D3DXVECTOR3, *LPD3DXVECTOR3; +#else /* !__cplusplus */ +typedef struct _D3DVECTOR D3DXVECTOR3, *LPD3DXVECTOR3; +#endif /* !__cplusplus */ + +typedef struct D3DXVECTOR4 +{ +#ifdef __cplusplus + D3DXVECTOR4(); + D3DXVECTOR4(const FLOAT *pf); + D3DXVECTOR4(FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw); + + operator FLOAT* (); + operator const FLOAT* () const; + + D3DXVECTOR4& operator += (const D3DXVECTOR4&); + D3DXVECTOR4& operator -= (const D3DXVECTOR4&); + D3DXVECTOR4& operator *= (FLOAT); + D3DXVECTOR4& operator /= (FLOAT); + + D3DXVECTOR4 operator + () const; + D3DXVECTOR4 operator - () const; + + D3DXVECTOR4 operator + (const D3DXVECTOR4&) const; + D3DXVECTOR4 operator - (const D3DXVECTOR4&) const; + D3DXVECTOR4 operator * (FLOAT) const; + D3DXVECTOR4 operator / (FLOAT) const; + + friend D3DXVECTOR4 operator * (FLOAT, const D3DXVECTOR4&); + + BOOL operator == (const D3DXVECTOR4&) const; + BOOL operator != (const D3DXVECTOR4&) const; +#endif /* __cplusplus */ + FLOAT x, y, z, w; +} D3DXVECTOR4, *LPD3DXVECTOR4; + +#ifdef __cplusplus +typedef struct D3DXMATRIX : public D3DMATRIX +{ + D3DXMATRIX(); + D3DXMATRIX(const FLOAT *pf); + D3DXMATRIX(const D3DMATRIX& mat); + D3DXMATRIX(FLOAT f11, FLOAT f12, FLOAT f13, FLOAT f14, + FLOAT f21, FLOAT f22, FLOAT f23, FLOAT f24, + FLOAT f31, FLOAT f32, FLOAT f33, FLOAT f34, + FLOAT f41, FLOAT f42, FLOAT f43, FLOAT f44); + + FLOAT& operator () (UINT row, UINT col); + FLOAT operator () (UINT row, UINT col) const; + + operator FLOAT* (); + operator const FLOAT* () const; + + D3DXMATRIX& operator *= (const D3DXMATRIX&); + D3DXMATRIX& operator += (const D3DXMATRIX&); + D3DXMATRIX& operator -= (const D3DXMATRIX&); + D3DXMATRIX& operator *= (FLOAT); + D3DXMATRIX& operator /= (FLOAT); + + D3DXMATRIX operator + () const; + D3DXMATRIX operator - () const; + + D3DXMATRIX operator * (const D3DXMATRIX&) const; + D3DXMATRIX operator + (const D3DXMATRIX&) const; + D3DXMATRIX operator - (const D3DXMATRIX&) const; + D3DXMATRIX operator * (FLOAT) const; + D3DXMATRIX operator / (FLOAT) const; + + friend D3DXMATRIX operator * (FLOAT, const D3DXMATRIX&); + + BOOL operator == (const D3DXMATRIX&) const; + BOOL operator != (const D3DXMATRIX&) const; +} D3DXMATRIX, *LPD3DXMATRIX; +#else /* !__cplusplus */ +typedef struct _D3DMATRIX D3DXMATRIX, *LPD3DXMATRIX; +#endif /* !__cplusplus */ + #ifdef __cplusplus extern "C" { #endif