Commit 56d1225e authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d8/tests: Direct3DCreate8() is always available if we have d3d8.

parent 71d018b2
TESTDLL = d3d8.dll
IMPORTS = user32
IMPORTS = d3d8 user32
C_SRCS = \
device.c \
......
......@@ -33,38 +33,36 @@ static HWND create_window(void)
return CreateWindowA("d3d8_test_wc", "d3d8_test", 0, 0, 0, 0, 0, 0, 0, 0, 0);
}
static HRESULT init_d3d8(HMODULE d3d8_module, IDirect3DDevice8 **device, D3DPRESENT_PARAMETERS *device_pparams)
static IDirect3DDevice8 *init_d3d8(D3DPRESENT_PARAMETERS *present_parameters)
{
IDirect3D8 * (WINAPI *d3d8_create)(UINT SDKVersion) = 0;
IDirect3DDevice8 *device;
D3DDISPLAYMODE d3ddm;
IDirect3D8 *d3d8 = 0;
IDirect3D8 *d3d8;
HWND window;
HRESULT hr;
d3d8_create = (void *)GetProcAddress(d3d8_module, "Direct3DCreate8");
if (!d3d8_create) return E_FAIL;
d3d8 = d3d8_create(D3D_SDK_VERSION);
if (!d3d8)
if (!(d3d8 = Direct3DCreate8(D3D_SDK_VERSION)))
{
skip("Failed to create D3D8 object.\n");
return E_FAIL;
return NULL;
}
window = create_window();
IDirect3D8_GetAdapterDisplayMode(d3d8, D3DADAPTER_DEFAULT, &d3ddm);
memset(device_pparams, 0, sizeof(*device_pparams));
device_pparams->Windowed = TRUE;
device_pparams->SwapEffect = D3DSWAPEFFECT_DISCARD;
device_pparams->BackBufferFormat = d3ddm.Format;
memset(present_parameters, 0, sizeof(*present_parameters));
present_parameters->Windowed = TRUE;
present_parameters->SwapEffect = D3DSWAPEFFECT_DISCARD;
present_parameters->BackBufferFormat = d3ddm.Format;
hr = IDirect3D8_CreateDevice(d3d8, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window,
D3DCREATE_SOFTWARE_VERTEXPROCESSING, device_pparams, device);
D3DCREATE_SOFTWARE_VERTEXPROCESSING, present_parameters, &device);
ok(SUCCEEDED(hr) || hr == D3DERR_NOTAVAILABLE || broken(hr == D3DERR_INVALIDCALL),
"IDirect3D8_CreateDevice failed, hr %#x.\n", hr);
if (SUCCEEDED(hr))
return device;
return hr;
return NULL;
}
static void test_begin_end_state_block(IDirect3DDevice8 *device)
......@@ -2048,25 +2046,12 @@ static void test_shader_constant_apply(IDirect3DDevice8 *device)
START_TEST(stateblock)
{
IDirect3DDevice8 *device = NULL;
D3DPRESENT_PARAMETERS device_pparams;
HMODULE d3d8_module;
IDirect3DDevice8 *device;
ULONG refcount;
HRESULT hr;
d3d8_module = LoadLibraryA("d3d8.dll");
if (!d3d8_module)
{
skip("Could not load d3d8.dll\n");
return;
}
hr = init_d3d8(d3d8_module, &device, &device_pparams);
if (FAILED(hr))
{
FreeLibrary(d3d8_module);
if (!(device = init_d3d8(&device_pparams)))
return;
}
test_begin_end_state_block(device);
test_state_management(device, &device_pparams);
......@@ -2074,6 +2059,4 @@ START_TEST(stateblock)
refcount = IDirect3DDevice8_Release(device);
ok(!refcount, "Device has %u references left\n", refcount);
FreeLibrary(d3d8_module);
}
......@@ -23,8 +23,6 @@
#include <d3d8.h>
#include "wine/test.h"
static HMODULE d3d8_handle = 0;
struct vec2
{
float x, y;
......@@ -130,18 +128,12 @@ out:
static IDirect3DDevice8 *init_d3d8(void)
{
IDirect3D8 * (__stdcall * d3d8_create)(UINT SDKVersion) = 0;
IDirect3D8 *d3d8_ptr = 0;
IDirect3DDevice8 *device_ptr = 0;
D3DPRESENT_PARAMETERS present_parameters;
IDirect3DDevice8 *device = NULL;
IDirect3D8 *d3d8;
HRESULT hr;
d3d8_create = (void *)GetProcAddress(d3d8_handle, "Direct3DCreate8");
ok(d3d8_create != NULL, "Failed to get address of Direct3DCreate8\n");
if (!d3d8_create) return NULL;
d3d8_ptr = d3d8_create(D3D_SDK_VERSION);
if (!d3d8_ptr)
if (!(d3d8 = Direct3DCreate8(D3D_SDK_VERSION)))
{
skip("could not create D3D8\n");
return NULL;
......@@ -157,11 +149,12 @@ static IDirect3DDevice8 *init_d3d8(void)
present_parameters.EnableAutoDepthStencil = TRUE;
present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8;
hr = IDirect3D8_CreateDevice(d3d8_ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
present_parameters.hDeviceWindow, D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &device_ptr);
ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL || broken(hr == D3DERR_NOTAVAILABLE), "IDirect3D_CreateDevice returned: %#08x\n", hr);
hr = IDirect3D8_CreateDevice(d3d8, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
present_parameters.hDeviceWindow, D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &device);
ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL || broken(hr == D3DERR_NOTAVAILABLE),
"IDirect3D_CreateDevice returned: %#08x\n", hr);
return device_ptr;
return device;
}
struct vertex
......@@ -4693,15 +4686,7 @@ START_TEST(visual)
DWORD color;
D3DCAPS8 caps;
d3d8_handle = LoadLibraryA("d3d8.dll");
if (!d3d8_handle)
{
win_skip("Could not load d3d8.dll\n");
return;
}
device_ptr = init_d3d8();
if (!device_ptr)
if (!(device_ptr = init_d3d8()))
{
win_skip("Could not initialize direct3d\n");
return;
......
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