Commit 110eecf7 authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

ddraw/tests: Rewrite SetRenderState() tests.

parent 47679918
......@@ -411,18 +411,6 @@ static void LightTest(void)
}
}
static void StateTest( void )
{
HRESULT rc;
/* The msdn says it's undocumented, does it return an error too? */
rc = IDirect3DDevice7_SetRenderState(lpD3DDevice, D3DRENDERSTATE_ZVISIBLE, TRUE);
ok(rc == D3D_OK, "IDirect3DDevice7_SetRenderState(D3DRENDERSTATE_ZVISIBLE, TRUE) returned %08x\n", rc);
rc = IDirect3DDevice7_SetRenderState(lpD3DDevice, D3DRENDERSTATE_ZVISIBLE, FALSE);
ok(rc == D3D_OK, "IDirect3DDevice7_SetRenderState(D3DRENDERSTATE_ZVISIBLE, FALSE) returned %08x\n", rc);
}
static void SceneTest(void)
{
HRESULT hr;
......@@ -1416,22 +1404,6 @@ out:
IDirect3DVertexBuffer7_Release(lpVBufSrc);
}
static void D3D7_OldRenderStateTest(void)
{
HRESULT hr;
DWORD val;
/* Test reaction to some deprecated states in D3D7. */
hr = IDirect3DDevice7_SetRenderState(lpD3DDevice, D3DRENDERSTATE_TEXTUREHANDLE, 0);
ok(hr == DDERR_INVALIDPARAMS, "IDirect3DDevice7_SetRenderState returned %#x.\n", hr);
hr = IDirect3DDevice7_GetRenderState(lpD3DDevice, D3DRENDERSTATE_TEXTUREHANDLE, &val);
ok(hr == DDERR_INVALIDPARAMS, "IDirect3DDevice7_GetRenderState returned %#x.\n", hr);
hr = IDirect3DDevice7_SetRenderState(lpD3DDevice, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATE);
ok(hr == DDERR_INVALIDPARAMS, "IDirect3DDevice7_SetRenderState returned %#x.\n", hr);
hr = IDirect3DDevice7_GetRenderState(lpD3DDevice, D3DRENDERSTATE_TEXTUREMAPBLEND, &val);
ok(hr == DDERR_INVALIDPARAMS, "IDirect3DDevice7_GetRenderState returned %#x.\n", hr);
}
#define IS_VALUE_NEAR(a, b) ( ((a) == (b)) || ((a) == (b) - 1) || ((a) == (b) + 1) )
#define MIN(a, b) ((a) < (b) ? (a) : (b))
......@@ -3444,14 +3416,12 @@ START_TEST(d3d)
skip("Skipping d3d7 tests\n");
} else {
LightTest();
StateTest();
SceneTest();
D3D7EnumTest();
D3D7EnumLifetimeTest();
SetMaterialTest();
CapsTest();
VertexBufferDescTest();
D3D7_OldRenderStateTest();
DeviceLoadTest();
SetRenderTargetTest();
VertexBufferLockRest();
......
......@@ -12166,6 +12166,49 @@ done:
DestroyWindow(window);
}
static void test_set_render_state(void)
{
IDirect3DDevice2 *device;
IDirectDraw2 *ddraw;
ULONG refcount;
HWND window;
DWORD state;
HRESULT hr;
window = create_window();
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
if (!(device = create_device(ddraw, window, DDSCL_NORMAL)))
{
skip("Failed to create 3D device.\n");
DestroyWindow(window);
return;
}
hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ZVISIBLE, TRUE);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ZVISIBLE, FALSE);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, 0);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
state = 0xdeadbeef;
hr = IDirect3DDevice2_GetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, &state);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(!state, "Got unexpected render state %#x.\n", state);
hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATE);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice2_GetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, &state);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(state == D3DTBLEND_MODULATE, "Got unexpected render state %#x.\n", state);
refcount = IDirect3DDevice2_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
refcount = IDirectDraw2_Release(ddraw);
ok(!refcount, "DirectDraw has %u references left.\n", refcount);
DestroyWindow(window);
}
static void test_depth_readback(void)
{
DWORD depth, expected_depth, max_diff;
......@@ -12697,6 +12740,7 @@ START_TEST(ddraw2)
test_display_mode_surface_pixel_format();
test_surface_desc_size();
test_ck_operation();
test_set_render_state();
test_depth_readback();
test_clear();
test_enum_surfaces();
......
......@@ -14077,6 +14077,44 @@ static void test_texture_stages_limits(void)
DestroyWindow(window);
}
static void test_set_render_state(void)
{
IDirect3DDevice3 *device;
ULONG refcount;
HWND window;
DWORD state;
HRESULT hr;
window = create_window();
if (!(device = create_device(window, DDSCL_NORMAL)))
{
skip("Failed to create 3D device.\n");
DestroyWindow(window);
return;
}
hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZVISIBLE, TRUE);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZVISIBLE, FALSE);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, 0);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
state = 0xdeadbeef;
hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, &state);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(!state, "Got unexpected render state %#x.\n", state);
hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATE);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, &state);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(state == D3DTBLEND_MODULATE, "Got unexpected render state %#x.\n", state);
refcount = IDirect3DDevice3_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
DestroyWindow(window);
}
static void test_map_synchronisation(void)
{
LARGE_INTEGER frequency, diff, ts[3];
......@@ -14819,6 +14857,7 @@ START_TEST(ddraw4)
test_vb_refcount();
test_compute_sphere_visibility();
test_texture_stages_limits();
test_set_render_state();
test_map_synchronisation();
test_depth_readback();
test_clear();
......
......@@ -13449,6 +13449,46 @@ static void test_texture_stages_limits(void)
DestroyWindow(window);
}
static void test_set_render_state(void)
{
IDirect3DDevice7 *device;
ULONG refcount;
HWND window;
DWORD state;
HRESULT hr;
window = create_window();
if (!(device = create_device(window, DDSCL_NORMAL)))
{
skip("Failed to create 3D device.\n");
DestroyWindow(window);
return;
}
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZVISIBLE, TRUE);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZVISIBLE, FALSE);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
/* States deprecated in D3D7 */
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, 0);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
state = 0xdeadbeef;
hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, &state);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
ok(state == 0xdeadbeef, "Got unexpected render state %#x.\n", state);
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATE);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
state = 0xdeadbeef;
hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, &state);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
ok(state == 0xdeadbeef, "Got unexpected render state %#x.\n", state);
refcount = IDirect3DDevice7_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
DestroyWindow(window);
}
static void test_map_synchronisation(void)
{
LARGE_INTEGER frequency, diff, ts[3];
......@@ -14157,6 +14197,7 @@ START_TEST(ddraw7)
test_compute_sphere_visibility();
test_clip_planes_limits();
test_texture_stages_limits();
test_set_render_state();
test_map_synchronisation();
test_depth_readback();
test_clear();
......
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