Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/d3drm/tests/d3drm.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c index 3beeaee007..9811224f46 100644 --- a/dlls/d3drm/tests/d3drm.c +++ b/dlls/d3drm/tests/d3drm.c @@ -1733,6 +1733,7 @@ static void test_Viewport(void) DWORD data, ref1, ref2, ref3, ref4; DWORD initial_ref1, initial_ref2, initial_ref3, device_ref, frame_ref, frame_ref2, viewport_ref;
+ /* Set up */ window = create_window(); GetClientRect(window, &rc);
@@ -1769,6 +1770,7 @@ static void test_Viewport(void) device_ref = get_refcount((IUnknown *)device1); frame_ref = get_refcount((IUnknown *)frame);
+ /* IDirect3DRM::CreateViewport tests */ hr = IDirect3DRM_CreateViewport(d3drm1, device1, frame, 0, 0, 0, 0, &viewport); ok(SUCCEEDED(hr), "Cannot get IDirect3DRMViewport interface (hr = %#x)\n", hr); ref4 = get_refcount((IUnknown *)d3drm1); @@ -1799,6 +1801,7 @@ static void test_Viewport(void) ref4 = get_refcount((IUnknown *)frame); ok(ref4 == frame_ref, "Expected ref4 == frame_ref, got frame_ref = %u, ref4 = %u.\n", frame_ref, ref4);
+ /* IDirect3DRM2::CreateViewport tests */ hr = IDirect3DRM2_CreateViewport(d3drm2, device1, frame, 0, 0, 0, 0, &viewport); ok(SUCCEEDED(hr), "Cannot get IDirect3DRMViewport interface (hr = %#x)\n", hr); ref4 = get_refcount((IUnknown *)d3drm1); @@ -1832,6 +1835,7 @@ static void test_Viewport(void) device_ref = get_refcount((IUnknown *)device3); frame_ref2 = get_refcount((IUnknown *)frame3);
+ /* IDirect3DRM3::CreateViewport tests */ hr = IDirect3DRM3_CreateViewport(d3drm3, device3, frame3, 0, 0, 0, 0, &viewport2); ok(SUCCEEDED(hr), "Cannot get IDirect3DRMViewport2 interface (hr = %#x)\n", hr); ref4 = get_refcount((IUnknown *)d3drm1); @@ -1862,7 +1866,7 @@ static void test_Viewport(void) ref4 = get_refcount((IUnknown *)frame3); ok(ref4 == frame_ref2, "Expected ref4 == frame_ref2, got frame_ref2 = %u, ref4 = %u.\n", frame_ref2, ref4);
- /* Test all failures together */ + /* IDirect3DRM::CreateViewport failure tests */ viewport = (IDirect3DRMViewport *)0xdeadbeef; hr = IDirect3DRM_CreateViewport(d3drm1, NULL, frame, rc.left, rc.top, rc.right, rc.bottom, &viewport); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); @@ -1886,6 +1890,7 @@ static void test_Viewport(void) hr = IDirect3DRM_CreateViewport(d3drm1, device1, frame, rc.left, rc.top, rc.right, rc.bottom, NULL); ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
+ /* IDirect3DRM2::CreateViewport failure tests */ viewport = (IDirect3DRMViewport *)0xdeadbeef; hr = IDirect3DRM2_CreateViewport(d3drm2, NULL, frame, rc.left, rc.top, rc.right, rc.bottom, &viewport); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); @@ -1909,6 +1914,7 @@ static void test_Viewport(void) hr = IDirect3DRM2_CreateViewport(d3drm2, device1, frame, rc.left, rc.top, rc.right, rc.bottom, NULL); ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
+ /* IDirect3DRM3::CreateViewport failure tests */ viewport2 = (IDirect3DRMViewport2 *)0xdeadbeef; hr = IDirect3DRM3_CreateViewport(d3drm3, NULL, frame3, rc.left, rc.top, rc.right, rc.bottom, &viewport2); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); @@ -1932,6 +1938,7 @@ static void test_Viewport(void) hr = IDirect3DRM3_CreateViewport(d3drm3, device3, frame3, rc.left, rc.top, rc.right, rc.bottom, NULL); ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
+ /* [IDirect3DRM2] IDirect3DRMViewport::GetDirect3DViewport tests */ hr = IDirect3DRM2_CreateViewport(d3drm2, device1, frame, rc.left, rc.top, rc.right, rc.bottom, &viewport); ok(hr == D3DRM_OK, "Cannot get IDirect3DRMViewport interface (hr = %#x)\n", hr); hr = IDirect3DRMViewport_GetDirect3DViewport(viewport, &d3d_viewport); @@ -1965,6 +1972,7 @@ static void test_Viewport(void) IDirect3DViewport_Release(d3d_viewport); IDirect3DRMViewport_Release(viewport);
+ /* [IDirect3DRM3] IDirect3DRMViewport2::GetDirect3DViewport tests */ hr = IDirect3DRM3_CreateViewport(d3drm3, device3, frame3, rc.left, rc.top, rc.right, rc.bottom, &viewport2); ok(hr == D3DRM_OK, "Cannot get IDirect3DRMViewport2 interface (hr = %#x)\n", hr); hr = IDirect3DRMViewport2_GetDirect3DViewport(viewport2, &d3d_viewport); @@ -1998,6 +2006,7 @@ static void test_Viewport(void) IDirect3DViewport_Release(d3d_viewport); IDirect3DRMViewport2_Release(viewport2);
+ /* [IDirect3DRM] IDirect3DRMViewport::GetDirect3DViewport tests */ hr = IDirect3DRM_CreateViewport(d3drm1, device1, frame, rc.left, rc.top, rc.right, rc.bottom, &viewport); ok(hr == D3DRM_OK, "Cannot get IDirect3DRMViewport interface (hr = %x)\n", hr); hr = IDirect3DRMViewport_GetDirect3DViewport(viewport, &d3d_viewport); @@ -2030,6 +2039,7 @@ static void test_Viewport(void) ok(vp.dvMaxY == expected_val, "Expected dvMaxY = %f, got %f.\n", expected_val, vp.dvMaxY); IDirect3DViewport_Release(d3d_viewport);
+ /* IDirect3DRMViewport*::QueryInterface tests */ hr = IDirect3DRMViewport_QueryInterface(viewport, &IID_IDirect3DRMObject, (void**)&obj); ok(hr == D3DRM_OK, "expected D3DRM_OK (hr = %x)\n", hr); ok((IDirect3DRMObject*)viewport == obj, "got object pointer %p, expected %p\n", obj, viewport); @@ -2070,7 +2080,7 @@ static void test_Viewport(void) IDirect3DRMViewport2_Release(viewport2); IDirect3DRMViewport_Release(viewport);
- /* IDirect3DRMViewport*::Init tests */ + /* IDirect3DRMViewport::Init tests ... */ ref1 = get_refcount((IUnknown *)d3drm1); ref2 = get_refcount((IUnknown *)d3drm2); ref3 = get_refcount((IUnknown *)d3drm3); @@ -2084,12 +2094,13 @@ static void test_Viewport(void) ref4 = get_refcount((IUnknown *)d3drm3); ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3, ref4);
+ /* ... test pre-Init return values */ hr = IDirect3DRMViewport_GetDirect3DViewport(viewport, &d3d_viewport); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); hr = IDirect3DRMViewport_GetDevice(viewport, &d3drm_device1); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
- /* Test all failures together */ + /* ... test Init failure */ hr = IDirect3DRMViewport_Init(viewport, NULL, frame, rc.left, rc.top, rc.right, rc.bottom); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); hr = IDirect3DRMViewport_Init(viewport, device1, NULL, rc.left, rc.top, rc.right, rc.bottom); @@ -2101,6 +2112,7 @@ static void test_Viewport(void) hr = IDirect3DRMViewport_Init(viewport, device1, frame, rc.left, rc.top, rc.right, rc.bottom + 1); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
+ /* ... test Init success */ device_ref = get_refcount((IUnknown *)device1); frame_ref = get_refcount((IUnknown *)frame); hr = IDirect3DRMViewport_Init(viewport, device1, frame, rc.left, rc.top, rc.right, rc.bottom); @@ -2116,6 +2128,7 @@ static void test_Viewport(void) ref4 = get_refcount((IUnknown *)frame); ok(ref4 > frame_ref, "Expected ref4 > frame_ref, got frame_ref = %u, ref4 = %u.\n", frame_ref, ref4);
+ /* ... test initialized values */ hr = IDirect3DRMViewport_GetDevice(viewport, &d3drm_device1); ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice3 interface (hr = %x)\n", hr); ok(device1 == d3drm_device1, "Expected device returned = %p, got %p.\n", device3, d3drm_device3); @@ -2151,6 +2164,7 @@ static void test_Viewport(void) ok(vp.dvMaxY == expected_val, "Expected dvMaxY = %f, got %f.\n", expected_val, vp.dvMaxY); IDirect3DViewport_Release(d3d_viewport);
+ /* ... test post-Init failures */ hr = IDirect3DRMViewport_Init(viewport, device1, frame, rc.left, rc.top, rc.right, rc.bottom); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); hr = IDirect3DRMViewport_GetDevice(viewport, NULL); @@ -2174,6 +2188,7 @@ static void test_Viewport(void) ref4 = get_refcount((IUnknown *)frame); todo_wine ok(ref4 > frame_ref, "Expected ref4 > frame_ref, got frame_ref = %u, ref4 = %u.\n", frame_ref, ref4);
+ /* IDirect3DRMViewport2::Init tests ... */ ref1 = get_refcount((IUnknown *)d3drm1); ref2 = get_refcount((IUnknown *)d3drm2); ref3 = get_refcount((IUnknown *)d3drm3); @@ -2187,11 +2202,13 @@ static void test_Viewport(void) ref4 = get_refcount((IUnknown *)d3drm3); ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3, ref4);
+ /* ... test pre-Init return values */ hr = IDirect3DRMViewport2_GetDirect3DViewport(viewport2, &d3d_viewport); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); hr = IDirect3DRMViewport2_GetDevice(viewport2, &d3drm_device3); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
+ /* ... test Init failure */ hr = IDirect3DRMViewport2_Init(viewport2, NULL, frame3, rc.left, rc.top, rc.right, rc.bottom); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); hr = IDirect3DRMViewport2_Init(viewport2, device3, NULL, rc.left, rc.top, rc.right, rc.bottom); @@ -2203,6 +2220,7 @@ static void test_Viewport(void) hr = IDirect3DRMViewport2_Init(viewport2, device3, frame3, rc.left, rc.top, rc.right, rc.bottom + 1); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
+ /* ... test Init success */ device_ref = get_refcount((IUnknown *)device3); frame_ref2 = get_refcount((IUnknown *)frame3); hr = IDirect3DRMViewport2_Init(viewport2, device3, frame3, rc.left, rc.top, rc.right, rc.bottom); @@ -2212,6 +2230,7 @@ static void test_Viewport(void) ref4 = get_refcount((IUnknown *)frame3); ok(ref4 > frame_ref2, "Expected ref4 > frame_ref2, got frame_ref2 = %u, ref4 = %u.\n", frame_ref2, ref4);
+ /* ... test initialized values */ hr = IDirect3DRMViewport2_GetDevice(viewport2, &d3drm_device3); ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice3 interface (hr = %x)\n", hr); ok(device3 == d3drm_device3, "Expected device returned = %p, got %p.\n", device3, d3drm_device3); @@ -2247,6 +2266,7 @@ static void test_Viewport(void) ok(vp.dvMaxY == expected_val, "Expected dvMaxY = %f, got %f.\n", expected_val, vp.dvMaxY); IDirect3DViewport_Release(d3d_viewport);
+ /* ... test post-Init failures */ hr = IDirect3DRMViewport2_Init(viewport2, device3, frame3, rc.left, rc.top, rc.right, rc.bottom); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); hr = IDirect3DRMViewport2_GetDevice(viewport2, NULL); @@ -2270,6 +2290,7 @@ static void test_Viewport(void) ref4 = get_refcount((IUnknown *)frame3); todo_wine ok(ref4 > frame_ref2, "Expected ref4 > frame_ref2, got frame_ref2 = %u, ref4 = %u.\n", frame_ref2, ref4);
+ /* Clean up */ IDirect3DRMDevice3_Release(device3); IDirect3DRMDevice_Release(device1); ref4 = get_refcount((IUnknown *)d3drm1);
Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/d3drm/tests/d3drm.c | 33 +++++++++++++++++++++++-- dlls/d3drm/viewport.c | 52 +++++++++++++++++++++++++++++++++------- 2 files changed, 75 insertions(+), 10 deletions(-)
diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c index 9811224f46..32204142a7 100644 --- a/dlls/d3drm/tests/d3drm.c +++ b/dlls/d3drm/tests/d3drm.c @@ -1719,8 +1719,8 @@ static void test_Viewport(void) IDirect3DRM3 *d3drm3; IDirect3DRMDevice *device1, *d3drm_device1; IDirect3DRMDevice3 *device3, *d3drm_device3; - IDirect3DRMFrame *frame; - IDirect3DRMFrame3 *frame3; + IDirect3DRMFrame *frame, *d3drm_frame; + IDirect3DRMFrame3 *frame3, *d3drm_frame3; IDirect3DRMViewport *viewport; IDirect3DRMViewport2 *viewport2; IDirect3DViewport *d3d_viewport; @@ -1789,6 +1789,11 @@ static void test_Viewport(void) ok(device1 == d3drm_device1, "Expected device returned = %p, got %p.\n", device1, d3drm_device1); IDirect3DRMDevice_Release(d3drm_device1);
+ hr = IDirect3DRMViewport_GetCamera(viewport, &d3drm_frame); + ok(SUCCEEDED(hr), "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr); + ok(frame == d3drm_frame, "Expected frame returned = %p, got %p.\n", frame, d3drm_frame); + IDirect3DRMFrame_Release(d3drm_frame); + IDirect3DRMViewport_Release(viewport); ref4 = get_refcount((IUnknown *)d3drm1); ok(ref4 == ref1, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4); @@ -1820,6 +1825,11 @@ static void test_Viewport(void) ok(device1 == d3drm_device1, "Expected device returned = %p, got %p.\n", device1, d3drm_device1); IDirect3DRMDevice_Release(d3drm_device1);
+ hr = IDirect3DRMViewport_GetCamera(viewport, &d3drm_frame); + ok(SUCCEEDED(hr), "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr); + ok(frame == d3drm_frame, "Expected frame returned = %p, got %p.\n", frame, d3drm_frame); + IDirect3DRMFrame_Release(d3drm_frame); + IDirect3DRMViewport_Release(viewport); ref4 = get_refcount((IUnknown *)d3drm1); ok(ref4 == ref1, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4); @@ -1854,6 +1864,11 @@ static void test_Viewport(void) ok(device3 == d3drm_device3, "Expected device returned = %p, got %p.\n", device3, d3drm_device3); IDirect3DRMDevice3_Release(d3drm_device3);
+ hr = IDirect3DRMViewport2_GetCamera(viewport2, &d3drm_frame3); + ok(SUCCEEDED(hr), "Cannot get IDirect3DRMFrame3 interface (hr = %x)\n", hr); + ok(frame3 == d3drm_frame3, "Expected frame returned = %p, got %p.\n", frame3, d3drm_frame3); + IDirect3DRMFrame3_Release(d3drm_frame3); + IDirect3DRMViewport2_Release(viewport2); ref4 = get_refcount((IUnknown *)d3drm1); ok(ref4 == ref1, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4); @@ -2099,6 +2114,11 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); hr = IDirect3DRMViewport_GetDevice(viewport, &d3drm_device1); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); + hr = IDirect3DRMViewport_GetCamera(viewport, &d3drm_frame); + ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); + + hr = IDirect3DRMViewport_SetCamera(viewport, frame); + ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
/* ... test Init failure */ hr = IDirect3DRMViewport_Init(viewport, NULL, frame, rc.left, rc.top, rc.right, rc.bottom); @@ -2171,6 +2191,8 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); hr = IDirect3DRMViewport_GetDirect3DViewport(viewport, NULL); ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); + hr = IDirect3DRMViewport_GetCamera(viewport, NULL); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); hr = IDirect3DRMViewport_SetField(viewport, 0.0f); ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); hr = IDirect3DRMViewport_SetField(viewport, -1.0f); @@ -2207,6 +2229,11 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); hr = IDirect3DRMViewport2_GetDevice(viewport2, &d3drm_device3); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); + hr = IDirect3DRMViewport2_GetCamera(viewport2, &d3drm_frame3); + ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); + + hr = IDirect3DRMViewport2_SetCamera(viewport2, frame3); + ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
/* ... test Init failure */ hr = IDirect3DRMViewport2_Init(viewport2, NULL, frame3, rc.left, rc.top, rc.right, rc.bottom); @@ -2273,6 +2300,8 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); hr = IDirect3DRMViewport2_GetDirect3DViewport(viewport2, NULL); ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); + hr = IDirect3DRMViewport2_GetCamera(viewport2, NULL); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); hr = IDirect3DRMViewport2_SetField(viewport2, 0.0f); ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); hr = IDirect3DRMViewport2_SetField(viewport2, -1.0f); diff --git a/dlls/d3drm/viewport.c b/dlls/d3drm/viewport.c index c2fa189742..a6ad4ea595 100644 --- a/dlls/d3drm/viewport.c +++ b/dlls/d3drm/viewport.c @@ -556,16 +556,29 @@ static HRESULT WINAPI d3drm_viewport1_SetUniformScaling(IDirect3DRMViewport *ifa
static HRESULT WINAPI d3drm_viewport2_SetCamera(IDirect3DRMViewport2 *iface, IDirect3DRMFrame3 *camera) { - FIXME("iface %p, camera %p stub!\n", iface, camera); + struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface); + HRESULT hr;
- return E_NOTIMPL; + TRACE("iface %p, camera %p.\n", iface, camera); + + if (!viewport->camera) + return D3DRMERR_BADOBJECT; + + IDirect3DRMFrame_Release(viewport->camera); + if (FAILED(hr = IDirect3DRMFrame3_QueryInterface(camera, &IID_IDirect3DRMFrame, (void **)&viewport->camera))) + return hr; + + return D3DRM_OK; }
static HRESULT WINAPI d3drm_viewport1_SetCamera(IDirect3DRMViewport *iface, IDirect3DRMFrame *camera) { - FIXME("iface %p, camera %p stub!\n", iface, camera); + struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface); + struct d3drm_frame *frame = unsafe_impl_from_IDirect3DRMFrame(camera);
- return E_NOTIMPL; + TRACE("iface %p, camera %p.\n", iface, camera); + + return d3drm_viewport2_SetCamera(&viewport->IDirect3DRMViewport2_iface, &frame->IDirect3DRMFrame3_iface); }
static HRESULT WINAPI d3drm_viewport2_SetProjection(IDirect3DRMViewport2 *iface, D3DRMPROJECTIONTYPE type) @@ -668,16 +681,39 @@ static HRESULT WINAPI d3drm_viewport1_SetPlane(IDirect3DRMViewport *iface,
static HRESULT WINAPI d3drm_viewport2_GetCamera(IDirect3DRMViewport2 *iface, IDirect3DRMFrame3 **camera) { - FIXME("iface %p, camera %p stub!\n", iface, camera); + struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface); + HRESULT hr;
- return E_NOTIMPL; + TRACE("iface %p, camera %p.\n", iface, camera); + + if (!camera) + return D3DRMERR_BADVALUE; + + if (!viewport->camera) + return D3DRMERR_BADOBJECT; + + if (FAILED(hr = IDirect3DRMFrame_QueryInterface(viewport->camera, &IID_IDirect3DRMFrame3, (void **)camera))) + return hr; + + return D3DRM_OK; }
static HRESULT WINAPI d3drm_viewport1_GetCamera(IDirect3DRMViewport *iface, IDirect3DRMFrame **camera) { - FIXME("iface %p, camera %p stub!\n", iface, camera); + struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
- return E_NOTIMPL; + TRACE("iface %p, camera %p.\n", iface, camera); + + if (!camera) + return D3DRMERR_BADVALUE; + + if (!viewport->camera) + return D3DRMERR_BADOBJECT; + + *camera = viewport->camera; + IDirect3DRMFrame_AddRef(*camera); + + return D3DRM_OK; }
static HRESULT WINAPI d3drm_viewport2_GetDevice(IDirect3DRMViewport2 *iface, IDirect3DRMDevice3 **device)
The 'field' value is now expressed in terms of the plane values.
Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/d3drm/d3drm_private.h | 5 ++- dlls/d3drm/tests/d3drm.c | 84 +++++++++++++++++++++++++++++++++++++- dlls/d3drm/viewport.c | 59 +++++++++++++++++++++----- 3 files changed, 136 insertions(+), 12 deletions(-)
diff --git a/dlls/d3drm/d3drm_private.h b/dlls/d3drm/d3drm_private.h index dcda35fb08..1c829f6130 100644 --- a/dlls/d3drm/d3drm_private.h +++ b/dlls/d3drm/d3drm_private.h @@ -101,7 +101,10 @@ struct d3drm_viewport IDirect3DRM *d3drm; D3DVALUE back; D3DVALUE front; - D3DVALUE field; + D3DVALUE plane_left; + D3DVALUE plane_right; + D3DVALUE plane_bottom; + D3DVALUE plane_top; D3DRMPROJECTIONTYPE projection; };
diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c index 32204142a7..f1fd55252c 100644 --- a/dlls/d3drm/tests/d3drm.c +++ b/dlls/d3drm/tests/d3drm.c @@ -1725,7 +1725,7 @@ static void test_Viewport(void) IDirect3DRMViewport2 *viewport2; IDirect3DViewport *d3d_viewport; D3DVIEWPORT vp; - D3DVALUE expected_val; + D3DVALUE expected_val, val1, val2, val3, val4; IDirect3DRMObject *obj, *obj2; GUID driver; HWND window; @@ -2116,9 +2116,17 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); hr = IDirect3DRMViewport_GetCamera(viewport, &d3drm_frame); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); + val1 = IDirect3DRMViewport_GetField(viewport); + ok(-1.0f == val1, "Expected viewport field = %f, got %f.\n", -1.0f, val1); + hr = IDirect3DRMViewport_GetPlane(viewport, &val1, &val2, &val3, &val4); + ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
hr = IDirect3DRMViewport_SetCamera(viewport, frame); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); + hr = IDirect3DRMViewport_SetField(viewport, 0.5f); + ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); + hr = IDirect3DRMViewport_SetPlane(viewport, -0.5f, 0.5f, -0.5f, 0.5f); + ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
/* ... test Init failure */ hr = IDirect3DRMViewport_Init(viewport, NULL, frame, rc.left, rc.top, rc.right, rc.bottom); @@ -2184,6 +2192,39 @@ static void test_Viewport(void) ok(vp.dvMaxY == expected_val, "Expected dvMaxY = %f, got %f.\n", expected_val, vp.dvMaxY); IDirect3DViewport_Release(d3d_viewport);
+ expected_val = 0.5f; + val1 = IDirect3DRMViewport_GetField(viewport); + ok(expected_val == val1, "Expected viewport field = %f, got %f.\n", expected_val, val1); + hr = IDirect3DRMViewport_GetPlane(viewport, &val1, &val2, &val3, &val4); + ok(SUCCEEDED(hr), "Cannot get viewport plane values (hr = %#x).\n", hr); + ok(-expected_val == val1, "Expected viewport plane left = %f, got %f.\n", -expected_val, val1); + ok(expected_val == val2, "Expected viewport plane right = %f, got %f.\n", expected_val, val2); + ok(-expected_val == val3, "Expected viewport plane bottom = %f, got %f.\n", -expected_val, val3); + ok(expected_val == val4, "Expected viewport plane top = %f, got %f.\n", expected_val, val4); + + /* ... test setters */ + hr = IDirect3DRMViewport_SetField(viewport, 1.0f); + ok(SUCCEEDED(hr), "Cannot set viewport field (hr = %#x).\n", hr); + expected_val = 1.0f; + val1 = IDirect3DRMViewport_GetField(viewport); + ok(expected_val == val1, "Expected viewport field = %f, got %f.\n", expected_val, val1); + hr = IDirect3DRMViewport_GetPlane(viewport, &val1, &val2, &val3, &val4); + ok(SUCCEEDED(hr), "Cannot get viewport plane values (hr = %#x).\n", hr); + ok(-expected_val == val1, "Expected viewport plane left = %f, got %f.\n", -expected_val, val1); + ok(expected_val == val2, "Expected viewport plane right = %f, got %f.\n", expected_val, val2); + ok(-expected_val == val3, "Expected viewport plane bottom = %f, got %f.\n", -expected_val, val3); + ok(expected_val == val4, "Expected viewport plane top = %f, got %f.\n", expected_val, val4); + hr = IDirect3DRMViewport_SetPlane(viewport, 5.0f, 3.0f, 2.0f, 0.0f); + ok(SUCCEEDED(hr), "Cannot set viewport plane (hr = %#x).\n", hr); + val1 = IDirect3DRMViewport_GetField(viewport); + ok(-1.0f == val1, "Expected viewport field = %f, got %f.\n", -1.0f, val1); + hr = IDirect3DRMViewport_GetPlane(viewport, &val1, &val2, &val3, &val4); + ok(SUCCEEDED(hr), "Cannot get viewport plane values (hr = %#x).\n", hr); + ok(5.0f == val1, "Expected viewport plane left = %f, got %f.\n", 5.0f, val1); + ok(3.0f == val2, "Expected viewport plane right = %f, got %f.\n", 3.0f, val2); + ok(2.0f == val3, "Expected viewport plane bottom = %f, got %f.\n", 2.0f, val3); + ok(0.0f == val4, "Expected viewport plane top = %f, got %f.\n", 0.0f, val4); + /* ... test post-Init failures */ hr = IDirect3DRMViewport_Init(viewport, device1, frame, rc.left, rc.top, rc.right, rc.bottom); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); @@ -2231,9 +2272,17 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); hr = IDirect3DRMViewport2_GetCamera(viewport2, &d3drm_frame3); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); + val1 = IDirect3DRMViewport2_GetField(viewport2); + ok(-1.0f == val1, "Expected viewport field = %f, got %f.\n", -1.0f, val1); + hr = IDirect3DRMViewport2_GetPlane(viewport2, &val1, &val2, &val3, &val4); + ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
hr = IDirect3DRMViewport2_SetCamera(viewport2, frame3); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); + hr = IDirect3DRMViewport2_SetField(viewport2, 0.5f); + ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); + hr = IDirect3DRMViewport2_SetPlane(viewport2, -0.5f, 0.5f, -0.5f, 0.5f); + ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
/* ... test Init failure */ hr = IDirect3DRMViewport2_Init(viewport2, NULL, frame3, rc.left, rc.top, rc.right, rc.bottom); @@ -2293,6 +2342,39 @@ static void test_Viewport(void) ok(vp.dvMaxY == expected_val, "Expected dvMaxY = %f, got %f.\n", expected_val, vp.dvMaxY); IDirect3DViewport_Release(d3d_viewport);
+ expected_val = 0.5f; + val1 = IDirect3DRMViewport2_GetField(viewport2); + ok(expected_val == val1, "Expected viewport field = %f, got %f.\n", expected_val, val1); + hr = IDirect3DRMViewport2_GetPlane(viewport2, &val1, &val2, &val3, &val4); + ok(SUCCEEDED(hr), "Cannot get viewport plane values (hr = %#x).\n", hr); + ok(-expected_val == val1, "Expected viewport plane left = %f, got %f.\n", -expected_val, val1); + ok(expected_val == val2, "Expected viewport plane right = %f, got %f.\n", expected_val, val2); + ok(-expected_val == val3, "Expected viewport plane bottom = %f, got %f.\n", -expected_val, val3); + ok(expected_val == val4, "Expected viewport plane top = %f, got %f.\n", expected_val, val4); + + /* ... test setters */ + hr = IDirect3DRMViewport2_SetField(viewport2, 1.0f); + ok(SUCCEEDED(hr), "Cannot set viewport field (hr = %#x).\n", hr); + expected_val = 1.0f; + val1 = IDirect3DRMViewport2_GetField(viewport2); + ok(expected_val == val1, "Expected viewport field = %f, got %f.\n", expected_val, val1); + hr = IDirect3DRMViewport2_GetPlane(viewport2, &val1, &val2, &val3, &val4); + ok(SUCCEEDED(hr), "Cannot get viewport plane values (hr = %#x).\n", hr); + ok(-expected_val == val1, "Expected viewport plane left = %f, got %f.\n", -expected_val, val1); + ok(expected_val == val2, "Expected viewport plane right = %f, got %f.\n", expected_val, val2); + ok(-expected_val == val3, "Expected viewport plane bottom = %f, got %f.\n", -expected_val, val3); + ok(expected_val == val4, "Expected viewport plane top = %f, got %f.\n", expected_val, val4); + hr = IDirect3DRMViewport2_SetPlane(viewport2, 5.0f, 3.0f, 2.0f, 0.0f); + ok(SUCCEEDED(hr), "Cannot set viewport plane (hr = %#x).\n", hr); + val1 = IDirect3DRMViewport2_GetField(viewport2); + ok(-1.0f == val1, "Expected viewport field = %f, got %f.\n", -1.0f, val1); + hr = IDirect3DRMViewport2_GetPlane(viewport2, &val1, &val2, &val3, &val4); + ok(SUCCEEDED(hr), "Cannot get viewport plane values (hr = %#x).\n", hr); + ok(5.0f == val1, "Expected viewport plane left = %f, got %f.\n", 5.0f, val1); + ok(3.0f == val2, "Expected viewport plane right = %f, got %f.\n", 3.0f, val2); + ok(2.0f == val3, "Expected viewport plane bottom = %f, got %f.\n", 2.0f, val3); + ok(0.0f == val4, "Expected viewport plane top = %f, got %f.\n", 0.0f, val4); + /* ... test post-Init failures */ hr = IDirect3DRMViewport2_Init(viewport2, device3, frame3, rc.left, rc.top, rc.right, rc.bottom); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); diff --git a/dlls/d3drm/viewport.c b/dlls/d3drm/viewport.c index a6ad4ea595..5418b068f2 100644 --- a/dlls/d3drm/viewport.c +++ b/dlls/d3drm/viewport.c @@ -369,6 +369,11 @@ static HRESULT WINAPI d3drm_viewport2_Init(IDirect3DRMViewport2 *iface, IDirect3 viewport->material = material; viewport->device = device_obj;
+ viewport->plane_left = -0.5f; + viewport->plane_right = 0.5f; + viewport->plane_bottom = -0.5f; + viewport->plane_top = 0.5f; + cleanup:
if (FAILED(hr)) @@ -523,10 +528,16 @@ static HRESULT WINAPI d3drm_viewport2_SetField(IDirect3DRMViewport2 *iface, D3DV
TRACE("iface %p, field %.8e.\n", iface, field);
+ if (!viewport->d3d_viewport) + return D3DRMERR_BADOBJECT; + if (field <= 0.0f) return D3DRMERR_BADVALUE;
- viewport->field = field; + viewport->plane_left = -field; + viewport->plane_right = field; + viewport->plane_bottom = -field; + viewport->plane_top = field;
return D3DRM_OK; } @@ -664,19 +675,31 @@ static HRESULT WINAPI d3drm_viewport1_ForceUpdate(IDirect3DRMViewport *iface, static HRESULT WINAPI d3drm_viewport2_SetPlane(IDirect3DRMViewport2 *iface, D3DVALUE left, D3DVALUE right, D3DVALUE bottom, D3DVALUE top) { - FIXME("iface %p, left %.8e, right %.8e, bottom %.8e, top %.8e stub!\n", + struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface); + + TRACE("iface %p, left %.8e, right %.8e, bottom %.8e, top %.8e.\n", iface, left, right, bottom, top);
- return E_NOTIMPL; + if (!viewport->d3d_viewport) + return D3DRMERR_BADOBJECT; + + viewport->plane_left = left; + viewport->plane_right = right; + viewport->plane_bottom = bottom; + viewport->plane_top = top; + + return D3DRM_OK; }
static HRESULT WINAPI d3drm_viewport1_SetPlane(IDirect3DRMViewport *iface, D3DVALUE left, D3DVALUE right, D3DVALUE bottom, D3DVALUE top) { - FIXME("iface %p, left %.8e, right %.8e, bottom %.8e, top %.8e stub!\n", + struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface); + + TRACE("iface %p, left %.8e, right %.8e, bottom %.8e, top %.8e.\n", iface, left, right, bottom, top);
- return E_NOTIMPL; + return d3drm_viewport2_SetPlane(&viewport->IDirect3DRMViewport2_iface, left, right, bottom, top); }
static HRESULT WINAPI d3drm_viewport2_GetCamera(IDirect3DRMViewport2 *iface, IDirect3DRMFrame3 **camera) @@ -755,19 +778,31 @@ static HRESULT WINAPI d3drm_viewport1_GetDevice(IDirect3DRMViewport *iface, IDir static HRESULT WINAPI d3drm_viewport2_GetPlane(IDirect3DRMViewport2 *iface, D3DVALUE *left, D3DVALUE *right, D3DVALUE *bottom, D3DVALUE *top) { - FIXME("iface %p, left %p, right %p, bottom %p, top %p stub!\n", + struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface); + + TRACE("iface %p, left %p, right %p, bottom %p, top %p.\n", iface, left, right, bottom, top);
- return E_NOTIMPL; + if (!viewport->d3d_viewport) + return D3DRMERR_BADOBJECT; + + *left = viewport->plane_left; + *right = viewport->plane_right; + *bottom = viewport->plane_bottom; + *top = viewport->plane_top; + + return D3DRM_OK; }
static HRESULT WINAPI d3drm_viewport1_GetPlane(IDirect3DRMViewport *iface, D3DVALUE *left, D3DVALUE *right, D3DVALUE *bottom, D3DVALUE *top) { - FIXME("iface %p, left %p, right %p, bottom %p, top %p stub!\n", + struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface); + + TRACE("iface %p, left %p, right %p, bottom %p, top %p.\n", iface, left, right, bottom, top);
- return E_NOTIMPL; + return d3drm_viewport2_GetPlane(&viewport->IDirect3DRMViewport2_iface, left, right, bottom, top); }
static HRESULT WINAPI d3drm_viewport2_Pick(IDirect3DRMViewport2 *iface, @@ -862,7 +897,11 @@ static D3DVALUE WINAPI d3drm_viewport2_GetField(IDirect3DRMViewport2 *iface)
TRACE("iface %p.\n", iface);
- return viewport->field; + if (!viewport->d3d_viewport) + return -1.0f; + + return (viewport->plane_right - viewport->plane_left + + viewport->plane_top - viewport->plane_bottom) / 4.0f; }
static D3DVALUE WINAPI d3drm_viewport1_GetField(IDirect3DRMViewport *iface)
Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/d3drm/tests/d3drm.c | 58 ++++++++++++++++++++++++++++++++++++++++ dlls/d3drm/viewport.c | 19 +++++++++++-- 2 files changed, 75 insertions(+), 2 deletions(-)
diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c index f1fd55252c..2bd182b60a 100644 --- a/dlls/d3drm/tests/d3drm.c +++ b/dlls/d3drm/tests/d3drm.c @@ -2120,6 +2120,10 @@ static void test_Viewport(void) ok(-1.0f == val1, "Expected viewport field = %f, got %f.\n", -1.0f, val1); hr = IDirect3DRMViewport_GetPlane(viewport, &val1, &val2, &val3, &val4); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); + val1 = IDirect3DRMViewport_GetFront(viewport); + ok(-1.0f == val1, "Expected viewport front clipping plane = %f, got %f.\n", -1.0f, val1); + val1 = IDirect3DRMViewport_GetBack(viewport); + ok(-1.0f == val1, "Expected viewport back clipping plane = %f, got %f.\n", -1.0f, val1);
hr = IDirect3DRMViewport_SetCamera(viewport, frame); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); @@ -2127,6 +2131,10 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); hr = IDirect3DRMViewport_SetPlane(viewport, -0.5f, 0.5f, -0.5f, 0.5f); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); + hr = IDirect3DRMViewport_SetFront(viewport, 1.0f); + ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); + hr = IDirect3DRMViewport_SetBack(viewport, 100.0f); + ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
/* ... test Init failure */ hr = IDirect3DRMViewport_Init(viewport, NULL, frame, rc.left, rc.top, rc.right, rc.bottom); @@ -2201,6 +2209,10 @@ static void test_Viewport(void) ok(expected_val == val2, "Expected viewport plane right = %f, got %f.\n", expected_val, val2); ok(-expected_val == val3, "Expected viewport plane bottom = %f, got %f.\n", -expected_val, val3); ok(expected_val == val4, "Expected viewport plane top = %f, got %f.\n", expected_val, val4); + val1 = IDirect3DRMViewport_GetFront(viewport); + ok(1.0f == val1, "Expected viewport front clipping plane distance = %f, got %f.\n", 1.0f, val1); + val1 = IDirect3DRMViewport_GetBack(viewport); + ok(100.0f == val1, "Expected viewport back clipping plane distance = %f, got %f.\n", 100.0f, val1);
/* ... test setters */ hr = IDirect3DRMViewport_SetField(viewport, 1.0f); @@ -2224,6 +2236,14 @@ static void test_Viewport(void) ok(3.0f == val2, "Expected viewport plane right = %f, got %f.\n", 3.0f, val2); ok(2.0f == val3, "Expected viewport plane bottom = %f, got %f.\n", 2.0f, val3); ok(0.0f == val4, "Expected viewport plane top = %f, got %f.\n", 0.0f, val4); + hr = IDirect3DRMViewport_SetFront(viewport, 2.0f); + ok(SUCCEEDED(hr), "Cannot set viewport front clipping plane distance (hr = %#x).\n", hr); + val1 = IDirect3DRMViewport_GetFront(viewport); + ok(2.0f == val1, "Expected viewport front clipping plane distance = %f, got %f.\n", 2.0f, val1); + hr = IDirect3DRMViewport_SetBack(viewport, 200.0f); + ok(SUCCEEDED(hr), "Cannot set viewport back clipping plane distance (hr = %#x).\n", hr); + val1 = IDirect3DRMViewport_GetBack(viewport); + ok(200.0f == val1, "Expected viewport back clipping plane distance = %f, got %f.\n", 200.0f, val1);
/* ... test post-Init failures */ hr = IDirect3DRMViewport_Init(viewport, device1, frame, rc.left, rc.top, rc.right, rc.bottom); @@ -2238,6 +2258,15 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); hr = IDirect3DRMViewport_SetField(viewport, -1.0f); ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); + hr = IDirect3DRMViewport_SetFront(viewport, 0.0f); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); + hr = IDirect3DRMViewport_SetFront(viewport, -1.0f); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); + val1 = IDirect3DRMViewport_GetFront(viewport); + hr = IDirect3DRMViewport_SetBack(viewport, val1); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); + hr = IDirect3DRMViewport_SetBack(viewport, val1 / 2.0f); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
IDirect3DRMViewport_Release(viewport); ref4 = get_refcount((IUnknown *)d3drm1); @@ -2276,6 +2305,10 @@ static void test_Viewport(void) ok(-1.0f == val1, "Expected viewport field = %f, got %f.\n", -1.0f, val1); hr = IDirect3DRMViewport2_GetPlane(viewport2, &val1, &val2, &val3, &val4); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); + val1 = IDirect3DRMViewport2_GetFront(viewport2); + ok(-1.0f == val1, "Expected viewport front clipping plane = %f, got %f.\n", -1.0f, val1); + val1 = IDirect3DRMViewport2_GetBack(viewport2); + ok(-1.0f == val1, "Expected viewport back clipping plane = %f, got %f.\n", -1.0f, val1);
hr = IDirect3DRMViewport2_SetCamera(viewport2, frame3); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); @@ -2283,6 +2316,10 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); hr = IDirect3DRMViewport2_SetPlane(viewport2, -0.5f, 0.5f, -0.5f, 0.5f); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); + hr = IDirect3DRMViewport2_SetFront(viewport2, 1.0f); + ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); + hr = IDirect3DRMViewport2_SetBack(viewport2, 100.0f); + ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
/* ... test Init failure */ hr = IDirect3DRMViewport2_Init(viewport2, NULL, frame3, rc.left, rc.top, rc.right, rc.bottom); @@ -2351,6 +2388,10 @@ static void test_Viewport(void) ok(expected_val == val2, "Expected viewport plane right = %f, got %f.\n", expected_val, val2); ok(-expected_val == val3, "Expected viewport plane bottom = %f, got %f.\n", -expected_val, val3); ok(expected_val == val4, "Expected viewport plane top = %f, got %f.\n", expected_val, val4); + val1 = IDirect3DRMViewport2_GetFront(viewport2); + ok(1.0f == val1, "Expected viewport front clipping plane distance = %f, got %f.\n", 1.0f, val1); + val1 = IDirect3DRMViewport2_GetBack(viewport2); + ok(100.0f == val1, "Expected viewport back clipping plane distance = %f, got %f.\n", 100.0f, val1);
/* ... test setters */ hr = IDirect3DRMViewport2_SetField(viewport2, 1.0f); @@ -2374,6 +2415,14 @@ static void test_Viewport(void) ok(3.0f == val2, "Expected viewport plane right = %f, got %f.\n", 3.0f, val2); ok(2.0f == val3, "Expected viewport plane bottom = %f, got %f.\n", 2.0f, val3); ok(0.0f == val4, "Expected viewport plane top = %f, got %f.\n", 0.0f, val4); + hr = IDirect3DRMViewport2_SetFront(viewport2, 2.0f); + ok(SUCCEEDED(hr), "Cannot set viewport front clipping plane distance (hr = %#x).\n", hr); + val1 = IDirect3DRMViewport2_GetFront(viewport2); + ok(2.0f == val1, "Expected viewport front clipping plane distance = %f, got %f.\n", 2.0f, val1); + hr = IDirect3DRMViewport2_SetBack(viewport2, 200.0f); + ok(SUCCEEDED(hr), "Cannot set viewport back clipping plane distance (hr = %#x).\n", hr); + val1 = IDirect3DRMViewport2_GetBack(viewport2); + ok(200.0f == val1, "Expected viewport back clipping plane distance = %f, got %f.\n", 200.0f, val1);
/* ... test post-Init failures */ hr = IDirect3DRMViewport2_Init(viewport2, device3, frame3, rc.left, rc.top, rc.right, rc.bottom); @@ -2388,6 +2437,15 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); hr = IDirect3DRMViewport2_SetField(viewport2, -1.0f); ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); + hr = IDirect3DRMViewport2_SetFront(viewport2, 0.0f); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); + hr = IDirect3DRMViewport2_SetFront(viewport2, -1.0f); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); + val1 = IDirect3DRMViewport2_GetFront(viewport2); + hr = IDirect3DRMViewport2_SetBack(viewport2, val1); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); + hr = IDirect3DRMViewport2_SetBack(viewport2, val1 / 2.0f); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
IDirect3DRMViewport2_Release(viewport2); ref4 = get_refcount((IUnknown *)d3drm1); diff --git a/dlls/d3drm/viewport.c b/dlls/d3drm/viewport.c index 5418b068f2..0cb834efc7 100644 --- a/dlls/d3drm/viewport.c +++ b/dlls/d3drm/viewport.c @@ -374,6 +374,9 @@ static HRESULT WINAPI d3drm_viewport2_Init(IDirect3DRMViewport2 *iface, IDirect3 viewport->plane_bottom = -0.5f; viewport->plane_top = 0.5f;
+ viewport->front = 1.0f; + viewport->back = 100.0f; + cleanup:
if (FAILED(hr)) @@ -488,6 +491,12 @@ static HRESULT WINAPI d3drm_viewport2_SetFront(IDirect3DRMViewport2 *iface, D3DV
TRACE("iface %p, front %.8e.\n", iface, front);
+ if (!viewport->d3d_viewport) + return D3DRMERR_BADOBJECT; + + if (front <= 0.0f) + return D3DRMERR_BADVALUE; + viewport->front = front;
return D3DRM_OK; @@ -508,6 +517,12 @@ static HRESULT WINAPI d3drm_viewport2_SetBack(IDirect3DRMViewport2 *iface, D3DVA
TRACE("iface %p, back %.8e.\n", iface, back);
+ if (!viewport->d3d_viewport) + return D3DRMERR_BADOBJECT; + + if (back <= viewport->front) + return D3DRMERR_BADVALUE; + viewport->back = back;
return D3DRM_OK; @@ -919,7 +934,7 @@ static D3DVALUE WINAPI d3drm_viewport2_GetBack(IDirect3DRMViewport2 *iface)
TRACE("iface %p.\n", iface);
- return viewport->back; + return (viewport->d3d_viewport) ? viewport->back : -1.0f; }
static D3DVALUE WINAPI d3drm_viewport1_GetBack(IDirect3DRMViewport *iface) @@ -937,7 +952,7 @@ static D3DVALUE WINAPI d3drm_viewport2_GetFront(IDirect3DRMViewport2 *iface)
TRACE("iface %p.\n", iface);
- return viewport->front; + return (viewport->d3d_viewport) ? viewport->front : -1.0f; }
static D3DVALUE WINAPI d3drm_viewport1_GetFront(IDirect3DRMViewport *iface)