Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ddraw/tests/ddraw7.c | 167 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+)
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 69eba24f99..eccaf86190 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -16208,6 +16208,172 @@ static void test_transform_state(void) DestroyWindow(window); }
+static void test_viewport_state(void) +{ + D3DVIEWPORT7 vp1 = {10, 10, 16, 16, 0.0f, 0.0f}, vp2 = {20, 20, 32, 32, 1.0f, 1.0f}, ret_vp; + IDirect3DDevice7 *device; + DWORD stateblock; + ULONG refcount; + HWND window; + HRESULT hr; + + window = create_window(); + if (!(device = create_device(window, DDSCL_NORMAL))) + { + skip("Failed to create 3D device.\n"); + DestroyWindow(window); + return; + } + + hr = IDirect3DDevice7_GetViewport(device, &ret_vp); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(ret_vp.dwX == 0, "Got unexpected dwX %u.\n", ret_vp.dwX); + ok(ret_vp.dwY == 0, "Got unexpected dwY %u.\n", ret_vp.dwY); + ok(ret_vp.dwWidth == 640, "Got unexpected dwWidth %u.\n", ret_vp.dwWidth); + ok(ret_vp.dwHeight == 480, "Got unexpected dwHeight %u.\n", ret_vp.dwHeight); + ok(ret_vp.dvMinZ == 0.0f, "Got unexpected dvMinZ %.8e.\n", ret_vp.dvMinZ); + ok(ret_vp.dvMaxZ == 1.0f, "Got unexpected dvMaxZ %.8e.\n", ret_vp.dvMaxZ); + + hr = IDirect3DDevice7_SetViewport(device, &vp1); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetViewport(device, &ret_vp); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&ret_vp, &vp1, sizeof(vp1)), "Got unexpected viewport.\n"); + + /* Recorded stateblock. */ + + hr = IDirect3DDevice7_BeginStateBlock(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetViewport(device, &vp2); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_EndStateBlock(device, &stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetViewport(device, &ret_vp); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&ret_vp, &vp1, sizeof(vp1)), "Got unexpected viewport.\n"); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetViewport(device, &ret_vp); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&ret_vp, &vp2, sizeof(vp2)), "Got unexpected viewport.\n"); + + hr = IDirect3DDevice7_SetViewport(device, &vp1); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetViewport(device, &vp2); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetViewport(device, &ret_vp); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&ret_vp, &vp1, sizeof(vp1)), "Got unexpected viewport.\n"); + + /* Predefined stateblock, D3DSBT_ALL. */ + + hr = IDirect3DDevice7_CreateStateBlock(device, D3DSBT_ALL, &stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetViewport(device, &vp2); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetViewport(device, &ret_vp); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&ret_vp, &vp1, sizeof(vp1)), "Got unexpected viewport.\n"); + + hr = IDirect3DDevice7_SetViewport(device, &vp2); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetViewport(device, &vp1); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetViewport(device, &ret_vp); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&ret_vp, &vp2, sizeof(vp2)), "Got unexpected viewport.\n"); + + hr = IDirect3DDevice7_SetViewport(device, &vp1); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + /* Predefined stateblock, D3DSBT_VERTEXSTATE. */ + + hr = IDirect3DDevice7_CreateStateBlock(device, D3DSBT_VERTEXSTATE, &stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetViewport(device, &vp2); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetViewport(device, &ret_vp); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&ret_vp, &vp2, sizeof(vp2)), "Got unexpected viewport.\n"); + + hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetViewport(device, &vp1); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetViewport(device, &ret_vp); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&ret_vp, &vp1, sizeof(vp1)), "Got unexpected viewport.\n"); + + /* Predefined stateblock, D3DSBT_PIXELSTATE. */ + + hr = IDirect3DDevice7_CreateStateBlock(device, D3DSBT_PIXELSTATE, &stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetViewport(device, &vp2); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetViewport(device, &ret_vp); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&ret_vp, &vp2, sizeof(vp2)), "Got unexpected viewport.\n"); + + hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetViewport(device, &vp1); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice7_GetViewport(device, &ret_vp); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&ret_vp, &vp1, sizeof(vp1)), "Got unexpected viewport.\n"); + + refcount = IDirect3DDevice7_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); + DestroyWindow(window); +} + START_TEST(ddraw7) { DDDEVICEIDENTIFIER2 identifier; @@ -16354,4 +16520,5 @@ START_TEST(ddraw7) test_clipper_refcount(); test_begin_end_state_block(); test_transform_state(); + test_viewport_state(); }