[D3D 20] Alpha test support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Changelog:
 Supports the ALPHAFUNC and ALPHAREF rendering states

-- 
		 Lionel Ulmer - http://www.bbrox.org/
--- ../wine_base/dlls/ddraw/mesa.c	Sun Dec 15 12:16:39 2002
+++ dlls/ddraw/mesa.c	Sun Dec 15 14:43:11 2002
@@ -30,6 +30,22 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
 
+GLenum convert_D3D_compare_to_GL(D3DCMPFUNC dwRenderState)
+{
+    switch (dwRenderState) {
+        case D3DCMP_NEVER: return GL_NEVER;
+	case D3DCMP_LESS: return GL_LESS;
+	case D3DCMP_EQUAL: return GL_EQUAL;
+	case D3DCMP_LESSEQUAL: return GL_LEQUAL;
+	case D3DCMP_GREATER: return GL_GREATER;
+	case D3DCMP_NOTEQUAL: return GL_NOTEQUAL;
+	case D3DCMP_GREATEREQUAL: return GL_GEQUAL;
+	case D3DCMP_ALWAYS: return GL_ALWAYS;
+	default: ERR("Unexpected compare type !!!\n");
+    }
+}  
+     
+
 void set_render_state(D3DRENDERSTATETYPE dwRenderStateType,
 		      DWORD dwRenderState, RenderState *rs)
 {
@@ -66,9 +82,9 @@
 		}
 	    } break;
 
-	    case D3DRENDERSTATE_TEXTUREADDRESSU:
-	    case D3DRENDERSTATE_TEXTUREADDRESSV:
-	    case D3DRENDERSTATE_TEXTUREADDRESS: { /* 3 */
+	    case D3DRENDERSTATE_TEXTUREADDRESSU:  /* 44 */
+	    case D3DRENDERSTATE_TEXTUREADDRESSV:  /* 45 */
+	    case D3DRENDERSTATE_TEXTUREADDRESS: { /*  3 */
 	        GLenum arg = GL_REPEAT; /* Default value */
 	        switch ((D3DTEXTUREADDRESS) dwRenderState) {
 		    case D3DTADDRESS_WRAP:   arg = GL_REPEAT; break;
@@ -133,8 +149,15 @@
 		else
 		    glDepthMask(GL_FALSE);
 	        break;
+	      
+	    case D3DRENDERSTATE_ALPHATESTENABLE:  /* 15 */
+	        if (dwRenderState)
+		    glEnable(GL_ALPHA_TEST);
+	        else
+		    glDisable(GL_ALPHA_TEST);
+	        break;
 
-	    case D3DRENDERSTATE_TEXTUREMAG:         /* 17 */
+	    case D3DRENDERSTATE_TEXTUREMAG:       /* 17 */
 	        switch ((D3DTEXTUREFILTER) dwRenderState) {
 		    case D3DFILTER_NEAREST:
 		        rs->mag = GL_NEAREST;
@@ -218,34 +241,17 @@
 	        break;
 
 	    case D3DRENDERSTATE_ZFUNC:            /* 23 */
-	        switch ((D3DCMPFUNC) dwRenderState) {
-		    case D3DCMP_NEVER:
-		        glDepthFunc(GL_NEVER);
-			break;
-		    case D3DCMP_LESS:
-			glDepthFunc(GL_LESS);
-			break;
-		    case D3DCMP_EQUAL:
-			glDepthFunc(GL_EQUAL);
-			break;
-		    case D3DCMP_LESSEQUAL:
-			glDepthFunc(GL_LEQUAL);
-			break;
-		    case D3DCMP_GREATER:
-			glDepthFunc(GL_GREATER);
-			break;
-		    case D3DCMP_NOTEQUAL:
-			glDepthFunc(GL_NOTEQUAL);
-			break;
-		    case D3DCMP_GREATEREQUAL:
-			glDepthFunc(GL_GEQUAL);
-			break;
-		    case D3DCMP_ALWAYS:
-			glDepthFunc(GL_ALWAYS);
-			break;
-		    default:
-			ERR("Unexpected value\n");
-		}
+	        glDepthFunc(convert_D3D_compare_to_GL(dwRenderState));
+	        break;
+	      
+	    case D3DRENDERSTATE_ALPHAREF:   /* 24 */
+	        rs->alpha_ref = dwRenderState / 255.0;
+	        glAlphaFunc(rs->alpha_func, rs->alpha_ref);
+	        break;
+	      
+	    case D3DRENDERSTATE_ALPHAFUNC: /* 25 */
+	        rs->alpha_func = convert_D3D_compare_to_GL(dwRenderState);
+	        glAlphaFunc(rs->alpha_func, rs->alpha_ref);
 	        break;
 
 	    case D3DRENDERSTATE_DITHERENABLE:     /* 26 */
--- ../wine_base/dlls/ddraw/mesa_private.h	Sun Dec 15 12:15:49 2002
+++ dlls/ddraw/mesa_private.h	Sun Dec 15 14:32:34 2002
@@ -63,6 +63,10 @@
     GLenum src, dst;
     /* This is used for textures */
     GLenum mag, min;
+
+    /* This is needed for the Alpha stuff */
+    GLenum alpha_func;
+    GLclampf alpha_ref;
 } RenderState;
 
 /* Common functions defined in d3dcommon.c */
--- ../wine_base/dlls/ddraw/d3ddevice/mesa.c	Sun Dec 15 12:15:49 2002
+++ dlls/ddraw/d3ddevice/mesa.c	Sun Dec 15 14:36:25 2002
@@ -1662,7 +1662,9 @@
     gl_object->render_state.dst = GL_ZERO;
     gl_object->render_state.mag = GL_NEAREST;
     gl_object->render_state.min = GL_NEAREST;
-
+    gl_object->render_state.alpha_ref = 0.0; /* No actual idea about the real default value... */
+    gl_object->render_state.alpha_func = GL_ALWAYS; /* Here either but it seems logical */
+    
     /* Allocate memory for the matrices */
     gl_object->world_mat = (D3DMATRIX *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 16 * sizeof(float));
     gl_object->view_mat  = (D3DMATRIX *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 16 * sizeof(float));

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux