Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/ddraw/tests/ddraw4.c | 43 +++++++++++++++++++++++++++++++++++++++ dlls/ddraw/viewport.c | 13 ++++++------ 2 files changed, 50 insertions(+), 6 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index ffa510a8b3..fd67317073 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -1837,11 +1837,54 @@ static void test_viewport_object(void) "Got unexpected values %g, %g, %g, %g, %g, %g.\n", vp.dvMaxX, vp.dvMaxY, vp.dvScaleX, vp.dvScaleY, vp.dvMinZ, vp.dvMaxZ);
+ vp.dwSize = sizeof(vp); + vp.dvMinZ = 0.5f; + vp.dvMaxZ = 2.0f; + hr = IDirect3DViewport3_SetViewport(viewport3, &vp); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + memset(&vp2, 0xff, sizeof(vp2)); + vp2.dwSize = sizeof(vp2); + hr = IDirect3DViewport3_GetViewport2(viewport3, &vp2); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(vp2.dvClipX == 0.75f && vp2.dvClipY == 1.0f && vp2.dvClipWidth == -1.5f + && vp2.dvClipHeight == 2.0f && vp2.dvMinZ == 0.0f && vp2.dvMaxZ == 1.0f, + "Got unexpected values %g, %g, %g, %g, %g, %g.\n", + vp2.dvClipX, vp2.dvClipY, vp2.dvClipWidth, vp2.dvClipHeight, vp2.dvMinZ, vp2.dvMaxZ); + + vp.dvMaxX = 4.5f; + vp.dvMaxY = -1.75f; + vp.dvScaleX = 192.0f; + vp.dvScaleY = -240.0f; + vp.dvMinZ = 2.0f; + vp.dvMaxZ = 0.5f; + + hr = IDirect3DViewport3_SetViewport(viewport3, &vp); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + memset(&vp2, 0xff, sizeof(vp2)); + vp2.dwSize = sizeof(vp2); + hr = IDirect3DViewport3_GetViewport2(viewport3, &vp2); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(vp2.dvClipX == -1.25f && vp2.dvClipY == -0.75f && vp2.dvClipWidth == 2.5f + && vp2.dvClipHeight == -1.5f && vp2.dvMinZ == 0.0f && vp2.dvMaxZ == 1.0f, + "Got unexpected values %g, %g, %g, %g, %g, %g.\n", + vp2.dvClipX, vp2.dvClipY, vp2.dvClipWidth, vp2.dvClipHeight, vp2.dvMinZ, vp2.dvMaxZ); + /* Destroying the device removes the viewport and releases the reference */ IDirect3DDevice3_Release(device); ref = get_refcount((IUnknown *) viewport3); ok(ref == 1, "Got unexpected refcount %u.\n", ref);
+ memset(&vp2, 0xff, sizeof(vp2)); + vp2.dwSize = sizeof(vp2); + hr = IDirect3DViewport3_GetViewport2(viewport3, &vp2); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(vp2.dvClipX == -1.25f && vp2.dvClipY == -0.75f && vp2.dvClipWidth == 2.5f + && vp2.dvClipHeight == -1.5f && vp2.dvMinZ == 0.0f && vp2.dvMaxZ == 1.0f, + "Got unexpected values %g, %g, %g, %g, %g, %g.\n", + vp2.dvClipX, vp2.dvClipY, vp2.dvClipWidth, vp2.dvClipHeight, vp2.dvMinZ, vp2.dvMaxZ); + vp.dwSize = sizeof(vp); hr = IDirect3DViewport3_SetViewport(viewport3, &vp); ok(hr == D3DERR_VIEWPORTHASNODEVICE, "Got unexpected hr %#x.\n", hr); diff --git a/dlls/ddraw/viewport.c b/dlls/ddraw/viewport.c index ceb5582524..0a06329a69 100644 --- a/dlls/ddraw/viewport.c +++ b/dlls/ddraw/viewport.c @@ -983,12 +983,13 @@ static HRESULT WINAPI d3d_viewport_GetViewport2(IDirect3DViewport3 *iface, D3DVI vp2.dwY = viewport->viewports.vp1.dwY; vp2.dwWidth = viewport->viewports.vp1.dwWidth; vp2.dwHeight = viewport->viewports.vp1.dwHeight; - vp2.dvClipX = 0.0f; - vp2.dvClipY = 0.0f; - vp2.dvClipWidth = 0.0f; - vp2.dvClipHeight = 0.0f; - vp2.dvMinZ = viewport->viewports.vp1.dvMinZ; - vp2.dvMaxZ = viewport->viewports.vp1.dvMaxZ; + + vp2.dvClipWidth = viewport->viewports.vp1.dwWidth / viewport->viewports.vp1.dvScaleX; + vp2.dvClipHeight = viewport->viewports.vp1.dwHeight / viewport->viewports.vp1.dvScaleY; + vp2.dvClipX = -vp2.dvClipWidth / 2.0f; + vp2.dvClipY = vp2.dvClipHeight / 2.0f; + vp2.dvMinZ = 0.0f; + vp2.dvMaxZ = 1.0f; memcpy(vp, &vp2, size); }