d3d8/tests: Add a test for DrawIndexedPrimitiveUP().

Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Matteo Bruni 2017-01-18 21:35:31 +01:00 committed by Alexandre Julliard
parent ea11b27528
commit 99509cba32

View file

@ -9700,6 +9700,108 @@ done:
DestroyWindow(window);
}
static void test_drawindexedprimitiveup(void)
{
static const struct vertex
{
struct vec3 position;
DWORD diffuse;
}
quad[] =
{
{{-1.0f, -1.0f, 0.1f}, 0xff00ff00},
{{-1.0f, 1.0f, 0.1f}, 0xff0000ff},
{{ 1.0f, -1.0f, 0.1f}, 0xffff0000},
{{ 1.0f, 1.0f, 0.1f}, 0xff0000ff},
{{-1.0f, -1.0f, 0.1f}, 0xff0000ff},
{{-1.0f, 1.0f, 0.1f}, 0xff00ff00},
{{ 1.0f, -1.0f, 0.1f}, 0xffff0000},
{{ 1.0f, 1.0f, 0.1f}, 0xff00ff00},
};
static const unsigned short indices[] = {0, 1, 2, 3, 4, 5, 6, 7};
IDirect3DDevice8 *device;
IDirect3D8 *d3d;
ULONG refcount;
D3DCOLOR color;
HWND window;
HRESULT hr;
window = create_window();
d3d = Direct3DCreate8(D3D_SDK_VERSION);
ok(!!d3d, "Failed to create a D3D object.\n");
if (!(device = create_device(d3d, window, window, TRUE)))
{
skip("Failed to create a D3D device.\n");
IDirect3D8_Release(d3d);
DestroyWindow(window);
return;
}
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_CLIPPING, FALSE);
ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZENABLE, FALSE);
ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
ok(SUCCEEDED(hr), "Failed to set alpha op, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
ok(SUCCEEDED(hr), "Failed to set alpha arg, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
hr = IDirect3DDevice8_BeginScene(device);
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
hr = IDirect3DDevice8_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 4, 4, 2, indices + 4, D3DFMT_INDEX16, quad, sizeof(*quad));
ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
hr = IDirect3DDevice8_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = getPixelColor(device, 160, 120);
ok(color_match(color, 0x0040bf00, 1), "Got unexpected color 0x%08x.\n", color);
color = getPixelColor(device, 480, 120);
ok(color_match(color, 0x0040bf00, 1), "Got unexpected color 0x%08x.\n", color);
color = getPixelColor(device, 160, 360);
ok(color_match(color, 0x00404080, 1), "Got unexpected color 0x%08x.\n", color);
color = getPixelColor(device, 480, 360);
ok(color_match(color, 0x00bf4000, 1), "Got unexpected color 0x%08x.\n", color);
hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
hr = IDirect3DDevice8_BeginScene(device);
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
hr = IDirect3DDevice8_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 0, 4, 2, indices, D3DFMT_INDEX16, quad, sizeof(*quad));
ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
hr = IDirect3DDevice8_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = getPixelColor(device, 160, 120);
ok(color_match(color, 0x004000bf, 1), "Got unexpected color 0x%08x.\n", color);
color = getPixelColor(device, 480, 120);
ok(color_match(color, 0x004000bf, 1), "Got unexpected color 0x%08x.\n", color);
color = getPixelColor(device, 160, 360);
ok(color_match(color, 0x00408040, 1), "Got unexpected color 0x%08x.\n", color);
color = getPixelColor(device, 480, 360);
ok(color_match(color, 0x00bf0040, 1), "Got unexpected color 0x%08x.\n", color);
refcount = IDirect3DDevice8_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
IDirect3D8_Release(d3d);
DestroyWindow(window);
}
START_TEST(visual)
{
D3DADAPTER_IDENTIFIER8 identifier;
@ -9770,4 +9872,5 @@ START_TEST(visual)
test_edge_antialiasing_blending();
test_max_index16();
test_backbuffer_resize();
test_drawindexedprimitiveup();
}