[PATCH] Implement D3DXVec2Subtract with a test
David Adam
DavidAdam at math.cnrs.fr
Sun Oct 14 12:22:17 CDT 2007
---
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 1c94c80..18f9970 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -87,6 +87,16 @@ static void D3X8Vector2Test(void)
got =3D D3DXVec2LengthSq(NULL);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", =
expected, got);
=20
+/*_______________D3DXVec2Subtract__________________________*/
+ expectedvec.x =3D 10.0f; expectedvec.y =3D -5.0f;
+ D3DXVec2Subtract(&gotvec,&u,&v);
+ expect_vec(expectedvec,gotvec);
+ /* Tests the case NULL */
+ funcpointer =3D D3DXVec2Subtract(&gotvec,NULL,&v);
+ ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
+ funcpointer =3D D3DXVec2Subtract(NULL,NULL,NULL);
+ ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
+
}
=20
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 D3DXVECTOR=
2 *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, CO=
NST D3DXVECTOR2 *pv2);
=20
#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 *p=
v)
return( (pv->x) * (pv->x) + (pv->y) * (pv->y) );
}
=20
+extern inline D3DXVECTOR2* D3DXVec2Subtract(D3DXVECTOR2 *pout, CONST D3DXVE=
CTOR2 *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;
+}
+
#endif
--=20
1.5.3.2
--=_52ygcm97bqg4--
More information about the wine-patches
mailing list