Implement BlendFactor renderstate

Kovács András andras at csevego.net
Fri Sep 1 14:47:27 CDT 2006


Hi,
I implemented D3DBLEND_BLENDFACTOR & D3DBLEND_INVBLENDFACTOR blending value. 
Without this, if a program uses blendfactor, it won't display blended result. 
With this my sample app works on wine as on windows.

Changelog:
* Implement BlendFactor renderstate

Best Regards, 
-- 
Lamarr
Kovács András
andras at csevego.net
http://csevego.net
-------------- next part --------------
From nobody Mon Sep 17 00:00:00 2001
From: Kov??cs Andr??s <andras at csevego.net>
Date: Fri Sep 1 21:32:49 2006 +0200
Subject: [PATCH] Implement BlendFactor renderstate
---

 dlls/wined3d/device.c  |   36 +++++++++++++++++++++---------------
 dlls/wined3d/directx.c |    6 ++++--
 2 files changed, 25 insertions(+), 17 deletions(-)

8f1476d50880b652d901e09b33ddc112d91740a9
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index c6a2af5..d46bb01 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -494,18 +494,6 @@ static void WINAPI IWineD3DDeviceImpl_Se
         checkGLcall("glTexEnvi GL_TEXTURE_LOD_BIAS_EXT ...");
     }
 
-    /* Note the D3DRS value applies to all textures, but GL has one
-     *  per texture, so apply it now ready to be used!
-     */
-    D3DCOLORTOGLFLOAT4(This->stateBlock->renderState[WINED3DRS_TEXTUREFACTOR], col);
-    /* Set the default alpha blend color */
-    if (GL_SUPPORT(ARB_IMAGING)) {
-        GL_EXTCALL(glBlendColor(col[0], col[1], col[2], col[3]));
-        checkGLcall("glBlendColor");
-    } else {
-        WARN("Unsupported in local OpenGL implementation: glBlendColor\n");
-    }
-
     D3DCOLORTOGLFLOAT4(This->stateBlock->renderState[WINED3DRS_TEXTUREFACTOR], col);
     glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &col[0]);
     checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);");
@@ -3610,7 +3598,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl
             case D3DBLEND_DESTCOLOR          : newVal = GL_DST_COLOR;  break;
             case D3DBLEND_INVDESTCOLOR       : newVal = GL_ONE_MINUS_DST_COLOR;  break;
             case D3DBLEND_SRCALPHASAT        : newVal = GL_SRC_ALPHA_SATURATE;  break;
-
             case D3DBLEND_BOTHSRCALPHA       : newVal = GL_SRC_ALPHA;
                 This->srcBlend = newVal;
                 This->dstBlend = newVal;
@@ -3620,6 +3607,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl
                 This->srcBlend = newVal;
                 This->dstBlend = newVal;
                 break;
+            case D3DBLEND_BLENDFACTOR        : newVal = GL_CONSTANT_COLOR;   break;
+            case D3DBLEND_INVBLENDFACTOR     : newVal = GL_ONE_MINUS_CONSTANT_COLOR;  break;
             default:
                 FIXME("Unrecognized src/dest blend value %ld (%d)\n", Value, State);
             }
@@ -4553,8 +4542,25 @@ static HRESULT WINAPI IWineD3DDeviceImpl
 
     case WINED3DRS_BLENDFACTOR               :
     {
-        if(0xFFFFFFFF != Value)
-            ERR("(%p)->(%s,%ld) not yet implemented. Missing of cap D3DPBLENDCAPS_BLENDFACTOR wasn't honored?\n", This, debug_d3drenderstate(State), Value);
+    float col[4];
+ 
+        if (GL_SUPPORT(ARB_IMAGING)) {
+
+           TRACE("Setting BlendFactor to %ld", Value);
+ 
+           D3DCOLORTOGLFLOAT4(Value, col);
+           if (0xFFFFFFFF != Value) {
+               glEnable(GL_BLEND);
+	       checkGLcall("glEnable(GL_BLEND)");
+	   }
+	   else {
+	      glDisable(GL_BLEND);
+              checkGLcall("glDisable(GL_BLEND)");
+	   }
+           glBlendColor (col[0],col[1],col[2],col[3]);
+       } else {
+           WARN("Unsupported in local OpenGL implementation: glBlendColor\n");
+       }
         break;
     }
 
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index c413175..df9cf89 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -1912,7 +1912,8 @@ static HRESULT WINAPI IWineD3DImpl_GetDe
                             D3DPBLENDCAPS_SRCALPHA        |
                             D3DPBLENDCAPS_SRCALPHASAT     |
                             D3DPBLENDCAPS_SRCCOLOR        |
-                            D3DPBLENDCAPS_ZERO;
+                            D3DPBLENDCAPS_ZERO            |
+			    D3DPBLENDCAPS_BLENDFACTOR;
                             
     *pCaps->DestBlendCaps = D3DPBLENDCAPS_BLENDFACTOR     |
                             D3DPBLENDCAPS_BOTHINVSRCALPHA |
@@ -1927,7 +1928,8 @@ static HRESULT WINAPI IWineD3DImpl_GetDe
                             D3DPBLENDCAPS_SRCALPHA        |
                             D3DPBLENDCAPS_SRCALPHASAT     |
                             D3DPBLENDCAPS_SRCCOLOR        |
-                            D3DPBLENDCAPS_ZERO;
+                            D3DPBLENDCAPS_ZERO            |
+			    D3DPBLENDCAPS_BLENDFACTOR;
 
     *pCaps->AlphaCmpCaps = D3DPCMPCAPS_ALWAYS       |
                            D3DPCMPCAPS_EQUAL        |
-- 
1.2.4



More information about the wine-patches mailing list