Stefan Dösinger : wined3d: Fix the half pixel correction.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Aug 28 07:50:09 CDT 2007


Module: wine
Branch: master
Commit: 322b55e29a83a3ab61a1912d751816aa24662e9f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=322b55e29a83a3ab61a1912d751816aa24662e9f

Author: Stefan Dösinger <stefan at codeweavers.com>
Date:   Sun Aug 19 19:43:44 2007 +0200

wined3d: Fix the half pixel correction.

---

 dlls/wined3d/state.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 900e366..4b38e40 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -2631,9 +2631,9 @@ static void transform_projection(DWORD state, IWineD3DStateBlockImpl *stateblock
         }
         checkGLcall("glOrtho");
 
-        /* Window Coord 0 is the middle of the first pixel, so translate by 3/8 pixels */
-        glTranslatef(0.375, 0.375, 0);
-        checkGLcall("glTranslatef(0.375, 0.375, 0)");
+        /* Window Coord 0 is the middle of the first pixel, so translate by 1/2 pixels */
+        glTranslatef(0.5, 0.5, 0);
+        checkGLcall("glTranslatef(0.5, 0.5, 0)");
         /* D3D texture coordinates are flipped compared to OpenGL ones, so
          * render everything upside down when rendering offscreen. */
         if (stateblock->wineD3DDevice->render_offscreen) {
@@ -2647,9 +2647,14 @@ static void transform_projection(DWORD state, IWineD3DStateBlockImpl *stateblock
             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.                                                               */
-        glTranslatef(0.9 / stateblock->viewport.Width, -0.9 / stateblock->viewport.Height, 0);
-        checkGLcall("glTranslatef (0.9 / width, -0.9 / height, 0)");
+            instead.
+
+            1.0 / Width is used because the coord range goes from -1.0 to 1.0, then we
+            divide by the Width/Height, so we need the half range(1.0) to translate by
+            half a pixel.
+         */
+        glTranslatef(1.0 / stateblock->viewport.Width, -1.0/ stateblock->viewport.Height, 0);
+        checkGLcall("glTranslatef (1.0 / width, -1.0 / height, 0)");
 
         /* D3D texture coordinates are flipped compared to OpenGL ones, so
             * render everything upside down when rendering offscreen. */
@@ -3369,8 +3374,8 @@ static void viewport(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCon
 
     checkGLcall("glViewport");
 
-    stateblock->wineD3DDevice->posFixup[2] = 0.9 / stateblock->viewport.Width;
-    stateblock->wineD3DDevice->posFixup[3] = -0.9 / stateblock->viewport.Height;
+    stateblock->wineD3DDevice->posFixup[2] = 1.0 / stateblock->viewport.Width;
+    stateblock->wineD3DDevice->posFixup[3] = -1.0 / stateblock->viewport.Height;
     if(!isStateDirty(context, STATE_TRANSFORM(WINED3DTS_PROJECTION))) {
         transform_projection(STATE_TRANSFORM(WINED3DTS_PROJECTION), stateblock, context);
     }




More information about the wine-cvs mailing list