[PATCH] Implement D3DXVec2Length with a test

David Adam David.Adam at math.cnrs.fr
Fri Oct 5 13:44:15 CDT 2007


---
 dlls/d3dx8/d3dx8.spec   |    1 +
 dlls/d3dx8/math.c       |    5 +++++
 dlls/d3dx8/tests/math.c |    6 +++++-
 include/d3dx8math.h     |    1 +
 4 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/dlls/d3dx8/d3dx8.spec b/dlls/d3dx8/d3dx8.spec
index 325d0a5..d021def 100644
--- a/dlls/d3dx8/d3dx8.spec
+++ b/dlls/d3dx8/d3dx8.spec
@@ -1,5 +1,6 @@
 @ stub D3DXVec2Normalize
 @ stdcall D3DXVec2LengthSq(ptr)
+@ stdcall D3DXVec2Length(ptr)
 @ stub D3DXVec2Hermite
 @ stub D3DXVec2CatmullRom
 @ stub D3DXVec2BaryCentric
diff --git a/dlls/d3dx8/math.c b/dlls/d3dx8/math.c
index 0b456e3..a23a1b7 100644
--- a/dlls/d3dx8/math.c
+++ b/dlls/d3dx8/math.c
@@ -27,6 +27,11 @@
=20
 #include "wine/debug.h"
=20
+FLOAT D3DXVec2Length(CONST LPD3DXVECTOR2 pv)
+{
+    return sqrt(D3DXVec2LengthSq(pv));
+}
+
 FLOAT D3DXVec2LengthSq(CONST LPD3DXVECTOR2 pv)
 {
     return (pv->x)*(pv->x)+(pv->y)*(pv->y);
diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
index 8e03ae9..fb8a221 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -25,11 +25,15 @@
 static void Vector2Test(void)
 {
     D3DXVECTOR2 u;
-    FLOAT long2;
+    FLOAT modulus,long2;
=20
     u.x=3D3.0f; u.y=3D4.0f;
=20
 /*__________________Vect2LengthSq_______________________*/
+    modulus=3DD3DXVec2Length(&u);
+    ok((modulus =3D=3D 5.0f), "Expected 5.0f, Got %f\n", modulus);
+
+/*__________________Vect2LengthSq_______________________*/
     long2=3DD3DXVec2LengthSq(&u);
     ok((long2 =3D=3D 25.0f), "Expected 25.0f, Got %f\n", long2);
 }
diff --git a/include/d3dx8math.h b/include/d3dx8math.h
index 53f18ec..f2cf867 100644
--- a/include/d3dx8math.h
+++ b/include/d3dx8math.h
@@ -59,6 +59,7 @@ typedef struct D3DXCOLOR
     FLOAT r, g, b, a;
 } D3DXCOLOR, *LPD3DXCOLOR;
=20
+FLOAT D3DXVec2Length(CONST LPD3DXVECTOR2);
 FLOAT D3DXVec2LengthSq(CONST LPD3DXVECTOR2);
=20
 #endif
--=20
1.5.2.4


--=_5r5dm2p5r98g--



More information about the wine-patches mailing list