WineD3D: Scissor rect corrections

Stefan Dösinger stefan at codeweavers.com
Fri Nov 3 12:11:19 CST 2006


The opengl scissor rectangle origin is on the lower left corner of the window, 
not the top left as in d3d
-------------- next part --------------
From 1c394d5e1221df98014eb531bea090263db52ae1 Mon Sep 17 00:00:00 2001
From: Stefan Doesinger <stefan at codeweavers.com>
Date: Fri, 3 Nov 2006 18:53:34 +0100
Subject: [PATCH] WineD3D: ScissorRect correction
---
 dlls/wined3d/device.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 481517e..0b5f3b8 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -4650,11 +4650,19 @@ static HRESULT WINAPI IWineD3DDeviceImpl
 
 static HRESULT WINAPI IWineD3DDeviceImpl_SetScissorRect(IWineD3DDevice *iface, CONST RECT* pRect) {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
-    ENTER_GL();
+    RECT windowRect;
+    UINT winHeight;
 
-    /** FIXME: Windows uses a top,left origin openGL uses a bottom Right? **/
-    TRACE("(%p)Setting new Scissor Rect to %d:%d-%d:%d\n", This, pRect->left, pRect->top, pRect->right, pRect->bottom);
-    glScissor(pRect->left, pRect->top, pRect->right - pRect->left, pRect->bottom - pRect->top);
+    GetWindowRect(((IWineD3DSwapChainImpl *)This->swapchains[0])->win_handle, &windowRect);
+    /* Warning: glScissor uses window coordinates, not viewport coordinates, so our viewport correction does not apply
+    * Warning2: Even in windowed mode the coords are relative to the window, not the screen
+    */
+    winHeight = windowRect.bottom - windowRect.top;
+    TRACE("(%p)Setting new Scissor Rect to %d:%d-%d:%d\n", This, pRect->left, pRect->bottom - winHeight,
+          pRect->right - pRect->left, pRect->bottom - pRect->top);
+    ENTER_GL();
+    glScissor(pRect->left, pRect->bottom - winHeight, pRect->right - pRect->left, pRect->bottom - pRect->top);
+    checkGLcall("glScissor");
     LEAVE_GL();
 
     return WINED3D_OK;
-- 
1.4.1.1



More information about the wine-patches mailing list