Commit 4ef92a23 authored by David Adam's avatar David Adam Committed by Alexandre Julliard

d3dx8: Implement D3DX*Subtract.

parent e205a210
......@@ -231,6 +231,17 @@ static void D3X8Vector3Test(void)
expected=0.0f;
got = D3DXVec3LengthSq(NULL);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
/*_______________D3DXVec3Subtract_______________________*/
expectedvec.x = 7.0f; expectedvec.y = 9.0f; expectedvec.z = 6.0f;
D3DXVec3Subtract(&gotvec,&u,&v);
expect_vec3(expectedvec,gotvec);
/* Tests the case NULL */
funcpointer = D3DXVec3Subtract(&gotvec,NULL,&v);
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
funcpointer = D3DXVec3Subtract(NULL,NULL,NULL);
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
}
static void D3X8Vector4Test(void)
......@@ -243,7 +254,7 @@ static void D3X8Vector4Test(void)
v.x = -3.0f; v.y = 4.0f; v.z = -5.0f; v.w = 7.0;
/*_______________D3DXVec3Add__________________________*/
expectedvec.x = -2.0f; expectedvec.y = 6.0f; expectedvec.z = -1.0f; expectedvec.w = 17.0;
expectedvec.x = -2.0f; expectedvec.y = 6.0f; expectedvec.z = -1.0f; expectedvec.w = 17.0f;
D3DXVec4Add(&gotvec,&u,&v);
expect_vec4(expectedvec,gotvec);
/* Tests the case NULL */
......@@ -281,6 +292,16 @@ static void D3X8Vector4Test(void)
expected=0.0f;
got = D3DXVec4LengthSq(NULL);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
/*_______________D3DXVec3Add__________________________*/
expectedvec.x = 4.0f; expectedvec.y = -2.0f; expectedvec.z = 9.0f; expectedvec.w = 3.0f;
D3DXVec4Subtract(&gotvec,&u,&v);
expect_vec4(expectedvec,gotvec);
/* Tests the case NULL */
funcpointer = D3DXVec4Subtract(&gotvec,NULL,&v);
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
funcpointer = D3DXVec4Subtract(NULL,NULL,NULL);
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
}
START_TEST(math)
......
......@@ -122,6 +122,14 @@ static inline FLOAT D3DXVec3LengthSq(CONST D3DXVECTOR3 *pv)
return (pv->x) * (pv->x) + (pv->y) * (pv->y) + (pv->z) * (pv->z);
}
static inline D3DXVECTOR3* D3DXVec3Subtract(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pv2)
{
if ( !pout || !pv1 || !pv2) return NULL;
pout->x = pv1->x - pv2->x;
pout->y = pv1->y - pv2->y;
pout->z = pv1->z - pv2->z;
return pout;
}
/*__________________D3DXVECTOR4_______________________*/
static inline D3DXVECTOR4* D3DXVec4Add(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pv2)
......@@ -152,6 +160,15 @@ static inline FLOAT D3DXVec4LengthSq(CONST D3DXVECTOR4 *pv)
return (pv->x) * (pv->x) + (pv->y) * (pv->y) + (pv->z) * (pv->z) + (pv->w) * (pv->w);
}
static inline D3DXVECTOR4* D3DXVec4Subtract(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pv2)
{
if ( !pout || !pv1 || !pv2) return NULL;
pout->x = pv1->x - pv2->x;
pout->y = pv1->y - pv2->y;
pout->z = pv1->z - pv2->z;
pout->w = pv1->w - pv2->w;
return pout;
}
/*__________________D3DXQUATERNION____________________*/
static inline FLOAT D3DXQuaternionDot(CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment