diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c index 7c74b65902..fbb8ab30be 100644 --- a/dlls/d3dx8/tests/math.c +++ b/dlls/d3dx8/tests/math.c @@ -36,8 +36,23 @@ static void D3DXColorTest(void) { D3DXCOLOR color, color1, expected, got; LPD3DXCOLOR funcpointer; + FLOAT scale; color.r = 0.2f; color.g = 0.75f; color.b = 0.41f; color.a = 0.93f; + scale = 0.3f; + +/*_______________D3DXColorLerp________________*/ + color1.r = 0.6f; color1.g = 0.55f; color1.b = 0.23f; color1.a = 0.82f; + expected.r = 0.32f; expected.g = 0.69f; expected.b = 0.356f; expected.a = 0.897f; + D3DXColorLerp(&got,&color,&color1,scale); + expect_color(expected,got); + /* Test the NULL case */ + funcpointer = D3DXColorLerp(&got,NULL,&color1,scale); + ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer); + funcpointer = D3DXColorLerp(NULL,NULL,&color1,scale); + ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer); + funcpointer = D3DXColorLerp(NULL,NULL,NULL,scale); + ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer); /*_______________D3DXColorNegative________________*/ expected.r = 0.8f; expected.g = 0.25f; expected.b = 0.59f; expected.a = 0.93f; diff --git a/include/d3dx8math.inl b/include/d3dx8math.inl index d4ddb1423b..da11f31c22 100644 --- a/include/d3dx8math.inl +++ b/include/d3dx8math.inl @@ -19,6 +19,18 @@ #ifndef __D3DX8MATH_INL__ #define __D3DX8MATH_INL__ +/*_______________D3DXCOLOR_____________________*/ + +static inline D3DXCOLOR* D3DXColorLerp(D3DXCOLOR *pout, CONST D3DXCOLOR *pc1, CONST D3DXCOLOR *pc2, FLOAT s) +{ + if ( !pout || !pc1 || !pc2 ) return NULL; + pout->r = (1-s) * (pc1->r) + s *(pc2->r); + pout->g = (1-s) * (pc1->g) + s *(pc2->g); + pout->b = (1-s) * (pc1->b) + s *(pc2->b); + pout->a = (1-s) * (pc1->a) + s *(pc2->a); + return pout; +} + static inline D3DXCOLOR* D3DXColorNegative(D3DXCOLOR *pout, CONST D3DXCOLOR *pc) { if ( !pout || !pc ) return NULL;