[1/4] wined3d: Where possible, avoid using D3DCOLORTOGLFLOAT4

H. Verbeet hverbeet at gmail.com
Wed Dec 27 20:12:43 CST 2006


Most of the places that use D3DCOLORTOGLFLOAT4 can handle GLint's just as well.

Changelog:
  - Where possible, avoid using D3DCOLORTOGLFLOAT4
-------------- next part --------------
---

 dlls/wined3d/basetexture.c     |    6 +++---
 dlls/wined3d/device.c          |    6 +++---
 dlls/wined3d/state.c           |   22 +++++++++++-----------
 dlls/wined3d/wined3d_private.h |    6 ++++++
 4 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/dlls/wined3d/basetexture.c b/dlls/wined3d/basetexture.c
index 9b9b5d7..4b6b0d5 100644
--- a/dlls/wined3d/basetexture.c
+++ b/dlls/wined3d/basetexture.c
@@ -363,11 +363,11 @@ void WINAPI IWineD3DBaseTextureImpl_Appl
             break;
             case WINED3DSAMP_BORDERCOLOR:
             {
-                float col[4];
+                GLint col[4];
                 *state = samplerStates[textureObjectSamplerStates[i].state];
-                D3DCOLORTOGLFLOAT4(*state, col);
+                D3DCOLORTOGLINT4(*state, col);
                 TRACE("Setting border color for %u to %x\n", textureDimensions, *state);
-                glTexParameterfv(textureDimensions, GL_TEXTURE_BORDER_COLOR, &col[0]);
+                glTexParameteriv(textureDimensions, GL_TEXTURE_BORDER_COLOR, &col[0]);
                 checkGLcall("glTexParameteri(..., GL_TEXTURE_BORDER_COLOR, ...)");
             }
             break;
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index a858ba1..14d6d9e 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -438,7 +438,7 @@ static void delete_glsl_shader_list(IWin
 /* Apply the current values to the specified texture stage */
 static void WINAPI IWineD3DDeviceImpl_SetupTextureStates(IWineD3DDevice *iface, DWORD Sampler, DWORD texture_idx, DWORD Flags) {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
-    float col[4];
+    GLint col[4];
 
     union {
         float f;
@@ -503,8 +503,8 @@ #undef APPLY_STATE
         checkGLcall("glTexEnvi GL_TEXTURE_LOD_BIAS_EXT ...");
     }
 
-    D3DCOLORTOGLFLOAT4(This->stateBlock->renderState[WINED3DRS_TEXTUREFACTOR], col);
-    glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &col[0]);
+    D3DCOLORTOGLINT4(This->stateBlock->renderState[WINED3DRS_TEXTUREFACTOR], col);
+    glTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &col[0]);
     checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);");
 
     /* TODO: NV_POINT_SPRITE */
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 27fd9f4..a842a6f 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -197,11 +197,11 @@ static void state_zfunc(DWORD state, IWi
 }
 
 static void state_ambient(DWORD state, IWineD3DStateBlockImpl *stateblock) {
-    float col[4];
-    D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_AMBIENT], col);
+    GLint col[4];
+    D3DCOLORTOGLINT4(stateblock->renderState[WINED3DRS_AMBIENT], col);
 
-    TRACE("Setting ambient to (%f,%f,%f,%f)\n", col[0], col[1], col[2], col[3]);
-    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, col);
+    TRACE("Setting ambient to (%d,%d,%d,%d)\n", col[0], col[1], col[2], col[3]);
+    glLightModeliv(GL_LIGHT_MODEL_AMBIENT, col);
     checkGLcall("glLightModel for MODEL_AMBIENT");
 }
 
@@ -499,8 +499,8 @@ static void state_texfactor(DWORD state,
     /* Note the texture color applies to all textures whereas
      * GL_TEXTURE_ENV_COLOR applies to active only
      */
-    float col[4];
-    D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_TEXTUREFACTOR], col);
+    GLint col[4];
+    D3DCOLORTOGLINT4(stateblock->renderState[WINED3DRS_TEXTUREFACTOR], col);
 
     if (!GL_SUPPORT(NV_REGISTER_COMBINERS)) {
         /* And now the default texture color as well */
@@ -515,11 +515,11 @@ static void state_texfactor(DWORD state,
                 FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
             }
 
-            glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &col[0]);
+            glTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &col[0]);
             checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);");
         }
     } else {
-        GL_EXTCALL(glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV, &col[0]));
+        GL_EXTCALL(glCombinerParameterivNV(GL_CONSTANT_COLOR0_NV, &col[0]));
     }
 }
 
@@ -786,10 +786,10 @@ #endif
 }
 
 static void state_fogcolor(DWORD state, IWineD3DStateBlockImpl *stateblock) {
-    float col[4];
-    D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_FOGCOLOR], col);
+    GLint col[4];
+    D3DCOLORTOGLINT4(stateblock->renderState[WINED3DRS_FOGCOLOR], col);
     /* Set the default alpha blend color */
-    glFogfv(GL_FOG_COLOR, &col[0]);
+    glFogiv(GL_FOG_COLOR, &col[0]);
     checkGLcall("glFog GL_FOG_COLOR");
 }
 
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 0efe89b..e3af89b 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -228,6 +228,12 @@ #define D3DCOLORTOGLFLOAT4(dw, vec) \
   (vec)[2] = D3DCOLOR_B(dw); \
   (vec)[3] = D3DCOLOR_A(dw);
 
+#define D3DCOLORTOGLINT4(src, dst) \
+  (dst)[0] = D3DCOLOR_B_R(src); \
+  (dst)[1] = D3DCOLOR_B_G(src); \
+  (dst)[2] = D3DCOLOR_B_B(src); \
+  (dst)[3] = D3DCOLOR_B_A(src);
+
 /* DirectX Device Limits */
 /* --------------------- */
 #define MAX_LEVELS  256  /* Maximum number of mipmap levels. Guessed at 256 */


More information about the wine-patches mailing list