[PATCH] Implement D3DXColorScale with a test

David Adam David.Adam at math.cnrs.fr
Tue Oct 23 06:06:51 CDT 2007


---
 dlls/d3dx8/tests/math.c |   10 ++++++++++
 include/d3dx8math.inl   |   10 ++++++++++
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
index 6ff0d0c..5d6806e 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -86,6 +86,16 @@ static void D3DXColorTest(void)
     ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
     funcpointer =3D D3DXColorNegative(NULL,NULL);
     ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
+
+/*_______________D3DXColorScale________________*/
+    expected.r =3D 0.06f; expected.g =3D 0.225f; expected.b =3D 0.123f; exp=
ected.a =3D 0.279f;
+    D3DXColorScale(&got,&color,scale);
+    expect_color(expected,got);
+    /* Test the NULL case */
+    funcpointer =3D D3DXColorScale(&got,NULL,scale);
+    ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
+    funcpointer =3D D3DXColorScale(NULL,NULL,scale);
+    ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
 }
=20
 static void D3DXPlaneTest(void)
diff --git a/include/d3dx8math.inl b/include/d3dx8math.inl
index 21e8fc8..50a1144 100644
--- a/include/d3dx8math.inl
+++ b/include/d3dx8math.inl
@@ -51,6 +51,16 @@ static inline D3DXCOLOR* D3DXColorNegative(D3DXCOLOR *pou=
t, CONST D3DXCOLOR *pc)
     return pout;
 }
=20
+static inline D3DXCOLOR* D3DXColorScale(D3DXCOLOR *pout, CONST D3DXCOLOR *p=
c, FLOAT s)
+{
+    if ( !pout || !pc ) return NULL;
+    pout->r =3D s* (pc->r);
+    pout->g =3D s* (pc->g);
+    pout->b =3D s* (pc->b);
+    pout->a =3D s* (pc->a);
+    return pout;
+}
+
 /*_______________D3DXVECTOR2________________________*/
=20
 static inline D3DXVECTOR2* D3DXVec2Add(D3DXVECTOR2 *pout, CONST D3DXVECTOR2=
 *pv1, CONST D3DXVECTOR2 *pv2)
--=20
1.5.3.2


--=_2u6rthh33yw4--



More information about the wine-patches mailing list