d3dx8: Implement D3DXVec2Add with a test.
This commit is contained in:
parent
a0ddecf778
commit
adf4580bf1
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue