wined3d: Fix the half pixel correction.

This commit is contained in:
Stefan Dösinger 2007-08-19 19:43:44 +02:00 committed by Alexandre Julliard
parent a45badf5c0
commit 322b55e29a
1 changed files with 13 additions and 8 deletions

View File

@ -2631,9 +2631,9 @@ static void transform_projection(DWORD state, IWineD3DStateBlockImpl *stateblock
} }
checkGLcall("glOrtho"); checkGLcall("glOrtho");
/* Window Coord 0 is the middle of the first pixel, so translate by 3/8 pixels */ /* Window Coord 0 is the middle of the first pixel, so translate by 1/2 pixels */
glTranslatef(0.375, 0.375, 0); glTranslatef(0.5, 0.5, 0);
checkGLcall("glTranslatef(0.375, 0.375, 0)"); checkGLcall("glTranslatef(0.5, 0.5, 0)");
/* D3D texture coordinates are flipped compared to OpenGL ones, so /* D3D texture coordinates are flipped compared to OpenGL ones, so
* render everything upside down when rendering offscreen. */ * render everything upside down when rendering offscreen. */
if (stateblock->wineD3DDevice->render_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 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 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) -1 and 1 respectively but (-1-1/viewport_widh) and (1-1/viewport_width)
instead. */ instead.
glTranslatef(0.9 / stateblock->viewport.Width, -0.9 / stateblock->viewport.Height, 0);
checkGLcall("glTranslatef (0.9 / width, -0.9 / height, 0)"); 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 /* D3D texture coordinates are flipped compared to OpenGL ones, so
* render everything upside down when rendering offscreen. */ * render everything upside down when rendering offscreen. */
@ -3369,8 +3374,8 @@ static void viewport(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCon
checkGLcall("glViewport"); checkGLcall("glViewport");
stateblock->wineD3DDevice->posFixup[2] = 0.9 / stateblock->viewport.Width; stateblock->wineD3DDevice->posFixup[2] = 1.0 / stateblock->viewport.Width;
stateblock->wineD3DDevice->posFixup[3] = -0.9 / stateblock->viewport.Height; stateblock->wineD3DDevice->posFixup[3] = -1.0 / stateblock->viewport.Height;
if(!isStateDirty(context, STATE_TRANSFORM(WINED3DTS_PROJECTION))) { if(!isStateDirty(context, STATE_TRANSFORM(WINED3DTS_PROJECTION))) {
transform_projection(STATE_TRANSFORM(WINED3DTS_PROJECTION), stateblock, context); transform_projection(STATE_TRANSFORM(WINED3DTS_PROJECTION), stateblock, context);
} }