Tony Wasserka : d3dx8: Implement the C++ stuff of the D3DXVECTOR2 structure .
Alexandre Julliard
julliard at winehq.org
Mon Nov 12 06:27:33 CST 2007
Module: wine
Branch: master
Commit: 74750c3c6449c00ab6eafad189d234b1986c24be
URL: http://source.winehq.org/git/wine.git/?a=commit;h=74750c3c6449c00ab6eafad189d234b1986c24be
Author: Tony Wasserka <tony.wasserka at freenet.de>
Date: Fri Nov 9 18:04:40 2007 +0100
d3dx8: Implement the C++ stuff of the D3DXVECTOR2 structure.
---
include/d3dx8math.h | 26 ++++++++++++
include/d3dx8math.inl | 105 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 131 insertions(+), 0 deletions(-)
diff --git a/include/d3dx8math.h b/include/d3dx8math.h
index bd1dc4f..385599f 100644
--- a/include/d3dx8math.h
+++ b/include/d3dx8math.h
@@ -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;
diff --git a/include/d3dx8math.inl b/include/d3dx8math.inl
index cdcea06..8c21f68 100644
--- a/include/d3dx8math.inl
+++ b/include/d3dx8math.inl
@@ -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;
More information about the wine-cvs
mailing list