d3dx8: Implement the C++ stuff of the D3DXVECTOR2 structure.

This commit is contained in:
Tony Wasserka 2007-11-09 18:04:40 +01:00 committed by Alexandre Julliard
parent 1efd4c02e5
commit 74750c3c64
2 changed files with 131 additions and 0 deletions

View File

@ -31,6 +31,32 @@
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;

View File

@ -21,6 +21,111 @@
/*_______________D3DXCOLOR_____________________*/
/* constructors & operators */
#ifdef __cplusplus
inline D3DXVECTOR2::D3DXVECTOR2()
{
}
inline D3DXVECTOR2::D3DXVECTOR2(CONST FLOAT *pf)
{
if(!pf) return;
x = pf[0];
y = pf[1];
}
inline D3DXVECTOR2::D3DXVECTOR2(FLOAT fx, FLOAT fy)
{
x = fx;
y = fy;
}
inline D3DXVECTOR2::operator FLOAT* ()
{
return (FLOAT*)&x;
}
inline D3DXVECTOR2::operator CONST FLOAT* () const
{
return (CONST FLOAT*)&x;
}
inline D3DXVECTOR2& D3DXVECTOR2::operator += (CONST D3DXVECTOR2& v)
{
x += v.x;
y += v.y;
return *this;
}
inline D3DXVECTOR2& D3DXVECTOR2::operator -= (CONST D3DXVECTOR2& v)
{
x -= v.x;
y -= v.y;
return *this;
}
inline D3DXVECTOR2& D3DXVECTOR2::operator *= (FLOAT f)
{
x *= f;
y *= f;
return *this;
}
inline D3DXVECTOR2& D3DXVECTOR2::operator /= (FLOAT f)
{
x /= f;
y /= f;
return *this;
}
inline D3DXVECTOR2 D3DXVECTOR2::operator + () const
{
return *this;
}
inline D3DXVECTOR2 D3DXVECTOR2::operator - () const
{
return D3DXVECTOR2(-x, -y);
}
inline D3DXVECTOR2 D3DXVECTOR2::operator + (CONST D3DXVECTOR2& v) const
{
return D3DXVECTOR2(x + v.x, y + v.y);
}
inline D3DXVECTOR2 D3DXVECTOR2::operator - (CONST D3DXVECTOR2& v) const
{
return D3DXVECTOR2(x - v.x, y - v.y);
}
inline D3DXVECTOR2 D3DXVECTOR2::operator * (FLOAT f) const
{
return D3DXVECTOR2(x * f, y * f);
}
inline D3DXVECTOR2 D3DXVECTOR2::operator / (FLOAT f) const
{
return D3DXVECTOR2(x / f, y / f);
}
inline D3DXVECTOR2 operator * (FLOAT f, CONST D3DXVECTOR2& v)
{
return D3DXVECTOR2(f * v.x, f * v.y);
}
inline BOOL D3DXVECTOR2::operator == (CONST D3DXVECTOR2& v) const
{
return x == v.x && y == v.y;
}
inline BOOL D3DXVECTOR2::operator != (CONST D3DXVECTOR2& v) const
{
return x != v.x || y != v.y;
}
#endif /* __cplusplus */
static inline D3DXCOLOR* D3DXColorAdd(D3DXCOLOR *pout, CONST D3DXCOLOR *pc1, CONST D3DXCOLOR *pc2)
{
if ( !pout || !pc1 || !pc2 ) return NULL;