d3dx8: Implement D3DXVec2Dot with a test.
This commit is contained in:
parent
d404ec8c4b
commit
1fa3abe7cc
|
@ -26,10 +26,23 @@
|
|||
|
||||
static void D3X8Vector2Test(void)
|
||||
{
|
||||
D3DXVECTOR2 u;
|
||||
D3DXVECTOR2 u,v;
|
||||
FLOAT expected, got;
|
||||
|
||||
u.x=3.0f; u.y=4.0f;
|
||||
v.x=-7.0f; v.y=9.0f;
|
||||
|
||||
/*_______________D3DXVec2Dot__________________________*/
|
||||
expected = 15.0f;
|
||||
got = D3DXVec2Dot(&u,&v);
|
||||
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
||||
/* Tests the case NULL */
|
||||
expected=0.0f;
|
||||
got = D3DXVec2Dot(NULL,&v);
|
||||
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
||||
expected=0.0f;
|
||||
got = D3DXVec2Dot(NULL,NULL);
|
||||
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
||||
|
||||
/*_______________D3DXVec2Length__________________________*/
|
||||
expected = 5.0f;
|
||||
|
@ -37,17 +50,16 @@ static void D3X8Vector2Test(void)
|
|||
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
||||
/* Tests the case NULL */
|
||||
expected=0.0f;
|
||||
got= D3DXVec2Length(NULL);
|
||||
got = D3DXVec2Length(NULL);
|
||||
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
||||
|
||||
|
||||
/*_______________D3DXVec2LengthSq________________________*/
|
||||
expected = 25.0f;
|
||||
got = D3DXVec2LengthSq(&u);
|
||||
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
||||
/* Tests the case NULL */
|
||||
expected=0.0f;
|
||||
got= D3DXVec2LengthSq(NULL);
|
||||
got = D3DXVec2LengthSq(NULL);
|
||||
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
||||
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ typedef struct D3DXCOLOR
|
|||
FLOAT r, g, b, a;
|
||||
} D3DXCOLOR, *LPD3DXCOLOR;
|
||||
|
||||
FLOAT D3DXVec2Dot(CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2);
|
||||
FLOAT D3DXVec2Length(CONST D3DXVECTOR2 *pv);
|
||||
FLOAT D3DXVec2LengthSq(CONST D3DXVECTOR2 *pv);
|
||||
|
||||
|
|
|
@ -19,6 +19,12 @@
|
|||
#ifndef __D3DX8MATH_INL__
|
||||
#define __D3DX8MATH_INL__
|
||||
|
||||
extern inline FLOAT D3DXVec2Dot(CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2)
|
||||
{
|
||||
if ( !pv1 || !pv2) return 0.0f;
|
||||
return ( (pv1->x * pv2->x + pv1->y * pv2->y) );
|
||||
}
|
||||
|
||||
extern inline FLOAT D3DXVec2Length(CONST D3DXVECTOR2 *pv)
|
||||
{
|
||||
if (!pv) return 0.0f;
|
||||
|
|
Loading…
Reference in New Issue