From: Alistair Leslie-Hughes leslie_alistair@hotmail.com
Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com --- dlls/d3drm/tests/d3drm.c | 91 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+)
diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c index 5745fea4b09..493b8ee03af 100644 --- a/dlls/d3drm/tests/d3drm.c +++ b/dlls/d3drm/tests/d3drm.c @@ -7465,6 +7465,96 @@ cleanup: DestroyWindow(window); }
+static void test_viewport_clear3(void) +{ + IDirectDraw *ddraw; + IDirectDrawClipper *clipper; + IDirect3DRM *d3drm1; + IDirect3DRMFrame *frame1, *camera1; + IDirect3DRMDevice *device1; + IDirect3DViewport *d3d_viewport; + IDirect3DRMViewport *viewport1; + IDirect3DDevice *d3d_device1; + IDirectDrawSurface *surface; + HWND window; + GUID driver = IID_IDirect3DRGBDevice; + HRESULT hr; + D3DCOLOR ret_color; + RECT rc; + + window = create_window(); + GetClientRect(window, &rc); + + hr = DirectDrawCreate(NULL, &ddraw, NULL); + ok(SUCCEEDED(hr), "Cannot create IDirectDraw interface, hr %#lx.\n", hr); + + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); + ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr); + + hr = IDirectDraw_CreateClipper(ddraw, 0, &clipper, NULL); + ok(SUCCEEDED(hr), "Cannot create clipper, hr %#lx.\n", hr); + + hr = IDirectDrawClipper_SetHWnd(clipper, 0, window); + ok(SUCCEEDED(hr), "Cannot set HWnd to Clipper, hr %#lx\n", hr); + + hr = Direct3DRMCreate(&d3drm1); + ok(SUCCEEDED(hr), "Cannot get IDirect3DRM interface, hr %#lx.\n", hr); + + hr = IDirect3DRM_CreateDeviceFromClipper(d3drm1, clipper, &driver, rc.right, rc.bottom, &device1); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRMDevice interface, hr %#lx\n", hr); + + hr = IDirect3DRM_CreateFrame(d3drm1, NULL, &frame1); + ok(SUCCEEDED(hr), "Cannot get IDirect3DRMFrame interface, hr %#lx\n", hr); + hr = IDirect3DRM_CreateFrame(d3drm1, frame1, &camera1); + ok(SUCCEEDED(hr), "Cannot get IDirect3DRMFrame interface, hr %#lx\n", hr); + + hr = IDirect3DRM_CreateViewport(d3drm1, device1, camera1, 0, 0, rc.right, + rc.bottom, &viewport1); + ok(SUCCEEDED(hr), "Cannot get IDirect3DRMViewport2 interface, hr %#lx\n", hr); + + /* Fetch immediate mode device and viewport */ + hr = IDirect3DRMDevice_GetDirect3DDevice(device1, &d3d_device1); + ok(SUCCEEDED(hr), "Cannot get IDirect3DDevice interface, hr %#lx.\n", hr); + hr = IDirect3DRMViewport_GetDirect3DViewport(viewport1, &d3d_viewport); + ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr); + + hr = IDirect3DDevice_QueryInterface(d3d_device1, &IID_IDirectDrawSurface, (void **)&surface); + ok(SUCCEEDED(hr), "Cannot get surface to the render target, hr %#lx.\n", hr); + + ret_color = get_surface_color(surface, 320, 240); + ok(compare_color(ret_color, 0, 1), "Got unexpected color 0x%08lx.\n", ret_color); + + /* Clear uses the scene frame's background color. */ + hr = IDirect3DRMFrame_SetSceneBackground(frame1, 0x00bc614e); + ok(SUCCEEDED(hr), "Cannot set scene background, hr %#lx\n", hr); + + hr = IDirect3DRMViewport_Clear(viewport1); + ok(SUCCEEDED(hr), "Cannot clear viewport, hr %#lx.\n", hr); + ret_color = get_surface_color(surface, 320, 240); + ok(compare_color(ret_color, 0x00bc614e, 1), "Got unexpected color 0x%08lx.\n", ret_color); + + hr = IDirect3DRMFrame_SetSceneBackground(frame1, 0xdeadbeef); + ok(SUCCEEDED(hr), "Cannot set scene background, hr %#lx\n", hr); + + hr = IDirect3DRMViewport_Render(viewport1, frame1); + ok(SUCCEEDED(hr), "Cannot Render, hr %#lx\n", hr); + + ret_color = get_surface_color(surface, 320, 240); + ok(compare_color(ret_color, 0x00bc614e, 1), "Got unexpected color 0x%08lx.\n", ret_color); + + IDirect3DViewport_Release(d3d_viewport); + IDirectDrawSurface_Release(surface); + IDirect3DDevice_Release(d3d_device1); + IDirect3DRMViewport_Release(viewport1); + IDirect3DRMFrame_Release(frame1); + IDirect3DRMFrame_Release(camera1); + IDirect3DRMDevice_Release(device1); + IDirect3DRM_Release(d3drm1); + IDirectDrawClipper_Release(clipper); + IDirectDraw_Release(ddraw); + DestroyWindow(window); +} + static void test_create_texture_from_surface(void) { D3DRMIMAGE testimg = @@ -8225,6 +8315,7 @@ START_TEST(d3drm) test_viewport_qi(); test_viewport_clear1(); test_viewport_clear2(); + test_viewport_clear3(); test_create_texture_from_surface(); test_animation(); test_animation_qi();
Stefan D��singer (@stefan) commented about dlls/d3drm/tests/d3drm.c:
- hr = IDirect3DDevice_QueryInterface(d3d_device1, &IID_IDirectDrawSurface, (void **)&surface);
- ok(SUCCEEDED(hr), "Cannot get surface to the render target, hr %#lx.\n", hr);
- ret_color = get_surface_color(surface, 320, 240);
- ok(compare_color(ret_color, 0, 1), "Got unexpected color 0x%08lx.\n", ret_color);
- /* Clear uses the scene frame's background color. */
- hr = IDirect3DRMFrame_SetSceneBackground(frame1, 0x00bc614e);
- ok(SUCCEEDED(hr), "Cannot set scene background, hr %#lx\n", hr);
- hr = IDirect3DRMViewport_Clear(viewport1);
- ok(SUCCEEDED(hr), "Cannot clear viewport, hr %#lx.\n", hr);
- ret_color = get_surface_color(surface, 320, 240);
- ok(compare_color(ret_color, 0x00bc614e, 1), "Got unexpected color 0x%08lx.\n", ret_color);
- hr = IDirect3DRMFrame_SetSceneBackground(frame1, 0xdeadbeef);
Afaics this here is what the test adds compared to test_viewport_clear1 and test_viewport_clear2. Set the background color to something else, invoke render() and demonstrate that render() does not clear. You can add this to the two existing tests instead of adding another one.
The point of clear1 and clear2 isn't that they aren't a first and second clear test; clear1 uses IDirect3DRM1 interfaces, clear2 IDirect3DRM2; A "clear3" following the scheme should use IDirect3DRM3 et al.