[7/16] WineD3D: Move WINED3DRS_SPECULARENABLE to the state table

Stefan Dösinger stefan at codeweavers.com
Fri Dec 8 11:38:30 CST 2006


-------------- next part --------------
From a0b2dd0928a40d6dc390885e0430bf40bbacdbbd Mon Sep 17 00:00:00 2001
From: Stefan Doesinger <stefan at codeweavers.com>
Date: Fri, 8 Dec 2006 16:52:56 +0100
Subject: [PATCH] WineD3D: Move WINED3DRS_SPECULARENABLE to the state table

---
 dlls/wined3d/device.c |   70 +-----------------------------------------------
 dlls/wined3d/state.c  |   72 ++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 72 insertions(+), 70 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 1921ad1..3da683c 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3461,76 +3461,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl
     case WINED3DRS_CLIPPING                  :
     case WINED3DRS_BLENDOP                   :
     case WINED3DRS_TEXTUREFACTOR             :
-        StateTable[STATE_RENDER(State)].apply(STATE_RENDER(State), This->stateBlock);
-        break;
-
     case WINED3DRS_SPECULARENABLE            :
-        {
-            /* Originally this used glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR)
-               and (GL_LIGHT_MODEL_COLOR_CONTROL,GL_SINGLE_COLOR) to swap between enabled/disabled
-               specular color. This is wrong:
-               Separate specular color means the specular colour is maintained separately, whereas
-               single color means it is merged in. However in both cases they are being used to
-               some extent.
-               To disable specular color, set it explicitly to black and turn off GL_COLOR_SUM_EXT
-               NOTE: If not supported don't give FIXMEs the impact is really minimal and very few people are
-                  running 1.4 yet!
-             */
-            /*
-             * If register combiners are enabled, enabling / disabling GL_COLOR_SUM has no effect.
-             * Instead, we need to setup the FinalCombiner properly.
-             *
-             * The default setup for the FinalCombiner is:
-             *
-             * <variable>       <input>                             <mapping>               <usage>
-             * GL_VARIABLE_A_NV GL_FOG,                             GL_UNSIGNED_IDENTITY_NV GL_ALPHA
-             * GL_VARIABLE_B_NV GL_SPARE0_PLUS_SECONDARY_COLOR_NV   GL_UNSIGNED_IDENTITY_NV GL_RGB
-             * GL_VARIABLE_C_NV GL_FOG                              GL_UNSIGNED_IDENTITY_NV GL_RGB
-             * GL_VARIABLE_D_NV GL_ZERO                             GL_UNSIGNED_IDENTITY_NV GL_RGB
-             * GL_VARIABLE_E_NV GL_ZERO                             GL_UNSIGNED_IDENTITY_NV GL_RGB
-             * GL_VARIABLE_F_NV GL_ZERO                             GL_UNSIGNED_IDENTITY_NV GL_RGB
-             * GL_VARIABLE_G_NV GL_SPARE0_NV                        GL_UNSIGNED_IDENTITY_NV GL_ALPHA
-             *
-             * That's pretty much fine as it is, except for variable B, which needs to take
-             * either GL_SPARE0_PLUS_SECONDARY_COLOR_NV or GL_SPARE0_NV, depending on
-             * whether WINED3DRS_SPECULARENABLE is enabled or not.
-             */
-
-              if (Value) {
-                glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float*) &This->updateStateBlock->material.Specular);
-                checkGLcall("glMaterialfv");
-                if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
-                  glEnable(GL_COLOR_SUM_EXT);
-                } else {
-                  TRACE("Specular colors cannot be enabled in this version of opengl\n");
-                }
-                checkGLcall("glEnable(GL_COLOR_SUM)");
-
-                if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
-                    GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_SPARE0_PLUS_SECONDARY_COLOR_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB));
-                    checkGLcall("glFinalCombinerInputNV()");
-                }
-              } else {
-                float black[4] = {0.0f, 0.0f, 0.0f, 0.0f};
-
-                /* for the case of enabled lighting: */
-                glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &black[0]);
-                checkGLcall("glMaterialfv");
-
-                /* for the case of disabled lighting: */
-                if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
-                  glDisable(GL_COLOR_SUM_EXT);
-                } else {
-                  TRACE("Specular colors cannot be disabled in this version of opengl\n");
-                }
-                checkGLcall("glDisable(GL_COLOR_SUM)");
-
-                if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
-                    GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB));
-                    checkGLcall("glFinalCombinerInputNV()");
-                }
-              }
-        }
+        StateTable[STATE_RENDER(State)].apply(STATE_RENDER(State), This->stateBlock);
         break;
 
     case WINED3DRS_STENCILENABLE :
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 549b120..a492fbe 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -432,6 +432,76 @@ static void state_blendop(DWORD state, I
     checkGLcall("glBlendEquation");
 }
 
