[2/?]WineD3D: Adjust the rhw transformation for offscreen rendering
Stefan Dösinger
stefan at codeweavers.com
Fri Mar 2 19:53:46 CST 2007
I hope I explained it correctly, these tripple upside down matrix things are
the perfect way to get insane.
-------------- next part --------------
From a1ec40ad4a5147ca250b2056282bad14770653f9 Mon Sep 17 00:00:00 2001
From: Stefan Doesinger <stefan at codeweavers.com>
Date: Sat, 3 Mar 2007 02:35:17 +0100
Subject: [PATCH] WineD3D: Adjust the rhw transformation for offscreen rendering
When drawing processed vertices with the fixed function pipeline the projection matrix is set up to map y values from 0 to height to 1.0;
-1.0(gl and d3d coord systems are flipped). This moves the y axis to the bottom of the drawing area. When later on the y inversion matrix
is applied for offscreen rendering, the coordinate system will get flipped out of the viewport.
This patch sets the Y range up upside down when using offscreen rendering, so the invymat will flip it to the correct position. This has to
happen before the 0.375 pixel correction.
---
dlls/wined3d/state.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 64bce1c..ba421a1 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -2154,7 +2154,11 @@ static void transform_projection(DWORD state, IWineD3DStateBlockImpl *stateblock
* the Z coordinate does not affect the size of the primitives
*/
TRACE("Calling glOrtho with %f, %f, %f, %f\n", width, height, -minZ, -maxZ);
- glOrtho(X, X + width, Y + height, Y, -minZ, -maxZ);
+ if(stateblock->wineD3DDevice->render_offscreen) {
+ glOrtho(X, X + width, Y, Y - height, -minZ, -maxZ);
+ } else {
+ glOrtho(X, X + width, Y + height, Y, -minZ, -maxZ);
+ }
} else {
/* If the app mixes transformed and untransformed primitives we can't use the coordinate system
* trick above because this would mess up transformed and untransformed Z order. Pass the z position
@@ -2164,7 +2168,11 @@ static void transform_projection(DWORD state, IWineD3DStateBlockImpl *stateblock
* replacement shader.
*/
TRACE("Calling glOrtho with %f, %f, %f, %f\n", width, height, 1.0, -1.0);
- glOrtho(X, X + width, Y + height, Y, 1.0, -1.0);
+ if(stateblock->wineD3DDevice->render_offscreen) {
+ glOrtho(X, X + width, Y, Y - height, 1.0, -1.0);
+ } else {
+ glOrtho(X, X + width, Y + height, Y, 1.0, -1.0);
+ }
}
checkGLcall("glOrtho");
--
1.4.4.3
More information about the wine-patches
mailing list