[PATCH] Implement D3DXVec2Add with a test

David Adam David.Adam at math.cnrs.fr
Fri Oct 5 15:06:41 CDT 2007


---
 dlls/d3dx8/d3dx8.spec   |    1 +
 dlls/d3dx8/math.c       |    7 +++++++
 dlls/d3dx8/tests/math.c |   14 ++++++++++++--
 include/d3dx8math.h     |    1 +
 4 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/dlls/d3dx8/d3dx8.spec b/dlls/d3dx8/d3dx8.spec
index d021def..ddc00ca 100644
--- a/dlls/d3dx8/d3dx8.spec
+++ b/dlls/d3dx8/d3dx8.spec
@@ -7,6 +7,7 @@
 @ stub D3DXVec2Transform
 @ stub D3DXVec2TransformCoord
 @ stub D3DXVec2TransformNormal
+@ stdcall D3DXVec2Add(ptr ptr ptr)
 @ stub D3DXVec3Normalize
 @ stub D3DXVec3Hermite
 @ stub D3DXVec3CatmullRom
diff --git a/dlls/d3dx8/math.c b/dlls/d3dx8/math.c
index a23a1b7..b6dc2e0 100644
--- a/dlls/d3dx8/math.c
+++ b/dlls/d3dx8/math.c
@@ -27,6 +27,13 @@
=20
 #include "wine/debug.h"
=20
+LPD3DXVECTOR2 D3DXVec2Add(LPD3DXVECTOR2 pOut, CONST LPD3DXVECTOR2 pv1, CONS=
T LPD3DXVECTOR2 pv2)
+{
+    pOut->x=3D pv1->x + pv2->x;
+    pOut->y=3D pv1->y + pv2->y;
+    return pOut;
+}
+
 FLOAT D3DXVec2Length(CONST LPD3DXVECTOR2 pv)
 {
     return sqrt(D3DXVec2LengthSq(pv));
diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
index fb8a221..7441915 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -22,12 +22,21 @@
 #include "d3dx8math.h"
 #define admitted_error 0.000001f
=20
+#define expect_vec2(expectedvec,gotvec) ok((fabs(expectedvec.x-gotvec.x)<ad=
mitted_error)&&(fabs(expectedvec.y-gotvec.y)<admitted_error), "Expected Vect=
or=3D (%f, %f)\n , Got Vector=3D (%f, %f)\n",expectedvec.x,expectedvec.y, go=
tvec.x, gotvec.y);
+
 static void Vector2Test(void)
 {
-    D3DXVECTOR2 u;
-    FLOAT modulus,long2;
+    D3DXVECTOR2 expected, result, u, vec1, vec2;
+    FLOAT modulus, long2;
=20
     u.x=3D3.0f; u.y=3D4.0f;
+    vec1.x=3D8.0f; vec1.y=3D-2.0f;
+    vec2.x=3D-4.0f; vec2.y=3D7.0f;
+
+/*__________________Vect2Add____________________________*/
+    D3DXVec2Add(&result,&vec1,&vec2);
+    expected.x=3D4.0f; expected.y=3D5.0f;
+    expect_vec2(result,expected);
=20
 /*__________________Vect2LengthSq_______________________*/
     modulus=3DD3DXVec2Length(&u);
@@ -36,6 +45,7 @@ static void Vector2Test(void)
 /*__________________Vect2LengthSq_______________________*/
     long2=3DD3DXVec2LengthSq(&u);
     ok((long2 =3D=3D 25.0f), "Expected 25.0f, Got %f\n", long2);
+
 }
=20
 START_TEST(math)
diff --git a/include/d3dx8math.h b/include/d3dx8math.h
index f2cf867..e108e73 100644
--- a/include/d3dx8math.h
+++ b/include/d3dx8math.h
@@ -59,6 +59,7 @@ typedef struct D3DXCOLOR
     FLOAT r, g, b, a;
 } D3DXCOLOR, *LPD3DXCOLOR;
=20
+LPD3DXVECTOR2 D3DXVec2Add(LPD3DXVECTOR2, CONST LPD3DXVECTOR2, CONST LPD3DXV=
ECTOR2);
 FLOAT D3DXVec2Length(CONST LPD3DXVECTOR2);
 FLOAT D3DXVec2LengthSq(CONST LPD3DXVECTOR2);
=20
--=20
1.5.2.4


--=_1af1vt17i480--



More information about the wine-patches mailing list