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)