Commit 81aeae32 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Do not specify the viewport origin upside down when doing offscreen rendering.

The gl viewport origin is the lower left corner of the window, in d3d it is the upper right corner. This is corrected when setting the viewport. However, when we are doing offscreen rendering, this is reversed. So do not flip the viewport origin when rendering offscreen.
parent 6886b237
......@@ -5134,6 +5134,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderTarget(IWineD3DDevice *iface,
viewport.MaxZ = 1.0f;
viewport.MinZ = 0.0f;
IWineD3DDeviceImpl_SetViewport(iface, &viewport);
/* Make sure the viewport state is dirty, because the render_offscreen thing affects it.
* SetViewport may catch NOP viewport changes, which would occur when switching between equally sized targets
*/
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VIEWPORT);
/* Activate the new render target for now. This shouldn't stay here, but is needed until all methods using gl activate the
* ctx properly.
......
......@@ -3015,11 +3015,17 @@ static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateblock, W
static void viewport(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
glDepthRange(stateblock->viewport.MinZ, stateblock->viewport.MaxZ);
checkGLcall("glDepthRange");
/* Note: GL requires lower left, DirectX supplies upper left */
/* TODO: replace usage of renderTarget with context management */
glViewport(stateblock->viewport.X,
(((IWineD3DSurfaceImpl *)stateblock->wineD3DDevice->render_targets[0])->currentDesc.Height - (stateblock->viewport.Y + stateblock->viewport.Height)),
stateblock->viewport.Width, stateblock->viewport.Height);
/* Note: GL requires lower left, DirectX supplies upper left. This is reversed when using offscreen rendering
*/
if(stateblock->wineD3DDevice->render_offscreen) {
glViewport(stateblock->viewport.X,
stateblock->viewport.Y,
stateblock->viewport.Width, stateblock->viewport.Height);
} else {
glViewport(stateblock->viewport.X,
(((IWineD3DSurfaceImpl *)stateblock->wineD3DDevice->render_targets[0])->currentDesc.Height - (stateblock->viewport.Y + stateblock->viewport.Height)),
stateblock->viewport.Width, stateblock->viewport.Height);
}
checkGLcall("glViewport");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment