David Adam : d3dx8: Implement D3DXVec2Add with a test.
Alexandre Julliard
julliard at winehq.org
Tue Oct 16 07:59:57 CDT 2007
Module: wine
Branch: master
Commit: adf4580bf17764089614da4497ec31507dbcb442
URL: http://source.winehq.org/git/wine.git/?a=commit;h=adf4580bf17764089614da4497ec31507dbcb442
Author: David Adam <David.Adam at math.cnrs.fr>
Date: Sun Oct 14 19:06:20 2007 +0200
d3dx8: Implement D3DXVec2Add with a test.
---
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 d47d8a4..01e8edb 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -24,14 +24,27 @@
#define admitted_error 0.00001f
+#define expect_vec(expectedvec,gotvec) ok((fabs(expectedvec.x-gotvec.x)<admitted_error)&&(fabs(expectedvec.y-gotvec.y)<admitted_error),"Expected Vector= (%f, %f)\n , Got Vector= (%f, %f)\n", expectedvec.x, expectedvec.y, gotvec.x, gotvec.y);
+
static void D3X8Vector2Test(void)
{
- D3DXVECTOR2 u,v;
+ D3DXVECTOR2 expectedvec, gotvec, u, v;
+ LPD3DXVECTOR2 funcpointer;
FLOAT expected, got;
u.x=3.0f; u.y=4.0f;
v.x=-7.0f; v.y=9.0f;
+/*_______________D3DXVec2Add__________________________*/
+ expectedvec.x = -4.0f; expectedvec.y = 13.0f;
+ D3DXVec2Add(&gotvec,&u,&v);
+ expect_vec(expectedvec,gotvec);
+ /* Tests the case NULL */
+ funcpointer = D3DXVec2Add(&gotvec,NULL,&v);
+ ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
+ funcpointer = D3DXVec2Add(NULL,NULL,NULL);
+ ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
+
/*_______________D3DXVec2CCW__________________________*/
expected = 55.0f;
got = 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;
+D3DXVECTOR2* D3DXVec2Add(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *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__
+extern inline D3DXVECTOR2* D3DXVec2Add(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2)
+{
+ if ( !pout || !pv1 || !pv2) return NULL;
+ pout->x = pv1->x + pv2->x;
+ pout->y = pv1->y + pv2->y;
+ return pout;
+}
+
extern inline FLOAT D3DXVec2CCW(CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2)
{
if ( !pv1 || !pv2) return 0.0f;
More information about the wine-cvs
mailing list