David Adam : d3dx8: Implement D3DXVec2Dot with a test.

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


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

Author: David Adam <David.Adam at math.cnrs.fr>
Date:   Sun Oct 14 18:24:33 2007 +0200

d3dx8: Implement D3DXVec2Dot with a test.

---

 dlls/d3dx8/tests/math.c |   20 ++++++++++++++++----
 include/d3dx8math.h     |    1 +
 include/d3dx8math.inl   |    6 ++++++
 3 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
index a8d80a3..ea51bf5 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -26,10 +26,23 @@
 
 static void D3X8Vector2Test(void)
 {
-    D3DXVECTOR2 u;
+    D3DXVECTOR2 u,v;
     FLOAT expected, got;
 
     u.x=3.0f; u.y=4.0f;
+    v.x=-7.0f; v.y=9.0f;
+
+/*_______________D3DXVec2Dot__________________________*/
+   expected = 15.0f;
+   got = D3DXVec2Dot(&u,&v);
+   ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
+   /* Tests the case NULL */
+    expected=0.0f;
+    got = D3DXVec2Dot(NULL,&v);
+    ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
+    expected=0.0f;
+    got = D3DXVec2Dot(NULL,NULL);
+    ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
 
 /*_______________D3DXVec2Length__________________________*/
    expected = 5.0f;
@@ -37,17 +50,16 @@ static void D3X8Vector2Test(void)
    ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
    /* Tests the case NULL */
     expected=0.0f;
-    got= D3DXVec2Length(NULL);
+    got = D3DXVec2Length(NULL);
     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
 
-
 /*_______________D3DXVec2LengthSq________________________*/
    expected = 25.0f;
    got = D3DXVec2LengthSq(&u);
    ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
    /* Tests the case NULL */
     expected=0.0f;
-    got= D3DXVec2LengthSq(NULL);
+    got = D3DXVec2LengthSq(NULL);
     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
 
 }
diff --git a/include/d3dx8math.h b/include/d3dx8math.h
index 2a98e00..db75b72 100644
--- a/include/d3dx8math.h
+++ b/include/d3dx8math.h
@@ -58,6 +58,7 @@ typedef struct D3DXCOLOR
     FLOAT r, g, b, a;
 } D3DXCOLOR, *LPD3DXCOLOR;
 
+FLOAT D3DXVec2Dot(CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2);
 FLOAT D3DXVec2Length(CONST D3DXVECTOR2 *pv);
 FLOAT D3DXVec2LengthSq(CONST D3DXVECTOR2 *pv);
 
diff --git a/include/d3dx8math.inl b/include/d3dx8math.inl
index e5ced8d..5c29484 100644
--- a/include/d3dx8math.inl
+++ b/include/d3dx8math.inl
@@ -19,6 +19,12 @@
 #ifndef __D3DX8MATH_INL__
 #define __D3DX8MATH_INL__
 
+extern inline FLOAT D3DXVec2Dot(CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2)
+{
+    if ( !pv1 || !pv2) return 0.0f;
+    return ( (pv1->x * pv2->x + pv1->y * pv2->y) );
+}
+
 extern inline FLOAT D3DXVec2Length(CONST D3DXVECTOR2 *pv)
 {
     if (!pv) return 0.0f;




More information about the wine-cvs mailing list