David Adam : d3dx8: Implement D3DXVecScale with a test.
Alexandre Julliard
julliard at winehq.org
Tue Oct 16 07:59:58 CDT 2007
Module: wine
Branch: master
Commit: 18123a93644a9025b16edb01d35d2a36b2323ad4
URL: http://source.winehq.org/git/wine.git/?a=commit;h=18123a93644a9025b16edb01d35d2a36b2323ad4
Author: David Adam <David.Adam at math.cnrs.fr>
Date: Sun Oct 14 20:20:01 2007 +0200
d3dx8: Implement D3DXVecScale with a test.
---
dlls/d3dx8/tests/math.c | 15 ++++++++++++---
include/d3dx8math.h | 1 +
include/d3dx8math.inl | 7 +++++++
3 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
index aefb55c..95452b3 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -30,10 +30,11 @@ static void D3X8Vector2Test(void)
{
D3DXVECTOR2 expectedvec, gotvec, u, v;
LPD3DXVECTOR2 funcpointer;
- FLOAT expected, got;
+ FLOAT expected, got, scale;
u.x=3.0f; u.y=4.0f;
v.x=-7.0f; v.y=9.0f;
+ scale = -6.5f;
/*_______________D3DXVec2Add__________________________*/
expectedvec.x = -4.0f; expectedvec.y = 13.0f;
@@ -89,7 +90,6 @@ static void D3X8Vector2Test(void)
/*_______________D3DXVec2Maximize__________________________*/
expectedvec.x = 3.0f; expectedvec.y = 9.0f;
- /*gotvec.x=0.0f; gotvec.y=0.0f;*/
D3DXVec2Maximize(&gotvec,&u,&v);
expect_vec(expectedvec,gotvec);
/* Tests the case NULL */
@@ -100,7 +100,6 @@ static void D3X8Vector2Test(void)
/*_______________D3DXVec2Minimize__________________________*/
expectedvec.x = -7.0f; expectedvec.y = 4.0f;
- /*vecgot.x=0.0f; vecgot.y=0.0f;*/
D3DXVec2Minimize(&gotvec,&u,&v);
expect_vec(expectedvec,gotvec);
/* Tests the case NULL */
@@ -109,6 +108,16 @@ static void D3X8Vector2Test(void)
funcpointer = D3DXVec2Minimize(NULL,NULL,NULL);
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
+/*_______________D3DXVec2Scale____________________________*/
+ expectedvec.x = -19.5f; expectedvec.y = -26.0f;
+ D3DXVec2Scale(&gotvec,&u,scale);
+ expect_vec(expectedvec,gotvec);
+ /* Tests the case NULL */
+ funcpointer = D3DXVec2Scale(&gotvec,NULL,scale);
+ ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
+ funcpointer = D3DXVec2Scale(NULL,NULL,scale);
+ ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
+
/*_______________D3DXVec2Subtract__________________________*/
expectedvec.x = 10.0f; expectedvec.y = -5.0f;
D3DXVec2Subtract(&gotvec,&u,&v);
diff --git a/include/d3dx8math.h b/include/d3dx8math.h
index 04528e9..d39563c 100644
--- a/include/d3dx8math.h
+++ b/include/d3dx8math.h
@@ -65,6 +65,7 @@ FLOAT D3DXVec2Length(CONST D3DXVECTOR2 *pv);
FLOAT D3DXVec2LengthSq(CONST D3DXVECTOR2 *pv);
D3DXVECTOR2* D3DXVec2Maximize(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2);
D3DXVECTOR2* D3DXVec2Minimize(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2);
+D3DXVECTOR2* D3DXVec2Scale(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv, FLOAT s);
D3DXVECTOR2* D3DXVec2Subtract(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2);
#endif /* __D3DX8MATH_H__ */
diff --git a/include/d3dx8math.inl b/include/d3dx8math.inl
index 4852f5f..81543c1 100644
--- a/include/d3dx8math.inl
+++ b/include/d3dx8math.inl
@@ -66,6 +66,13 @@ extern inline D3DXVECTOR2* D3DXVec2Minimize(D3DXVECTOR2 *pout, CONST D3DXVECTOR2
pout->y = min(pv1->y , pv2->y);
return pout;
}
+extern inline D3DXVECTOR2* D3DXVec2Scale(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv, FLOAT s)
+{
+ if ( !pout || !pv) return NULL;
+ pout->x = s * (pv->x);
+ pout->y = s * (pv->y);
+ return pout;
+}
extern inline D3DXVECTOR2* D3DXVec2Subtract(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2)
{
More information about the wine-cvs
mailing list