+static void
+state_specularenable(DWORD state, IWineD3DStateBlockImpl *stateblock) {
+    /* Originally this used glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR)
+     * and (GL_LIGHT_MODEL_COLOR_CONTROL,GL_SINGLE_COLOR) to swap between enabled/disabled
+     * specular color. This is wrong:
+     * Separate specular color means the specular colour is maintained separately, whereas
+     * single color means it is merged in. However in both cases they are being used to
+     * some extent.
+     * To disable specular color, set it explicitly to black and turn off GL_COLOR_SUM_EXT
+     * NOTE: If not supported don't give FIXMEs the impact is really minimal and very few people are
+     * running 1.4 yet!
+     *
+     *
+     * If register combiners are enabled, enabling / disabling GL_COLOR_SUM has no effect.
+     * Instead, we need to setup the FinalCombiner properly.
+     *
+     * The default setup for the FinalCombiner is:
+     *
+     * <variable>       <input>                             <mapping>               <usage>
+     * GL_VARIABLE_A_NV GL_FOG,                             GL_UNSIGNED_IDENTITY_NV GL_ALPHA
+     * GL_VARIABLE_B_NV GL_SPARE0_PLUS_SECONDARY_COLOR_NV   GL_UNSIGNED_IDENTITY_NV GL_RGB
+     * GL_VARIABLE_C_NV GL_FOG                              GL_UNSIGNED_IDENTITY_NV GL_RGB
+     * GL_VARIABLE_D_NV GL_ZERO                             GL_UNSIGNED_IDENTITY_NV GL_RGB
+     * GL_VARIABLE_E_NV GL_ZERO                             GL_UNSIGNED_IDENTITY_NV GL_RGB
+     * GL_VARIABLE_F_NV GL_ZERO                             GL_UNSIGNED_IDENTITY_NV GL_RGB
+     * GL_VARIABLE_G_NV GL_SPARE0_NV                        GL_UNSIGNED_IDENTITY_NV GL_ALPHA
+     *
+     * That's pretty much fine as it is, except for variable B, which needs to take
+     * either GL_SPARE0_PLUS_SECONDARY_COLOR_NV or GL_SPARE0_NV, depending on
+     * whether WINED3DRS_SPECULARENABLE is enabled or not.
+     */
+
+    TRACE("Setting specular enable state\n");
+    /* TODO: Add to the material setting functions */
+    if (stateblock->renderState[WINED3DRS_SPECULARENABLE]) {
+        glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float*) &stateblock->material.Specular);
+        checkGLcall("glMaterialfv");
+        if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
+            glEnable(GL_COLOR_SUM_EXT);
+        } else {
+            TRACE("Specular colors cannot be enabled in this version of opengl\n");
+        }
+        checkGLcall("glEnable(GL_COLOR_SUM)");
+
+        if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
+            GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_SPARE0_PLUS_SECONDARY_COLOR_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB));
+            checkGLcall("glFinalCombinerInputNV()");
+        }
+    } else {
+        float black[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+
+        /* for the case of enabled lighting: */
+        glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &black[0]);
+        checkGLcall("glMaterialfv");
+
+        /* for the case of disabled lighting: */
+        if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
+            glDisable(GL_COLOR_SUM_EXT);
+        } else {
+            TRACE("Specular colors cannot be disabled in this version of opengl\n");
+        }
+        checkGLcall("glDisable(GL_COLOR_SUM)");
+
+        if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
+            GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB));
+            checkGLcall("glFinalCombinerInputNV()");
+        }
+    }
+}
+
 static void state_texfactor(DWORD state, IWineD3DStateBlockImpl *stateblock) {
     unsigned int i;
 
@@ -492,7 +562,7 @@ const struct StateEntry StateTable[] =
     { /* 26, WINED3DRS_DITHERENABLE                 */      STATE_RENDER(WINED3DRS_DITHERENABLE),               state_ditherenable  },
     { /* 27, WINED3DRS_ALPHABLENDENABLE             */      STATE_RENDER(WINED3DRS_ALPHABLENDENABLE),           state_blend         },
     { /* 28, WINED3DRS_FOGENABLE                    */      STATE_RENDER(WINED3DRS_FOGENABLE),                  state_unknown       },
-    { /* 29, WINED3DRS_SPECULARENABLE               */      STATE_RENDER(WINED3DRS_SPECULARENABLE),             state_unknown       },
+    { /* 29, WINED3DRS_SPECULARENABLE               */      STATE_RENDER(WINED3DRS_SPECULARENABLE),             state_specularenable},
     { /* 30, WINED3DRS_ZVISIBLE                     */      0 /* Not supported according to the msdn */,        state_nogl          },
     { /* 31, WINED3DRS_SUBPIXEL                     */      STATE_RENDER(WINED3DRS_SUBPIXEL),                   state_unknown       },
     { /* 32, WINED3DRS_SUBPIXELX                    */      STATE_RENDER(WINED3DRS_SUBPIXELX),                  state_unknown       },
-- 
1.4.2.4



More information about the wine-patches mailing list