[D3D 81] Small code reorg

Lionel Ulmer lionel.ulmer at free.fr
Sat Jan 4 07:20:09 CST 2003


Changelog:
 Factorize the 'ortho' code (will be needed later on)

-- 
		 Lionel Ulmer - http://www.bbrox.org/
-------------- next part --------------
--- /home/ulmer/Wine/wine_base//dlls/ddraw/d3ddevice/mesa.c	2003-01-04 08:12:57.000000000 +0100
+++ /home/ulmer/Wine/wine_work//dlls/ddraw/d3ddevice/mesa.c	2003-01-04 11:42:54.000000000 +0100
@@ -668,28 +670,10 @@
 	    glEnable(GL_FOG);
     } else if ((vertex_transformed == TRUE) &&
 	       (glThis->transform_state != GL_TRANSFORM_ORTHO)) {
-        GLfloat height, width;
-	GLfloat trans_mat[16];
-	
-	glThis->transform_state = GL_TRANSFORM_ORTHO;
-	
-	width = glThis->parent.surface->surface_desc.dwWidth;
-	height = glThis->parent.surface->surface_desc.dwHeight;
-
-	/* The X axis is straighforward.. For the Y axis, we need to convert 'D3D' screen coordinates
-	   to OpenGL screen coordinates (ie the upper left corner is not the same).
-	   For Z, the mystery is what should it be mapped to ? Ie should the resulting range be between
-	   -1.0 and 1.0 (as the X and Y coordinates) or between 0.0 and 1.0 ? */
-	trans_mat[ 0] = 2.0 / width;  trans_mat[ 4] = 0.0;  trans_mat[ 8] = 0.0; trans_mat[12] = -1.0;
-	trans_mat[ 1] = 0.0; trans_mat[ 5] = -2.0 / height; trans_mat[ 9] = 0.0; trans_mat[13] =  1.0;
-	trans_mat[ 2] = 0.0; trans_mat[ 6] = 0.0; trans_mat[10] = 1.0;           trans_mat[14] = -1.0;
-	trans_mat[ 3] = 0.0; trans_mat[ 7] = 0.0; trans_mat[11] = 0.0;           trans_mat[15] =  1.0;
-
-        glMatrixMode(GL_MODELVIEW);
-	glLoadIdentity();
-	glMatrixMode(GL_PROJECTION);
-	glLoadMatrixf(trans_mat);
-
+        /* Set our orthographic projection */
+        glThis->transform_state = GL_TRANSFORM_ORTHO;
+	d3ddevice_set_ortho(This);
+    
 	/* Remove also fogging... */
 	glDisable(GL_FOG);
     }
@@ -1901,6 +1885,30 @@
 }
 
 void
+d3ddevice_set_ortho(IDirect3DDeviceImpl *This)
+{
+    GLfloat height, width;
+    GLfloat trans_mat[16];
+    
+    width = This->surface->surface_desc.dwWidth;
+    height = This->surface->surface_desc.dwHeight;
+    
+    /* The X axis is straighforward.. For the Y axis, we need to convert 'D3D' screen coordinates
+       to OpenGL screen coordinates (ie the upper left corner is not the same).
+       For Z, the mystery is what should it be mapped to ? Ie should the resulting range be between
+       -1.0 and 1.0 (as the X and Y coordinates) or between 0.0 and 1.0 ? */
+    trans_mat[ 0] = 2.0 / width;  trans_mat[ 4] = 0.0;  trans_mat[ 8] = 0.0; trans_mat[12] = -1.0;
+    trans_mat[ 1] = 0.0; trans_mat[ 5] = -2.0 / height; trans_mat[ 9] = 0.0; trans_mat[13] =  1.0;
+    trans_mat[ 2] = 0.0; trans_mat[ 6] = 0.0; trans_mat[10] = 1.0;           trans_mat[14] = -1.0;
+    trans_mat[ 3] = 0.0; trans_mat[ 7] = 0.0; trans_mat[11] = 0.0;           trans_mat[15] =  1.0;
+    
+    glMatrixMode(GL_MODELVIEW);
+    glLoadIdentity();
+    glMatrixMode(GL_PROJECTION);
+    glLoadMatrixf(trans_mat);
+}
+
+void
 d3ddevice_set_matrices(IDirect3DDeviceImpl *This, DWORD matrices,
 		       D3DMATRIX *world_mat, D3DMATRIX *view_mat, D3DMATRIX *proj_mat)
 {
--- /home/ulmer/Wine/wine_base//dlls/ddraw/d3dexecutebuffer.c	2003-01-02 18:01:43.000000000 +0100
+++ /home/ulmer/Wine/wine_work//dlls/ddraw/d3dexecutebuffer.c	2003-01-04 11:08:00.000000000 +0100
@@ -269,31 +269,11 @@
 			break;
 
 		    case D3DVT_TLVERTEX: {
-		        GLdouble height, width;
-			GLfloat trans_mat[16];
-			
-			/* First, disable lighting */
+			/* First, disable lighting and fogging */
 			glDisable(GL_LIGHTING);
-			
-			width = lpDevice->surface->surface_desc.dwWidth;
-			height = lpDevice->surface->surface_desc.dwHeight;
-
-			/* The X axis is straighforward.. For the Y axis, we need to convert 'D3D' screen coordinates
-			   to OpenGL screen coordinates (ie the upper left corner is not the same).
-			   For Z, the mystery is what should it be mapped to ? Ie should the resulting range be between
-			   -1.0 and 1.0 (as the X and Y coordinates) or between 0.0 and 1.0 ? */
-			trans_mat[ 0] = 2.0 / width;  trans_mat[ 4] = 0.0;  trans_mat[ 8] = 0.0; trans_mat[12] = -1.0;
-			trans_mat[ 1] = 0.0; trans_mat[ 5] = -2.0 / height; trans_mat[ 9] = 0.0; trans_mat[13] =  1.0;
-			trans_mat[ 2] = 0.0; trans_mat[ 6] = 0.0; trans_mat[10] = 1.0;           trans_mat[14] = -1.0;
-			trans_mat[ 3] = 0.0; trans_mat[ 7] = 0.0; trans_mat[11] = 0.0;           trans_mat[15] =  1.0;
-
-			glMatrixMode(GL_MODELVIEW);
-			glLoadIdentity();
-			glMatrixMode(GL_PROJECTION);
-			glLoadMatrixf(trans_mat);
-
-			/* Remove also fogging... */
 			glDisable(GL_FOG);
+			
+			d3ddevice_set_ortho(lpDevice);
 		    } break;
 
 		    default:
--- /home/ulmer/Wine/wine_base//dlls/ddraw/mesa_private.h	2003-01-03 16:02:11.000000000 +0100
+++ /home/ulmer/Wine/wine_work//dlls/ddraw/mesa_private.h	2003-01-04 11:07:02.000000000 +0100
@@ -164,6 +164,9 @@
 /* Used to upload the texture */
 extern HRESULT gltex_upload_texture(IDirectDrawSurfaceImpl *This) ;
 
+/* Used to set-up our orthographic projection */
+extern void d3ddevice_set_ortho(IDirect3DDeviceImpl *This) ;
+
 /* Common functions defined in d3dcommon.c */
 void set_render_state(IDirect3DDeviceGLImpl* This,
 		      D3DRENDERSTATETYPE dwRenderStateType, DWORD dwRenderState);


More information about the wine-patches mailing list