David Adam : d3dx8: Implement D3DXVec2Subtract with a test.

Alexandre Julliard julliard at winehq.org
Tue Oct 16 07:59:57 CDT 2007


Module: wine
Branch: master
Commit: 43d13935d8e5cb2b2b774b94a0fcf2da9cf25cac
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=43d13935d8e5cb2b2b774b94a0fcf2da9cf25cac

Author: David Adam <David.Adam at math.cnrs.fr>
Date:   Sun Oct 14 19:22:17 2007 +0200

d3dx8: Implement D3DXVec2Subtract with a test.

---

 dlls/d3dx8/tests/math.c |   10 ++++++++++
 include/d3dx8math.h     |    1 +
 include/d3dx8math.inl   |    8 ++++++++
 3 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
index 01e8edb..85a1cb7 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -87,6 +87,16 @@ static void D3X8Vector2Test(void)
     got = D3DXVec2LengthSq(NULL);
     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
 
+/*_______________D3DXVec2Subtract__________________________*/
+   expectedvec.x = 10.0f; expectedvec.y = -5.0f;
+   D3DXVec2Subtract(&gotvec,&u,&v);
+   expect_vec(expectedvec,gotvec);
+   /* Tests the case NULL */
+    funcpointer = D3DXVec2Subtract(&gotvec,NULL,&v);
+    ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
+    funcpointer = D3DXVec2Subtract(NULL,NULL,NULL);
+    ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
+
 }
 
 START_TEST(math)
diff --git a/include/d3dx8math.h b/include/d3dx8math.h
index 5dfb0fd..e1c25a1 100644
--- a/include/d3dx8math.h
+++ b/include/d3dx8math.h
@@ -63,5 +63,6 @@ FLOAT D3DXVec2CCW(CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2);
 FLOAT D3DXVec2Dot(CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2);
 FLOAT D3DXVec2Length(CONST D3DXVECTOR2 *pv);
 FLOAT D3DXVec2LengthSq(CONST D3DXVECTOR2 *pv);
+D3DXVECTOR2* D3DXVec2Subtract(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2);
 
 #endif /* __D3DX8MATH_H__ */
diff --git a/include/d3dx8math.inl b/include/d3dx8math.inl
index 4579db2..bafee45 100644
--- a/include/d3dx8math.inl
+++ b/include/d3dx8math.inl
@@ -51,4 +51,12 @@ extern inline FLOAT D3DXVec2LengthSq(CONST D3DXVECTOR2 *pv)
     return( (pv->x) * (pv->x) + (pv->y) * (pv->y) );
 }
 
+extern inline D3DXVECTOR2* D3DXVec2Subtract(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2)
+{
+    if ( !pout || !pv1 || !pv2) return NULL;
+    pout->x = pv1->x - pv2->x;
+    pout->y = pv1->y - pv2->y;
+    return pout;
+}
+
 #endif




More information about the wine-cvs mailing list