Commit baa5ceec authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ddraw/tests: Add a test for the initial color keying state.

parent fa90a256
......@@ -1284,6 +1284,185 @@ static void test_ck_rgba(void)
DestroyWindow(window);
}
static void test_ck_default(void)
{
static D3DRECT clear_rect = {{0}, {0}, {640}, {480}};
static D3DTLVERTEX tquad[] =
{
{{ 0.0f}, {480.0f}, {0.0f}, {1.0f}, {0xffffffff}, {0x00000000}, {0.0f}, {0.0f}},
{{ 0.0f}, { 0.0f}, {0.0f}, {1.0f}, {0xffffffff}, {0x00000000}, {0.0f}, {1.0f}},
{{640.0f}, {480.0f}, {0.0f}, {1.0f}, {0xffffffff}, {0x00000000}, {1.0f}, {0.0f}},
{{640.0f}, { 0.0f}, {0.0f}, {1.0f}, {0xffffffff}, {0x00000000}, {1.0f}, {1.0f}},
};
IDirect3DExecuteBuffer *execute_buffer;
IDirectDrawSurface *surface, *rt;
D3DTEXTUREHANDLE texture_handle;
D3DEXECUTEBUFFERDESC exec_desc;
IDirect3DMaterial *background;
UINT draw1_offset, draw1_len;
UINT draw2_offset, draw2_len;
UINT draw3_offset, draw3_len;
UINT draw4_offset, draw4_len;
IDirect3DViewport *viewport;
DDSURFACEDESC surface_desc;
IDirect3DTexture *texture;
IDirect3DDevice *device;
IDirectDraw *ddraw;
D3DCOLOR color;
HWND window;
DDBLTFX fx;
HRESULT hr;
void *ptr;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 640, 480, 0, 0, 0, 0);
if (!(ddraw = create_ddraw()))
{
skip("Failed to create ddraw object, skipping test.\n");
DestroyWindow(window);
return;
}
if (!(device = create_device(ddraw, window, DDSCL_NORMAL)))
{
skip("Failed to create D3D device, skipping test.\n");
IDirectDraw_Release(ddraw);
DestroyWindow(window);
return;
}
hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&rt);
ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
background = create_diffuse_material(device, 0.0, 1.0f, 0.0f, 1.0f);
viewport = create_viewport(device, 0, 0, 640, 480);
viewport_set_background(device, viewport, background);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CKSRCBLT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
surface_desc.dwWidth = 256;
surface_desc.dwHeight = 256;
surface_desc.ddpfPixelFormat.dwSize = sizeof(surface_desc.ddpfPixelFormat);
surface_desc.ddpfPixelFormat.dwFlags = DDPF_RGB;
U1(surface_desc.ddpfPixelFormat).dwRGBBitCount = 32;
U2(surface_desc.ddpfPixelFormat).dwRBitMask = 0x00ff0000;
U3(surface_desc.ddpfPixelFormat).dwGBitMask = 0x0000ff00;
U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x000000ff;
surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x000000ff;
surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x000000ff;
hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DTexture, (void **)&texture);
ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
hr = IDirect3DTexture_GetHandle(texture, device, &texture_handle);
ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#x.\n", hr);
IDirect3DTexture_Release(texture);
memset(&fx, 0, sizeof(fx));
fx.dwSize = sizeof(fx);
U5(fx).dwFillColor = 0x000000ff;
hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
memset(&exec_desc, 0, sizeof(exec_desc));
exec_desc.dwSize = sizeof(exec_desc);
exec_desc.dwFlags = D3DDEB_BUFSIZE | D3DDEB_CAPS;
exec_desc.dwBufferSize = 1024;
exec_desc.dwCaps = D3DDEBCAPS_SYSTEMMEMORY;
hr = IDirect3DDevice_CreateExecuteBuffer(device, &exec_desc, &execute_buffer, NULL);
ok(SUCCEEDED(hr), "Failed to create execute buffer, hr %#x.\n", hr);
hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#x.\n", hr);
memcpy(exec_desc.lpData, tquad, sizeof(tquad));
ptr = (BYTE *)exec_desc.lpData + sizeof(tquad);
emit_process_vertices(&ptr, 0, 4);
emit_set_rs(&ptr, D3DRENDERSTATE_TEXTUREHANDLE, texture_handle);
emit_tquad(&ptr, 0);
emit_end(&ptr);
draw1_offset = sizeof(tquad);
draw1_len = (BYTE *)ptr - (BYTE *)exec_desc.lpData - draw1_offset;
emit_process_vertices(&ptr, 0, 4);
emit_set_rs(&ptr, D3DRENDERSTATE_COLORKEYENABLE, FALSE);
emit_tquad(&ptr, 0);
emit_end(&ptr);
draw2_offset = draw1_offset + draw1_len;
draw2_len = (BYTE *)ptr - (BYTE *)exec_desc.lpData - draw2_offset;
emit_process_vertices(&ptr, 0, 4);
emit_tquad(&ptr, 0);
emit_end(&ptr);
draw3_offset = draw2_offset + draw2_len;
draw3_len = (BYTE *)ptr - (BYTE *)exec_desc.lpData - draw3_offset;
emit_process_vertices(&ptr, 0, 4);
emit_set_rs(&ptr, D3DRENDERSTATE_COLORKEYENABLE, TRUE);
emit_tquad(&ptr, 0);
emit_set_rs(&ptr, D3DRENDERSTATE_TEXTUREHANDLE, 0);
emit_end(&ptr);
draw4_offset = draw3_offset + draw3_len;
draw4_len = (BYTE *)ptr - (BYTE *)exec_desc.lpData - draw4_offset;
hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#x.\n", hr);
hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
hr = IDirect3DDevice_BeginScene(device);
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
set_execute_data(execute_buffer, 4, draw1_offset, draw1_len);
hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#x.\n", hr);
hr = IDirect3DDevice_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = get_surface_color(rt, 320, 240);
ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
hr = IDirect3DDevice_BeginScene(device);
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
set_execute_data(execute_buffer, 4, draw2_offset, draw2_len);
hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#x.\n", hr);
hr = IDirect3DDevice_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = get_surface_color(rt, 320, 240);
todo_wine ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
hr = IDirect3DDevice_BeginScene(device);
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
set_execute_data(execute_buffer, 4, draw3_offset, draw3_len);
hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#x.\n", hr);
hr = IDirect3DDevice_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = get_surface_color(rt, 320, 240);
todo_wine ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
hr = IDirect3DDevice_BeginScene(device);
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
set_execute_data(execute_buffer, 4, draw4_offset, draw4_len);
hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#x.\n", hr);
hr = IDirect3DDevice_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = get_surface_color(rt, 320, 240);
ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
IDirect3DExecuteBuffer_Release(execute_buffer);
IDirectDrawSurface_Release(surface);
destroy_viewport(device, viewport);
destroy_material(background);
IDirectDrawSurface_Release(rt);
IDirect3DDevice_Release(device);
IDirectDraw_Release(ddraw);
DestroyWindow(window);
}
struct qi_test
{
REFIID iid;
......@@ -1508,6 +1687,7 @@ START_TEST(ddraw1)
test_viewport_interfaces();
test_zenable();
test_ck_rgba();
test_ck_default();
test_surface_qi();
test_device_qi();
}
......@@ -1480,6 +1480,127 @@ static void test_ck_rgba(void)
DestroyWindow(window);
}
static void test_ck_default(void)
{
static D3DRECT clear_rect = {{0}, {0}, {640}, {480}};
static D3DTLVERTEX tquad[] =
{
{{ 0.0f}, {480.0f}, {0.0f}, {1.0f}, {0xffffffff}, {0x00000000}, {0.0f}, {0.0f}},
{{ 0.0f}, { 0.0f}, {0.0f}, {1.0f}, {0xffffffff}, {0x00000000}, {0.0f}, {1.0f}},
{{640.0f}, {480.0f}, {0.0f}, {1.0f}, {0xffffffff}, {0x00000000}, {1.0f}, {0.0f}},
{{640.0f}, { 0.0f}, {0.0f}, {1.0f}, {0xffffffff}, {0x00000000}, {1.0f}, {1.0f}},
};
IDirectDrawSurface *surface, *rt;
D3DTEXTUREHANDLE texture_handle;
IDirect3DMaterial2 *background;
IDirect3DViewport2 *viewport;
DDSURFACEDESC surface_desc;
IDirect3DTexture2 *texture;
IDirect3DDevice2 *device;
IDirectDraw2 *ddraw;
D3DCOLOR color;
DWORD value;
HWND window;
DDBLTFX fx;
HRESULT hr;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 640, 480, 0, 0, 0, 0);
if (!(ddraw = create_ddraw()))
{
skip("Failed to create ddraw object, skipping test.\n");
DestroyWindow(window);
return;
}
if (!(device = create_device(ddraw, window, DDSCL_NORMAL)))
{
skip("Failed to create D3D device, skipping test.\n");
IDirectDraw2_Release(ddraw);
DestroyWindow(window);
return;
}
hr = IDirect3DDevice2_GetRenderTarget(device, &rt);
ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
background = create_diffuse_material(device, 0.0, 1.0f, 0.0f, 1.0f);
viewport = create_viewport(device, 0, 0, 640, 480);
viewport_set_background(device, viewport, background);
hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CKSRCBLT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
surface_desc.dwWidth = 256;
surface_desc.dwHeight = 256;
surface_desc.ddpfPixelFormat.dwSize = sizeof(surface_desc.ddpfPixelFormat);
surface_desc.ddpfPixelFormat.dwFlags = DDPF_RGB;
U1(surface_desc.ddpfPixelFormat).dwRGBBitCount = 32;
U2(surface_desc.ddpfPixelFormat).dwRBitMask = 0x00ff0000;
U3(surface_desc.ddpfPixelFormat).dwGBitMask = 0x0000ff00;
U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x000000ff;
surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x000000ff;
surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x000000ff;
hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DTexture2, (void **)&texture);
ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
hr = IDirect3DTexture2_GetHandle(texture, device, &texture_handle);
ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#x.\n", hr);
IDirect3DTexture_Release(texture);
memset(&fx, 0, sizeof(fx));
fx.dwSize = sizeof(fx);
U5(fx).dwFillColor = 0x000000ff;
hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
hr = IDirect3DDevice2_BeginScene(device);
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, texture_handle);
ok(SUCCEEDED(hr), "Failed to set texture handle, hr %#x.\n", hr);
hr = IDirect3DDevice2_GetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, &value);
ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
ok(!value, "Got unexpected color keying state %#x.\n", value);
hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_TLVERTEX, &tquad[0], 4, 0);
ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
hr = IDirect3DDevice2_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = get_surface_color(rt, 320, 240);
ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
hr = IDirect3DDevice2_BeginScene(device);
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, TRUE);
ok(SUCCEEDED(hr), "Failed to enable color keying, hr %#x.\n", hr);
hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_TLVERTEX, &tquad[0], 4, 0);
ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
hr = IDirect3DDevice2_GetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, &value);
ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
ok(!!value, "Got unexpected color keying state %#x.\n", value);
hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, 0);
ok(SUCCEEDED(hr), "Failed to set texture handle, hr %#x.\n", hr);
hr = IDirect3DDevice2_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = get_surface_color(rt, 320, 240);
ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
IDirectDrawSurface_Release(surface);
destroy_viewport(device, viewport);
destroy_material(background);
IDirectDrawSurface_Release(rt);
IDirect3DDevice2_Release(device);
IDirectDraw2_Release(ddraw);
DestroyWindow(window);
}
struct qi_test
{
REFIID iid;
......@@ -1705,6 +1826,7 @@ START_TEST(ddraw2)
test_viewport_interfaces();
test_zenable();
test_ck_rgba();
test_ck_default();
test_surface_qi();
test_device_qi();
}
......@@ -1616,6 +1616,123 @@ static void test_ck_rgba(void)
DestroyWindow(window);
}
static void test_ck_default(void)
{
static D3DRECT clear_rect = {{0}, {0}, {640}, {480}};
static struct
{
struct vec4 position;
struct vec2 texcoord;
}
tquad[] =
{
{{ 0.0f, 480.0f, 0.0f, 1.0f}, {0.0f, 0.0f}},
{{ 0.0f, 0.0f, 0.0f, 1.0f}, {0.0f, 1.0f}},
{{640.0f, 480.0f, 0.0f, 1.0f}, {1.0f, 0.0f}},
{{640.0f, 0.0f, 0.0f, 1.0f}, {1.0f, 1.0f}},
};
IDirectDrawSurface4 *surface, *rt;
IDirect3DViewport3 *viewport;
DDSURFACEDESC2 surface_desc;
IDirect3DTexture2 *texture;
IDirect3DDevice3 *device;
IDirectDraw4 *ddraw;
IDirect3D3 *d3d;
D3DCOLOR color;
DWORD value;
HWND window;
DDBLTFX fx;
HRESULT hr;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 640, 480, 0, 0, 0, 0);
if (!(device = create_device(window, DDSCL_NORMAL)))
{
skip("Failed to create D3D device, skipping test.\n");
DestroyWindow(window);
return;
}
hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
IDirect3D3_Release(d3d);
hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
viewport = create_viewport(device, 0, 0, 640, 480);
hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CKSRCBLT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
surface_desc.dwWidth = 256;
surface_desc.dwHeight = 256;
U4(surface_desc).ddpfPixelFormat.dwSize = sizeof(U4(surface_desc).ddpfPixelFormat);
U4(surface_desc).ddpfPixelFormat.dwFlags = DDPF_RGB;
U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount = 32;
U2(U4(surface_desc).ddpfPixelFormat).dwRBitMask = 0x00ff0000;
U3(U4(surface_desc).ddpfPixelFormat).dwGBitMask = 0x0000ff00;
U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x000000ff;
surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x000000ff;
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
hr = IDirectDrawSurface4_QueryInterface(surface, &IID_IDirect3DTexture2, (void **)&texture);
ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
hr = IDirect3DDevice3_SetTexture(device, 0, texture);
ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
memset(&fx, 0, sizeof(fx));
fx.dwSize = sizeof(fx);
U5(fx).dwFillColor = 0x000000ff;
hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xff00ff00, 1.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
hr = IDirect3DDevice3_BeginScene(device);
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, &value);
ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
ok(!value, "Got unexpected color keying state %#x.\n", value);
hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZRHW | D3DFVF_TEX1, &tquad[0], 4, 0);
ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
hr = IDirect3DDevice3_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = get_surface_color(rt, 320, 240);
ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xff00ff00, 1.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
hr = IDirect3DDevice3_BeginScene(device);
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, TRUE);
ok(SUCCEEDED(hr), "Failed to enable color keying, hr %#x.\n", hr);
hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZRHW | D3DFVF_TEX1, &tquad[0], 4, 0);
ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, &value);
ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
ok(!!value, "Got unexpected color keying state %#x.\n", value);
hr = IDirect3DDevice3_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = get_surface_color(rt, 320, 240);
ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
IDirect3DTexture_Release(texture);
IDirectDrawSurface4_Release(surface);
destroy_viewport(device, viewport);
IDirectDrawSurface4_Release(rt);
IDirect3DDevice3_Release(device);
IDirectDraw4_Release(ddraw);
DestroyWindow(window);
}
struct qi_test
{
REFIID iid;
......@@ -1834,6 +1951,7 @@ START_TEST(ddraw4)
test_viewport_interfaces();
test_zenable();
test_ck_rgba();
test_ck_default();
test_surface_qi();
test_device_qi();
}
......@@ -1435,6 +1435,112 @@ static void test_ck_rgba(void)
DestroyWindow(window);
}
static void test_ck_default(void)
{
static struct
{
struct vec4 position;
struct vec2 texcoord;
}
tquad[] =
{
{{ 0.0f, 480.0f, 0.0f, 1.0f}, {0.0f, 0.0f}},
{{ 0.0f, 0.0f, 0.0f, 1.0f}, {0.0f, 1.0f}},
{{640.0f, 480.0f, 0.0f, 1.0f}, {1.0f, 0.0f}},
{{640.0f, 0.0f, 0.0f, 1.0f}, {1.0f, 1.0f}},
};
IDirectDrawSurface7 *surface, *rt;
DDSURFACEDESC2 surface_desc;
IDirect3DDevice7 *device;
IDirectDraw7 *ddraw;
IDirect3D7 *d3d;
D3DCOLOR color;
DWORD value;
HWND window;
DDBLTFX fx;
HRESULT hr;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 640, 480, 0, 0, 0, 0);
if (!(device = create_device(window, DDSCL_NORMAL)))
{
skip("Failed to create D3D device, skipping test.\n");
DestroyWindow(window);
return;
}
hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
IDirect3D7_Release(d3d);
hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CKSRCBLT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
surface_desc.dwWidth = 256;
surface_desc.dwHeight = 256;
U4(surface_desc).ddpfPixelFormat.dwSize = sizeof(U4(surface_desc).ddpfPixelFormat);
U4(surface_desc).ddpfPixelFormat.dwFlags = DDPF_RGB;
U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount = 32;
U2(U4(surface_desc).ddpfPixelFormat).dwRBitMask = 0x00ff0000;
U3(U4(surface_desc).ddpfPixelFormat).dwGBitMask = 0x0000ff00;
U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x000000ff;
surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x000000ff;
hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
hr = IDirect3DDevice7_SetTexture(device, 0, surface);
ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
memset(&fx, 0, sizeof(fx));
fx.dwSize = sizeof(fx);
U5(fx).dwFillColor = 0x000000ff;
hr = IDirectDrawSurface7_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff00ff00, 1.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
hr = IDirect3DDevice7_BeginScene(device);
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, &value);
ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
ok(!value, "Got unexpected color keying state %#x.\n", value);
hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZRHW | D3DFVF_TEX1, &tquad[0], 4, 0);
ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
hr = IDirect3DDevice7_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = get_surface_color(rt, 320, 240);
ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff00ff00, 1.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
hr = IDirect3DDevice7_BeginScene(device);
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, TRUE);
ok(SUCCEEDED(hr), "Failed to enable color keying, hr %#x.\n", hr);
hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZRHW | D3DFVF_TEX1, &tquad[0], 4, 0);
ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, &value);
ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
ok(!!value, "Got unexpected color keying state %#x.\n", value);
hr = IDirect3DDevice7_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = get_surface_color(rt, 320, 240);
ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
IDirectDrawSurface7_Release(surface);
IDirectDrawSurface7_Release(rt);
IDirect3DDevice7_Release(device);
IDirectDraw7_Release(ddraw);
DestroyWindow(window);
}
struct qi_test
{
REFIID iid;
......@@ -1661,6 +1767,7 @@ START_TEST(ddraw7)
test_texture_load_ckey();
test_zenable();
test_ck_rgba();
test_ck_default();
test_surface_qi();
test_device_qi();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment