ddraw/tests: Fix compilation with Visual C++ 2005.

Francois Gouget fgouget at free.fr
Sun May 27 09:08:39 CDT 2007


---

Visual C++ does not like the divisions by zero. Fortunately Stefan's 
suggestion of tricking it by using intermediate variables worked.


 dlls/ddraw/tests/d3d.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/dlls/ddraw/tests/d3d.c b/dlls/ddraw/tests/d3d.c
index bb52816..5de0e2f 100644
--- a/dlls/ddraw/tests/d3d.c
+++ b/dlls/ddraw/tests/d3d.c
@@ -142,6 +142,8 @@ static void LightTest(void)
     D3DLIGHT7 light;
     D3DLIGHT7 defaultlight;
     BOOL bEnabled = FALSE;
+    float one = 1.0f;
+    float zero= 0.0f;
 
     /* Set a few lights with funky indices. */
     memset(&light, 0, sizeof(light));
@@ -256,7 +258,7 @@ static void LightTest(void)
     U3(light.dcvDiffuse).b = 1.f;
     U3(light.dvDirection).z = 1.f;
 
-    light.dvAttenuation0 = -1.0 / 0.0; /* -INFINITY */
+    light.dvAttenuation0 = -one / zero; /* -INFINITY */
     rc = IDirect3DDevice7_SetLight(lpD3DDevice, 103, &light);
     ok(rc==DDERR_INVALIDPARAMS, "SetLight returned: %x\n", rc);
 
@@ -272,11 +274,11 @@ static void LightTest(void)
     rc = IDirect3DDevice7_SetLight(lpD3DDevice, 103, &light);
     ok(rc==D3D_OK, "SetLight returned: %x\n", rc);
 
-    light.dvAttenuation0 = 1.0 / 0.0; /* +INFINITY */
+    light.dvAttenuation0 = one / zero; /* +INFINITY */
     rc = IDirect3DDevice7_SetLight(lpD3DDevice, 103, &light);
     ok(rc==D3D_OK, "SetLight returned: %x\n", rc);
 
-    light.dvAttenuation0 = 0.0 / 0.0; /* NaN */
+    light.dvAttenuation0 = zero / zero; /* NaN */
     rc = IDirect3DDevice7_SetLight(lpD3DDevice, 103, &light);
     ok(rc==D3D_OK, "SetLight returned: %x\n", rc);
 
-- 
1.4.4.4




More information about the wine-patches mailing list