[dx63] Warcraft ugly fonts

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

 



This solves the problem of very ugly fonts in Warcraft3. I'd like to
take credit but I am just tidying up and commenting a fix which was
worked on by Lucho. 

Changelog:

Ensure pixel coordinates point to the bottom left of the pixel not the
middle

Jason
Index: dlls/d3d8/drawprim.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/drawprim.c,v
retrieving revision 1.3
diff -u -r1.3 drawprim.c
--- dlls/d3d8/drawprim.c	27 Jun 2003 22:20:44 -0000	1.3
+++ dlls/d3d8/drawprim.c	1 Jul 2003 19:29:09 -0000
@@ -185,13 +185,6 @@
         checkGLcall("glMatrixMode");
         glLoadIdentity();
         checkGLcall("glLoadIdentity");
-        /**
-         * As seen in d3d7 code:
-         *  See the OpenGL Red Book for an explanation of the following translation (in the OpenGL
-         *  Correctness Tips section).
-         */
-        glTranslatef(0.375f, 0.375f, 0.0f);
-        checkGLcall("glTranslatef(0.375f, 0.375f, 0.0f)");
 
         glMatrixMode(GL_PROJECTION);
         checkGLcall("glMatrixMode");
@@ -209,6 +202,11 @@
         glOrtho(X, X + width, Y + height, Y, -minZ, -maxZ);
         checkGLcall("glOrtho");
 
+        /* Window Coord 0 is the middle of the first pixel, so translate by half
+           a pixel (See comment above glTranslate below)                         */
+        glTranslatef(0.5, 0.5, 0);
+        checkGLcall("glTranslatef(0.5, 0.5, 0)");
+
     } else {
 
         /* Untransformed, so relies on the view and projection matrices */
@@ -219,11 +217,22 @@
         glMultMatrixf((float *) &This->StateBlock->transforms[D3DTS_WORLDMATRIX(0)].u.m[0][0]);
         checkGLcall("glMultMatrixf");
 
-
         glMatrixMode(GL_PROJECTION);
         checkGLcall("glMatrixMode");
-        glLoadMatrixf((float *) &This->StateBlock->transforms[D3DTS_PROJECTION].u.m[0][0]);
+
+        /* The rule is that the window coordinate 0 does not correspond to the
+           beginning of the first pixel, but the center of the first pixel.
+           As a consequence if you want to correctly draw one line exactly from
+           the left to the right end of the viewport (with all matrices set to
+           be identity), the x coords of both ends of the line would be not
+           -1 and 1 respectively but (-1-1/viewport_widh) and (1-1/viewport_width)
+           instead.                                                               */
+        glLoadIdentity();
+        glTranslatef(1.0/This->StateBlock->viewport.Width, -1.0/This->StateBlock->viewport.Height, 0);
+        checkGLcall("glTranslatef (1.0/width, -1.0/height, 0)");
+        glMultMatrixf((float *) &This->StateBlock->transforms[D3DTS_PROJECTION].u.m[0][0]);
         checkGLcall("glLoadMatrixf");
+
     }
     return isLightingOn;
 }

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

  Powered by Linux