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)