[PATCH] Implement D3DXVec2Add with a test
David Adam
DavidAdam at math.cnrs.fr
Sun Oct 14 12:06:20 CDT 2007
---
dlls/d3dx8/tests/math.c | 15 ++++++++++++++-
include/d3dx8math.h | 1 +
include/d3dx8math.inl | 8 ++++++++
3 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
index 6efe02c..1c94c80 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -24,14 +24,27 @@
=20
#define admitted_error 0.00001f
=20
+#define expect_vec(expectedvec,gotvec) ok((fabs(expectedvec.x-gotvec.x)<adm=
itted_error)&&(fabs(expectedvec.y-gotvec.y)<admitted_error),"Expected Vector=
=3D (%f, %f)\n , Got Vector=3D (%f, %f)\n", expectedvec.x, expectedvec.y, go=
tvec.x, gotvec.y);
+
static void D3X8Vector2Test(void)
{
- D3DXVECTOR2 u,v;
+ D3DXVECTOR2 expectedvec, gotvec, u, v;
+ LPD3DXVECTOR2 funcpointer;
FLOAT expected, got;
=20
u.x=3D3.0f; u.y=3D4.0f;
v.x=3D-7.0f; v.y=3D9.0f;
=20
+/*_______________D3DXVec2Add__________________________*/
+ expectedvec.x =3D -4.0f; expectedvec.y =3D 13.0f;
+ D3DXVec2Add(&gotvec,&u,&v);
+ expect_vec(expectedvec,gotvec);
+ /* Tests the case NULL */
+ funcpointer =3D D3DXVec2Add(&gotvec,NULL,&v);
+ ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
+ funcpointer =3D D3DXVec2Add(NULL,NULL,NULL);
+ ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
+
/*_______________D3DXVec2CCW__________________________*/
expected =3D 55.0f;
got =3D D3DXVec2CCW(&u,&v);
diff --git a/include/d3dx8math.h b/include/d3dx8math.h
index e088760..5dfb0fd 100644
--- a/include/d3dx8math.h
+++ b/include/d3dx8math.h
@@ -58,6 +58,7 @@ typedef struct D3DXCOLOR
FLOAT r, g, b, a;
} D3DXCOLOR, *LPD3DXCOLOR;
=20
+D3DXVECTOR2* D3DXVec2Add(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D=
3DXVECTOR2 *pv2);
FLOAT D3DXVec2CCW(CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2);
FLOAT D3DXVec2Dot(CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2);
FLOAT D3DXVec2Length(CONST D3DXVECTOR2 *pv);
diff --git a/include/d3dx8math.inl b/include/d3dx8math.inl
index 8112488..4579db2 100644
--- a/include/d3dx8math.inl
+++ b/include/d3dx8math.inl
@@ -19,6 +19,14 @@
#ifndef __D3DX8MATH_INL__
#define __D3DX8MATH_INL__
=20
+extern inline D3DXVECTOR2* D3DXVec2Add(D3DXVECTOR2 *pout, CONST D3DXVECTOR2=
*pv1, CONST D3DXVECTOR2 *pv2)
+{
+ if ( !pout || !pv1 || !pv2) return NULL;
+ pout->x =3D pv1->x + pv2->x;
+ pout->y =3D pv1->y + pv2->y;
+ return pout;
+}
+
extern inline FLOAT D3DXVec2CCW(CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *=
pv2)
{
if ( !pv1 || !pv2) return 0.0f;
--=20
1.5.3.2
--=_502i7feozl44--
More information about the wine-patches
mailing list