David Adam : d3dx8: Implement D3DXPlaneColorNegative.
Alexandre Julliard
julliard at winehq.org
Wed Oct 24 11:04:50 CDT 2007
Module: wine
Branch: master
Commit: 6ebc5cefdf6bfb625d20b57ddc67827f9288ceeb
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6ebc5cefdf6bfb625d20b57ddc67827f9288ceeb
Author: David Adam <David.Adam at math.cnrs.fr>
Date: Tue Oct 23 11:30:55 2007 +0200
d3dx8: Implement D3DXPlaneColorNegative.
---
dlls/d3dx8/tests/math.c | 31 +++++++++++++++++++++++++++++++
include/d3dx8math.inl | 10 ++++++++++
2 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
index e73a619..7c74b65 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -24,12 +24,42 @@
#define admitted_error 0.00001f
+#define expect_color(expectedcolor,gotcolor) ok((fabs(expectedcolor.r-gotcolor.r)<admitted_error)&&(fabs(expectedcolor.g-gotcolor.g)<admitted_error)&&(fabs(expectedcolor.b-gotcolor.b)<admitted_error)&&(fabs(expectedcolor.a-gotcolor.a)<admitted_error),"Expected Color= (%f, %f, %f, %f)\n , Got Color= (%f, %f, %f, %f)\n", expectedcolor.r, expectedcolor.g, expectedcolor.b, expectedcolor.a, gotcolor.r, gotcolor.g, gotcolor.b, gotcolor.a);
+
#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);
#define expect_vec3(expectedvec,gotvec) ok((fabs(expectedvec.x-gotvec.x)<admitted_error)&&(fabs(expectedvec.y-gotvec.y)<admitted_error)&&(fabs(expectedvec.z-gotvec.z)<admitted_error),"Expected Vector= (%f, %f,%f)\n , Got Vector= (%f, %f, %f)\n", expectedvec.x, expectedvec.y, expectedvec.z, gotvec.x, gotvec.y, gotvec.z);
#define expect_vec4(expectedvec,gotvec) ok((fabs(expectedvec.x-gotvec.x)<admitted_error)&&(fabs(expectedvec.y-gotvec.y)<admitted_error)&&(fabs(expectedvec.z-gotvec.z)<admitted_error)&&(fabs(expectedvec.w-gotvec.w)<admitted_error),"Expected Vector= (%f, %f, %f, %f)\n , Got Vector= (%f, %f, %f, %f)\n", expectedvec.x, expectedvec.y, expectedvec.z, expectedvec.w, gotvec.x, gotvec.y, gotvec.z, gotvec.w);
+static void D3DXColorTest(void)
+{
+ D3DXCOLOR color, color1, expected, got;
+ LPD3DXCOLOR funcpointer;
+
+ color.r = 0.2f; color.g = 0.75f; color.b = 0.41f; color.a = 0.93f;
+
+/*_______________D3DXColorNegative________________*/
+ expected.r = 0.8f; expected.g = 0.25f; expected.b = 0.59f; expected.a = 0.93f;
+ D3DXColorNegative(&got,&color);
+ expect_color(got,expected);
+ /* Test the greater than 1 case */
+ color1.r = 0.2f; color1.g = 1.75f; color1.b = 0.41f; color1.a = 0.93f;
+ expected.r = 0.8f; expected.g = -0.75f; expected.b = 0.59f; expected.a = 0.93f;
+ D3DXColorNegative(&got,&color1);
+ expect_color(got,expected);
+ /* Test the negative case */
+ color1.r = 0.2f; color1.g = -0.75f; color1.b = 0.41f; color1.a = 0.93f;
+ expected.r = 0.8f; expected.g = 1.75f; expected.b = 0.59f; expected.a = 0.93f;
+ D3DXColorNegative(&got,&color1);
+ expect_color(got,expected);
+ /* Test the NULL case */
+ funcpointer = D3DXColorNegative(&got,NULL);
+ ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
+ funcpointer = D3DXColorNegative(NULL,NULL);
+ ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
+}
+
static void D3DXPlaneTest(void)
{
D3DXPLANE plane;
@@ -473,6 +503,7 @@ static void D3X8Vector4Test(void)
START_TEST(math)
{
+ D3DXColorTest();
D3DXPlaneTest();
D3X8QuaternionTest();
D3X8Vector2Test();
diff --git a/include/d3dx8math.inl b/include/d3dx8math.inl
index 71f9641..d4ddb14 100644
--- a/include/d3dx8math.inl
+++ b/include/d3dx8math.inl
@@ -19,6 +19,16 @@
#ifndef __D3DX8MATH_INL__
#define __D3DX8MATH_INL__
+static inline D3DXCOLOR* D3DXColorNegative(D3DXCOLOR *pout, CONST D3DXCOLOR *pc)
+{
+ if ( !pout || !pc ) return NULL;
+ pout->r = 1.0f - pc->r;
+ pout->g = 1.0f - pc->g;
+ pout->b = 1.0f - pc->b;
+ pout->a = pc->a;
+ return pout;
+}
+
/*_______________D3DXVECTOR2________________________*/
static inline D3DXVECTOR2* D3DXVec2Add(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2)
More information about the wine-cvs
mailing list