2011-12-19 21:00:06 +01:00
|
|
|
/*
|
2012-03-26 20:28:08 +02:00
|
|
|
* Copyright 2011-2012 Henri Verbeet for CodeWeavers
|
2011-12-19 21:00:06 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
2012-02-02 12:56:00 +01:00
|
|
|
#define COBJMACROS
|
2011-12-19 21:00:06 +01:00
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
#include <limits.h>
|
|
|
|
#include "d3d.h"
|
|
|
|
|
2012-02-28 19:48:41 +01:00
|
|
|
struct vec2
|
|
|
|
{
|
|
|
|
float x, y;
|
|
|
|
};
|
|
|
|
|
2011-12-19 21:00:06 +01:00
|
|
|
struct vec3
|
|
|
|
{
|
|
|
|
float x, y, z;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vec4
|
|
|
|
{
|
|
|
|
float x, y, z, w;
|
|
|
|
};
|
|
|
|
|
2012-01-26 23:04:20 +01:00
|
|
|
struct create_window_thread_param
|
|
|
|
{
|
|
|
|
HWND window;
|
|
|
|
HANDLE window_created;
|
|
|
|
HANDLE destroy_window;
|
|
|
|
HANDLE thread;
|
|
|
|
};
|
|
|
|
|
2011-12-19 21:00:06 +01:00
|
|
|
static BOOL compare_float(float f, float g, unsigned int ulps)
|
|
|
|
{
|
|
|
|
int x = *(int *)&f;
|
|
|
|
int y = *(int *)&g;
|
|
|
|
|
|
|
|
if (x < 0)
|
|
|
|
x = INT_MIN - x;
|
|
|
|
if (y < 0)
|
|
|
|
y = INT_MIN - y;
|
|
|
|
|
|
|
|
if (abs(x - y) > ulps)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL compare_vec4(struct vec4 *vec, float x, float y, float z, float w, unsigned int ulps)
|
|
|
|
{
|
|
|
|
return compare_float(vec->x, x, ulps)
|
|
|
|
&& compare_float(vec->y, y, ulps)
|
|
|
|
&& compare_float(vec->z, z, ulps)
|
|
|
|
&& compare_float(vec->w, w, ulps);
|
|
|
|
}
|
|
|
|
|
2012-01-04 23:34:52 +01:00
|
|
|
static BOOL compare_color(D3DCOLOR c1, D3DCOLOR c2, BYTE max_diff)
|
|
|
|
{
|
|
|
|
if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
|
|
|
|
c1 >>= 8; c2 >>= 8;
|
|
|
|
if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
|
|
|
|
c1 >>= 8; c2 >>= 8;
|
|
|
|
if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
|
|
|
|
c1 >>= 8; c2 >>= 8;
|
|
|
|
if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2012-01-26 23:04:20 +01:00
|
|
|
static DWORD WINAPI create_window_thread_proc(void *param)
|
|
|
|
{
|
|
|
|
struct create_window_thread_param *p = param;
|
|
|
|
DWORD res;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
p->window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
|
|
|
|
0, 0, 640, 480, 0, 0, 0, 0);
|
|
|
|
ret = SetEvent(p->window_created);
|
|
|
|
ok(ret, "SetEvent failed, last error %#x.\n", GetLastError());
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
|
|
|
|
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
res = WaitForSingleObject(p->destroy_window, 100);
|
|
|
|
if (res == WAIT_OBJECT_0)
|
|
|
|
break;
|
|
|
|
if (res != WAIT_TIMEOUT)
|
|
|
|
{
|
|
|
|
ok(0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DestroyWindow(p->window);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void create_window_thread(struct create_window_thread_param *p)
|
|
|
|
{
|
|
|
|
DWORD res, tid;
|
|
|
|
|
|
|
|
p->window_created = CreateEvent(NULL, FALSE, FALSE, NULL);
|
|
|
|
ok(!!p->window_created, "CreateEvent failed, last error %#x.\n", GetLastError());
|
|
|
|
p->destroy_window = CreateEvent(NULL, FALSE, FALSE, NULL);
|
|
|
|
ok(!!p->destroy_window, "CreateEvent failed, last error %#x.\n", GetLastError());
|
|
|
|
p->thread = CreateThread(NULL, 0, create_window_thread_proc, p, 0, &tid);
|
|
|
|
ok(!!p->thread, "Failed to create thread, last error %#x.\n", GetLastError());
|
|
|
|
res = WaitForSingleObject(p->window_created, INFINITE);
|
|
|
|
ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
|
|
|
|
}
|
|
|
|
|
|
|
|
static void destroy_window_thread(struct create_window_thread_param *p)
|
|
|
|
{
|
|
|
|
SetEvent(p->destroy_window);
|
|
|
|
WaitForSingleObject(p->thread, INFINITE);
|
|
|
|
CloseHandle(p->destroy_window);
|
|
|
|
CloseHandle(p->window_created);
|
|
|
|
CloseHandle(p->thread);
|
|
|
|
}
|
|
|
|
|
2012-02-02 19:26:38 +01:00
|
|
|
static IDirectDrawSurface4 *get_depth_stencil(IDirect3DDevice3 *device)
|
|
|
|
{
|
|
|
|
IDirectDrawSurface4 *rt, *ret;
|
|
|
|
DDSCAPS2 caps = {DDSCAPS_ZBUFFER, 0, 0, 0};
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to get the render target, hr %#x.\n", hr);
|
|
|
|
hr = IDirectDrawSurface4_GetAttachedSurface(rt, &caps, &ret);
|
|
|
|
ok(SUCCEEDED(hr) || hr == DDERR_NOTFOUND, "Failed to get the z buffer, hr %#x.\n", hr);
|
|
|
|
IDirectDrawSurface4_Release(rt);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-01-04 23:34:52 +01:00
|
|
|
static D3DCOLOR get_surface_color(IDirectDrawSurface4 *surface, UINT x, UINT y)
|
|
|
|
{
|
|
|
|
RECT rect = {x, y, x + 1, y + 1};
|
|
|
|
DDSURFACEDESC2 surface_desc;
|
|
|
|
D3DCOLOR color;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
memset(&surface_desc, 0, sizeof(surface_desc));
|
|
|
|
surface_desc.dwSize = sizeof(surface_desc);
|
|
|
|
|
|
|
|
hr = IDirectDrawSurface4_Lock(surface, &rect, &surface_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return 0xdeadbeef;
|
|
|
|
|
|
|
|
color = *((DWORD *)surface_desc.lpSurface) & 0x00ffffff;
|
|
|
|
|
|
|
|
hr = IDirectDrawSurface4_Unlock(surface, &rect);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
2012-01-17 21:13:34 +01:00
|
|
|
static HRESULT CALLBACK enum_z_fmt(DDPIXELFORMAT *format, void *ctx)
|
|
|
|
{
|
|
|
|
DDPIXELFORMAT *z_fmt = ctx;
|
|
|
|
|
|
|
|
if (U1(*format).dwZBufferBitDepth > U1(*z_fmt).dwZBufferBitDepth)
|
|
|
|
*z_fmt = *format;
|
|
|
|
|
|
|
|
return DDENUMRET_OK;
|
|
|
|
}
|
|
|
|
|
2011-12-21 21:34:58 +01:00
|
|
|
static IDirectDraw4 *create_ddraw(void)
|
2011-12-19 21:00:06 +01:00
|
|
|
{
|
|
|
|
IDirectDraw4 *ddraw4;
|
|
|
|
IDirectDraw *ddraw1;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (FAILED(DirectDrawCreate(NULL, &ddraw1, NULL)))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
hr = IDirectDraw_QueryInterface(ddraw1, &IID_IDirectDraw4, (void **)&ddraw4);
|
|
|
|
IDirectDraw_Release(ddraw1);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return NULL;
|
|
|
|
|
2011-12-21 21:34:58 +01:00
|
|
|
return ddraw4;
|
|
|
|
}
|
|
|
|
|
|
|
|
static IDirect3DDevice3 *create_device(HWND window, DWORD coop_level)
|
|
|
|
{
|
2012-01-17 21:13:34 +01:00
|
|
|
IDirectDrawSurface4 *surface, *ds;
|
2011-12-21 21:34:58 +01:00
|
|
|
IDirect3DDevice3 *device = NULL;
|
|
|
|
DDSURFACEDESC2 surface_desc;
|
|
|
|
IDirectDraw4 *ddraw4;
|
2012-01-17 21:13:34 +01:00
|
|
|
DDPIXELFORMAT z_fmt;
|
2011-12-21 21:34:58 +01:00
|
|
|
IDirect3D3 *d3d3;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (!(ddraw4 = create_ddraw()))
|
|
|
|
return NULL;
|
|
|
|
|
2011-12-19 21:00:06 +01:00
|
|
|
hr = IDirectDraw4_SetCooperativeLevel(ddraw4, window, coop_level);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set cooperative level, 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;
|
|
|
|
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
|
|
|
|
surface_desc.dwWidth = 640;
|
|
|
|
surface_desc.dwHeight = 480;
|
|
|
|
|
|
|
|
hr = IDirectDraw4_CreateSurface(ddraw4, &surface_desc, &surface, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
if (coop_level & DDSCL_NORMAL)
|
|
|
|
{
|
|
|
|
IDirectDrawClipper *clipper;
|
|
|
|
|
|
|
|
hr = IDirectDraw4_CreateClipper(ddraw4, 0, &clipper, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
|
|
|
|
hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
|
|
|
|
hr = IDirectDrawSurface4_SetClipper(surface, clipper);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set surface clipper, hr %#x.\n", hr);
|
|
|
|
IDirectDrawClipper_Release(clipper);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDirectDraw4_QueryInterface(ddraw4, &IID_IDirect3D3, (void **)&d3d3);
|
|
|
|
IDirectDraw4_Release(ddraw4);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
IDirectDrawSurface4_Release(surface);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-01-17 21:13:34 +01:00
|
|
|
memset(&z_fmt, 0, sizeof(z_fmt));
|
|
|
|
hr = IDirect3D3_EnumZBufferFormats(d3d3, &IID_IDirect3DHALDevice, enum_z_fmt, &z_fmt);
|
|
|
|
if (FAILED(hr) || !z_fmt.dwSize)
|
|
|
|
{
|
|
|
|
IDirect3D3_Release(d3d3);
|
|
|
|
IDirectDrawSurface4_Release(surface);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&surface_desc, 0, sizeof(surface_desc));
|
|
|
|
surface_desc.dwSize = sizeof(surface_desc);
|
|
|
|
surface_desc.dwFlags = DDSD_CAPS | DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT;
|
|
|
|
surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
|
|
|
|
U4(surface_desc).ddpfPixelFormat = z_fmt;
|
|
|
|
surface_desc.dwWidth = 640;
|
|
|
|
surface_desc.dwHeight = 480;
|
|
|
|
hr = IDirectDraw4_CreateSurface(ddraw4, &surface_desc, &ds, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to create depth buffer, hr %#x.\n", hr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
IDirect3D3_Release(d3d3);
|
|
|
|
IDirectDrawSurface4_Release(surface);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDirectDrawSurface_AddAttachedSurface(surface, ds);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x.\n", hr);
|
|
|
|
IDirectDrawSurface4_Release(ds);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
IDirect3D3_Release(d3d3);
|
|
|
|
IDirectDrawSurface4_Release(surface);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-12-19 21:00:06 +01:00
|
|
|
hr = IDirect3D3_CreateDevice(d3d3, &IID_IDirect3DHALDevice, surface, &device, NULL);
|
|
|
|
IDirect3D3_Release(d3d3);
|
|
|
|
IDirectDrawSurface4_Release(surface);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return device;
|
|
|
|
}
|
|
|
|
|
2012-03-26 20:28:08 +02:00
|
|
|
static IDirect3DViewport3 *create_viewport(IDirect3DDevice3 *device, UINT x, UINT y, UINT w, UINT h)
|
|
|
|
{
|
|
|
|
IDirect3DViewport3 *viewport;
|
|
|
|
D3DVIEWPORT2 vp;
|
|
|
|
IDirect3D3 *d3d;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
|
|
|
|
hr = IDirect3D3_CreateViewport(d3d, &viewport, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to create viewport, hr %#x.\n", hr);
|
|
|
|
hr = IDirect3DDevice3_AddViewport(device, viewport);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to add viewport, hr %#x.\n", hr);
|
|
|
|
memset(&vp, 0, sizeof(vp));
|
|
|
|
vp.dwSize = sizeof(vp);
|
|
|
|
vp.dwX = x;
|
|
|
|
vp.dwY = y;
|
|
|
|
vp.dwWidth = w;
|
|
|
|
vp.dwHeight = h;
|
|
|
|
vp.dvClipX = -1.0f;
|
|
|
|
vp.dvClipY = 1.0f;
|
|
|
|
vp.dvClipWidth = 2.0f;
|
|
|
|
vp.dvClipHeight = 2.0f;
|
|
|
|
vp.dvMinZ = 0.0f;
|
|
|
|
vp.dvMaxZ = 1.0f;
|
|
|
|
hr = IDirect3DViewport3_SetViewport2(viewport, &vp);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x.\n", hr);
|
|
|
|
IDirect3D3_Release(d3d);
|
|
|
|
|
|
|
|
return viewport;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void destroy_viewport(IDirect3DDevice3 *device, IDirect3DViewport3 *viewport)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IDirect3DDevice3_DeleteViewport(device, viewport);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to delete viewport, hr %#x.\n", hr);
|
|
|
|
IDirect3DViewport3_Release(viewport);
|
|
|
|
}
|
|
|
|
|
2011-12-19 21:00:06 +01:00
|
|
|
static void test_process_vertices(void)
|
|
|
|
{
|
|
|
|
IDirect3DVertexBuffer *src_vb, *dst_vb;
|
|
|
|
IDirect3DViewport3 *viewport;
|
|
|
|
D3DVERTEXBUFFERDESC vb_desc;
|
|
|
|
IDirect3DDevice3 *device;
|
|
|
|
struct vec3 *src_data;
|
|
|
|
struct vec4 *dst_data;
|
|
|
|
IDirect3D3 *d3d3;
|
|
|
|
D3DVIEWPORT2 vp2;
|
|
|
|
D3DVIEWPORT vp1;
|
|
|
|
HWND window;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
static D3DMATRIX identity =
|
|
|
|
{
|
|
|
|
1.0f, 0.0f, 0.0f, 0.0f,
|
|
|
|
0.0f, 1.0f, 0.0f, 0.0f,
|
|
|
|
0.0f, 0.0f, 1.0f, 0.0f,
|
|
|
|
0.0f, 0.0f, 0.0f, 1.0f,
|
|
|
|
};
|
|
|
|
static D3DMATRIX projection =
|
|
|
|
{
|
|
|
|
1.0f, 0.0f, 0.0f, 0.0f,
|
|
|
|
0.0f, 1.0f, 0.0f, 0.0f,
|
|
|
|
0.0f, 0.0f, 1.0f, 0.0f,
|
|
|
|
6.0f, 7.0f, 8.0f, 1.0f,
|
|
|
|
};
|
|
|
|
|
|
|
|
window = CreateWindowA("static", "d3d7_test", WS_OVERLAPPEDWINDOW,
|
|
|
|
0, 0, 640, 480, 0, 0, 0, 0);
|
|
|
|
if (!(device = create_device(window, DDSCL_NORMAL)))
|
|
|
|
{
|
|
|
|
skip("Failed to create a 3D device, skipping test.\n");
|
|
|
|
DestroyWindow(window);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDirect3DDevice3_GetDirect3D(device, &d3d3);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to get Direct3D3 interface, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
memset(&vb_desc, 0, sizeof(vb_desc));
|
|
|
|
vb_desc.dwSize = sizeof(vb_desc);
|
|
|
|
vb_desc.dwFVF = D3DFVF_XYZ;
|
|
|
|
vb_desc.dwNumVertices = 3;
|
|
|
|
hr = IDirect3D3_CreateVertexBuffer(d3d3, &vb_desc, &src_vb, 0, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to create source vertex buffer, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDirect3DVertexBuffer_Lock(src_vb, DDLOCK_WRITEONLY, (void **)&src_data, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to lock source vertex buffer, hr %#x.\n", hr);
|
|
|
|
src_data[0].x = -1.0f;
|
|
|
|
src_data[0].y = -1.0f;
|
|
|
|
src_data[0].z = -1.0f;
|
|
|
|
src_data[1].x = 0.0f;
|
|
|
|
src_data[1].y = 0.0f;
|
|
|
|
src_data[1].z = 0.0f;
|
|
|
|
src_data[2].x = 1.0f;
|
|
|
|
src_data[2].y = 1.0f;
|
|
|
|
src_data[2].z = 1.0f;
|
|
|
|
hr = IDirect3DVertexBuffer_Unlock(src_vb);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to unlock source vertex buffer, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
memset(&vb_desc, 0, sizeof(vb_desc));
|
|
|
|
vb_desc.dwSize = sizeof(vb_desc);
|
|
|
|
vb_desc.dwFVF = D3DFVF_XYZRHW;
|
|
|
|
vb_desc.dwNumVertices = 3;
|
|
|
|
hr = IDirect3D3_CreateVertexBuffer(d3d3, &vb_desc, &dst_vb, 0, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to create destination vertex buffer, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDirect3D3_CreateViewport(d3d3, &viewport, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to create viewport, hr %#x.\n", hr);
|
|
|
|
hr = IDirect3DDevice3_AddViewport(device, viewport);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to add viewport, hr %#x.\n", hr);
|
|
|
|
vp2.dwSize = sizeof(vp2);
|
|
|
|
vp2.dwX = 10;
|
|
|
|
vp2.dwY = 20;
|
|
|
|
vp2.dwWidth = 100;
|
|
|
|
vp2.dwHeight = 200;
|
|
|
|
vp2.dvClipX = 2.0f;
|
|
|
|
vp2.dvClipY = 3.0f;
|
|
|
|
vp2.dvClipWidth = 4.0f;
|
|
|
|
vp2.dvClipHeight = 5.0f;
|
|
|
|
vp2.dvMinZ = -2.0f;
|
|
|
|
vp2.dvMaxZ = 3.0f;
|
|
|
|
hr = IDirect3DViewport3_SetViewport2(viewport, &vp2);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x.\n", hr);
|
|
|
|
hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &identity);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set world transformation, hr %#x.\n", hr);
|
|
|
|
hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &identity);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set view transformation, hr %#x.\n", hr);
|
|
|
|
hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &identity);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set projection transformation, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDirect3DVertexBuffer_ProcessVertices(dst_vb, D3DVOP_TRANSFORM, 0, 3, src_vb, 0, device, 0);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to process vertices, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDirect3DVertexBuffer_Lock(dst_vb, DDLOCK_READONLY, (void **)&dst_data, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to lock destination vertex buffer, hr %#x.\n", hr);
|
2011-12-21 21:34:56 +01:00
|
|
|
ok(compare_vec4(&dst_data[0], -6.500e+1f, +1.800e+2f, +2.000e-1f, +1.000e+0f, 4096),
|
2011-12-19 21:00:06 +01:00
|
|
|
"Got unexpected vertex 0 {%.8e, %.8e, %.8e, %.8e}.\n",
|
|
|
|
dst_data[0].x, dst_data[0].y, dst_data[0].z, dst_data[0].w);
|
2011-12-21 21:34:56 +01:00
|
|
|
ok(compare_vec4(&dst_data[1], -4.000e+1f, +1.400e+2f, +4.000e-1f, +1.000e+0f, 4096),
|
2011-12-19 21:00:06 +01:00
|
|
|
"Got unexpected vertex 1 {%.8e, %.8e, %.8e, %.8e}.\n",
|
|
|
|
dst_data[1].x, dst_data[1].y, dst_data[1].z, dst_data[1].w);
|
2011-12-21 21:34:56 +01:00
|
|
|
ok(compare_vec4(&dst_data[2], -1.500e+1f, +1.000e+2f, +6.000e-1f, +1.000e+0f, 4096),
|
2011-12-19 21:00:06 +01:00
|
|
|
"Got unexpected vertex 2 {%.8e, %.8e, %.8e, %.8e}.\n",
|
|
|
|
dst_data[2].x, dst_data[2].y, dst_data[2].z, dst_data[2].w);
|
|
|
|
hr = IDirect3DVertexBuffer_Unlock(dst_vb);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to unlock destination vertex buffer, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDirect3DDevice3_MultiplyTransform(device, D3DTRANSFORMSTATE_PROJECTION, &projection);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set projection transformation, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDirect3DVertexBuffer_ProcessVertices(dst_vb, D3DVOP_TRANSFORM, 0, 3, src_vb, 0, device, 0);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to process vertices, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDirect3DVertexBuffer_Lock(dst_vb, DDLOCK_READONLY, (void **)&dst_data, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to lock destination vertex buffer, hr %#x.\n", hr);
|
2011-12-21 21:34:56 +01:00
|
|
|
ok(compare_vec4(&dst_data[0], +8.500e+1f, -1.000e+2f, +1.800e+0f, +1.000e+0f, 4096),
|
2011-12-19 21:00:06 +01:00
|
|
|
"Got unexpected vertex 0 {%.8e, %.8e, %.8e, %.8e}.\n",
|
|
|
|
dst_data[0].x, dst_data[0].y, dst_data[0].z, dst_data[0].w);
|
2011-12-21 21:34:56 +01:00
|
|
|
ok(compare_vec4(&dst_data[1], +1.100e+2f, -1.400e+2f, +2.000e+0f, +1.000e+0f, 4096),
|
2011-12-19 21:00:06 +01:00
|
|
|
"Got unexpected vertex 1 {%.8e, %.8e, %.8e, %.8e}.\n",
|
|
|
|
dst_data[1].x, dst_data[1].y, dst_data[1].z, dst_data[1].w);
|
2011-12-21 21:34:56 +01:00
|
|
|
ok(compare_vec4(&dst_data[2], +1.350e+2f, -1.800e+2f, +2.200e+0f, +1.000e+0f, 4096),
|
2011-12-19 21:00:06 +01:00
|
|
|
"Got unexpected vertex 2 {%.8e, %.8e, %.8e, %.8e}.\n",
|
|
|
|
dst_data[2].x, dst_data[2].y, dst_data[2].z, dst_data[2].w);
|
|
|
|
hr = IDirect3DVertexBuffer_Unlock(dst_vb);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to unlock destination vertex buffer, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
vp2.dwSize = sizeof(vp2);
|
|
|
|
vp2.dwX = 30;
|
|
|
|
vp2.dwY = 40;
|
|
|
|
vp2.dwWidth = 90;
|
|
|
|
vp2.dwHeight = 80;
|
|
|
|
vp2.dvClipX = 4.0f;
|
|
|
|
vp2.dvClipY = 6.0f;
|
|
|
|
vp2.dvClipWidth = 2.0f;
|
|
|
|
vp2.dvClipHeight = 4.0f;
|
|
|
|
vp2.dvMinZ = 3.0f;
|
|
|
|
vp2.dvMaxZ = -2.0f;
|
|
|
|
hr = IDirect3DViewport3_SetViewport2(viewport, &vp2);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDirect3DVertexBuffer_ProcessVertices(dst_vb, D3DVOP_TRANSFORM, 0, 3, src_vb, 0, device, 0);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to process vertices, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDirect3DVertexBuffer_Lock(dst_vb, DDLOCK_READONLY, (void **)&dst_data, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to lock destination vertex buffer, hr %#x.\n", hr);
|
2011-12-21 21:34:56 +01:00
|
|
|
ok(compare_vec4(&dst_data[0], +7.500e+1f, +4.000e+1f, -8.000e-1f, +1.000e+0f, 4096),
|
2011-12-19 21:00:06 +01:00
|
|
|
"Got unexpected vertex 0 {%.8e, %.8e, %.8e, %.8e}.\n",
|
|
|
|
dst_data[0].x, dst_data[0].y, dst_data[0].z, dst_data[0].w);
|
2011-12-21 21:34:56 +01:00
|
|
|
ok(compare_vec4(&dst_data[1], +1.200e+2f, +2.000e+1f, -1.000e+0f, +1.000e+0f, 4096),
|
2011-12-19 21:00:06 +01:00
|
|
|
"Got unexpected vertex 1 {%.8e, %.8e, %.8e, %.8e}.\n",
|
|
|
|
dst_data[1].x, dst_data[1].y, dst_data[1].z, dst_data[1].w);
|
2011-12-21 21:34:56 +01:00
|
|
|
ok(compare_vec4(&dst_data[2], +1.650e+2f, +0.000e+0f, -1.200e+0f, +1.000e+0f, 4096),
|
2011-12-19 21:00:06 +01:00
|
|
|
"Got unexpected vertex 2 {%.8e, %.8e, %.8e, %.8e}.\n",
|
|
|
|
dst_data[2].x, dst_data[2].y, dst_data[2].z, dst_data[2].w);
|
|
|
|
hr = IDirect3DVertexBuffer_Unlock(dst_vb);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to unlock destination vertex buffer, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
vp1.dwSize = sizeof(vp1);
|
|
|
|
vp1.dwX = 30;
|
|
|
|
vp1.dwY = 40;
|
|
|
|
vp1.dwWidth = 90;
|
|
|
|
vp1.dwHeight = 80;
|
|
|
|
vp1.dvScaleX = 7.0f;
|
|
|
|
vp1.dvScaleY = 2.0f;
|
|
|
|
vp1.dvMaxX = 6.0f;
|
|
|
|
vp1.dvMaxY = 10.0f;
|
|
|
|
vp1.dvMinZ = -2.0f;
|
|
|
|
vp1.dvMaxZ = 3.0f;
|
|
|
|
hr = IDirect3DViewport3_SetViewport(viewport, &vp1);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDirect3DVertexBuffer_ProcessVertices(dst_vb, D3DVOP_TRANSFORM, 0, 3, src_vb, 0, device, 0);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to process vertices, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDirect3DVertexBuffer_Lock(dst_vb, DDLOCK_READONLY, (void **)&dst_data, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to lock destination vertex buffer, hr %#x.\n", hr);
|
2011-12-21 21:34:56 +01:00
|
|
|
ok(compare_vec4(&dst_data[0], +1.100e+2f, +6.800e+1f, +7.000e+0f, +1.000e+0f, 4096),
|
2011-12-19 21:00:06 +01:00
|
|
|
"Got unexpected vertex 0 {%.8e, %.8e, %.8e, %.8e}.\n",
|
|
|
|
dst_data[0].x, dst_data[0].y, dst_data[0].z, dst_data[0].w);
|
2011-12-21 21:34:56 +01:00
|
|
|
ok(compare_vec4(&dst_data[1], +1.170e+2f, +6.600e+1f, +8.000e+0f, +1.000e+0f, 4096),
|
2011-12-19 21:00:06 +01:00
|
|
|
"Got unexpected vertex 1 {%.8e, %.8e, %.8e, %.8e}.\n",
|
|
|
|
dst_data[1].x, dst_data[1].y, dst_data[1].z, dst_data[1].w);
|
2011-12-21 21:34:56 +01:00
|
|
|
ok(compare_vec4(&dst_data[2], +1.240e+2f, +6.400e+1f, +9.000e+0f, +1.000e+0f, 4096),
|
2011-12-19 21:00:06 +01:00
|
|
|
"Got unexpected vertex 2 {%.8e, %.8e, %.8e, %.8e}.\n",
|
|
|
|
dst_data[2].x, dst_data[2].y, dst_data[2].z, dst_data[2].w);
|
|
|
|
hr = IDirect3DVertexBuffer_Unlock(dst_vb);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to unlock destination vertex buffer, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDirect3DDevice3_DeleteViewport(device, viewport);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to delete viewport, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
IDirect3DVertexBuffer_Release(dst_vb);
|
|
|
|
IDirect3DVertexBuffer_Release(src_vb);
|
|
|
|
IDirect3DViewport3_Release(viewport);
|
|
|
|
IDirect3D3_Release(d3d3);
|
|
|
|
IDirect3DDevice3_Release(device);
|
|
|
|
DestroyWindow(window);
|
|
|
|
}
|
|
|
|
|
2011-12-21 21:34:58 +01:00
|
|
|
static void test_coop_level_create_device_window(void)
|
|
|
|
{
|
|
|
|
HWND focus_window, device_window;
|
|
|
|
IDirectDraw4 *ddraw;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
focus_window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
|
|
|
|
0, 0, 640, 480, 0, 0, 0, 0);
|
|
|
|
if (!(ddraw = create_ddraw()))
|
|
|
|
{
|
|
|
|
skip("Failed to create a ddraw object, skipping test.\n");
|
|
|
|
DestroyWindow(focus_window);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
|
|
|
|
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
|
|
|
|
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
|
|
|
ok(!device_window, "Unexpected device window found.\n");
|
|
|
|
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW);
|
|
|
|
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
|
|
|
|
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
|
|
|
ok(!device_window, "Unexpected device window found.\n");
|
|
|
|
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL);
|
2011-12-22 21:51:18 +01:00
|
|
|
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
|
2011-12-21 21:34:58 +01:00
|
|
|
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
|
|
|
ok(!device_window, "Unexpected device window found.\n");
|
|
|
|
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL | DDSCL_FULLSCREEN);
|
2011-12-22 21:51:18 +01:00
|
|
|
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
|
2011-12-21 21:34:58 +01:00
|
|
|
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
|
|
|
ok(!device_window, "Unexpected device window found.\n");
|
|
|
|
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
|
2011-12-22 21:51:20 +01:00
|
|
|
ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#x.\n", hr);
|
2011-12-21 21:34:58 +01:00
|
|
|
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
|
|
|
ok(!device_window, "Unexpected device window found.\n");
|
|
|
|
|
|
|
|
/* Windows versions before 98 / NT5 don't support DDSCL_CREATEDEVICEWINDOW. */
|
|
|
|
if (broken(hr == DDERR_INVALIDPARAMS))
|
|
|
|
{
|
|
|
|
win_skip("DDSCL_CREATEDEVICEWINDOW not supported, skipping test.\n");
|
|
|
|
IDirectDraw4_Release(ddraw);
|
|
|
|
DestroyWindow(focus_window);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
|
|
|
|
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
|
|
|
|
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
|
|
|
ok(!device_window, "Unexpected device window found.\n");
|
|
|
|
hr = IDirectDraw4_SetCooperativeLevel(ddraw, focus_window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
|
|
|
|
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
|
|
|
|
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
|
|
|
ok(!device_window, "Unexpected device window found.\n");
|
|
|
|
|
|
|
|
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
|
|
|
|
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
|
|
|
|
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
|
|
|
ok(!device_window, "Unexpected device window found.\n");
|
|
|
|
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_SETFOCUSWINDOW
|
|
|
|
| DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
|
2011-12-22 21:51:21 +01:00
|
|
|
ok(hr == DDERR_NOHWND, "Got unexpected hr %#x.\n", hr);
|
2011-12-21 21:34:58 +01:00
|
|
|
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
2011-12-22 21:51:22 +01:00
|
|
|
ok(!!device_window, "Device window not found.\n");
|
2011-12-21 21:34:58 +01:00
|
|
|
|
|
|
|
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
|
|
|
|
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
|
|
|
|
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
|
|
|
ok(!device_window, "Unexpected device window found.\n");
|
|
|
|
hr = IDirectDraw4_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW
|
|
|
|
| DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
|
2011-12-22 21:51:21 +01:00
|
|
|
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
|
2011-12-21 21:34:58 +01:00
|
|
|
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
2011-12-22 21:51:22 +01:00
|
|
|
ok(!!device_window, "Device window not found.\n");
|
2011-12-21 21:34:58 +01:00
|
|
|
|
|
|
|
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
|
|
|
|
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
|
|
|
|
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
|
|
|
ok(!device_window, "Unexpected device window found.\n");
|
|
|
|
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
|
2011-12-22 21:51:20 +01:00
|
|
|
ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#x.\n", hr);
|
2011-12-21 21:34:58 +01:00
|
|
|
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
|
|
|
ok(!device_window, "Unexpected device window found.\n");
|
|
|
|
hr = IDirectDraw4_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW);
|
|
|
|
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
|
|
|
|
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
|
|
|
ok(!device_window, "Unexpected device window found.\n");
|
|
|
|
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
|
2011-12-22 21:51:20 +01:00
|
|
|
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
|
2011-12-21 21:34:58 +01:00
|
|
|
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
|
2011-12-22 21:51:22 +01:00
|
|
|
ok(!!device_window, "Device window not found.\n");
|
2011-12-21 21:34:58 +01:00
|
|
|
|
|
|
|
IDirectDraw4_Release(ddraw);
|
|
|
|
DestroyWindow(focus_window);
|
|
|
|
}
|
|
|
|
|
2012-01-04 23:34:52 +01:00
|
|
|
static void test_clipper_blt(void)
|
|
|
|
{
|
|
|
|
IDirectDrawSurface4 *src_surface, *dst_surface;
|
|
|
|
RECT client_rect, src_rect, *rect;
|
|
|
|
IDirectDrawClipper *clipper;
|
|
|
|
DDSURFACEDESC2 surface_desc;
|
|
|
|
unsigned int i, j, x, y;
|
|
|
|
IDirectDraw4 *ddraw;
|
|
|
|
RGNDATA *rgn_data;
|
|
|
|
D3DCOLOR color;
|
|
|
|
HRGN r1, r2;
|
|
|
|
HWND window;
|
|
|
|
DDBLTFX fx;
|
|
|
|
HRESULT hr;
|
2012-01-17 21:13:33 +01:00
|
|
|
DWORD *ptr;
|
2012-01-04 23:34:52 +01:00
|
|
|
DWORD ret;
|
|
|
|
|
2012-01-17 21:13:33 +01:00
|
|
|
static const DWORD src_data[] =
|
|
|
|
{
|
|
|
|
0xff0000ff, 0xff0000ff, 0xff00ff00, 0xffff0000, 0xffffffff, 0xffffffff,
|
|
|
|
0xff0000ff, 0xff0000ff, 0xff00ff00, 0xffff0000, 0xffffffff, 0xffffffff,
|
|
|
|
0xff0000ff, 0xff0000ff, 0xff00ff00, 0xffff0000, 0xffffffff, 0xffffffff,
|
|
|
|
};
|
2012-01-04 23:34:52 +01:00
|
|
|
static const D3DCOLOR expected1[] =
|
|
|
|
{
|
|
|
|
0x000000ff, 0x0000ff00, 0x00000000, 0x00000000,
|
|
|
|
0x000000ff, 0x0000ff00, 0x00000000, 0x00000000,
|
|
|
|
0x00000000, 0x00000000, 0x00ff0000, 0x00ffffff,
|
|
|
|
0x00000000, 0x00000000, 0x00ff0000, 0x00ffffff,
|
|
|
|
};
|
|
|
|
static const D3DCOLOR expected2[] =
|
|
|
|
{
|
|
|
|
0x000000ff, 0x000000ff, 0x00000000, 0x00000000,
|
|
|
|
0x000000ff, 0x000000ff, 0x00000000, 0x00000000,
|
|
|
|
0x00000000, 0x00000000, 0x000000ff, 0x000000ff,
|
|
|
|
0x00000000, 0x00000000, 0x000000ff, 0x000000ff,
|
|
|
|
};
|
|
|
|
|
|
|
|
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
|
|
|
|
10, 10, 640, 480, 0, 0, 0, 0);
|
|
|
|
ShowWindow(window, SW_SHOW);
|
|
|
|
if (!(ddraw = create_ddraw()))
|
|
|
|
{
|
|
|
|
skip("Failed to create a ddraw object, skipping test.\n");
|
|
|
|
DestroyWindow(window);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = GetClientRect(window, &client_rect);
|
|
|
|
ok(ret, "Failed to get client rect.\n");
|
|
|
|
ret = MapWindowPoints(window, NULL, (POINT *)&client_rect, 2);
|
|
|
|
ok(ret, "Failed to map client rect.\n");
|
|
|
|
|
|
|
|
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDirectDraw4_CreateClipper(ddraw, 0, &clipper, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
|
2012-01-06 11:20:04 +01:00
|
|
|
hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
|
|
|
|
ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#x.\n", hr);
|
2012-01-04 23:34:52 +01:00
|
|
|
hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
|
|
|
|
hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#x.\n", hr);
|
|
|
|
rgn_data = HeapAlloc(GetProcessHeap(), 0, ret);
|
|
|
|
hr = IDirectDrawClipper_GetClipList(clipper, NULL, rgn_data, &ret);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to get clip list, hr %#x.\n", hr);
|
|
|
|
ok(rgn_data->rdh.dwSize == sizeof(rgn_data->rdh), "Got unexpected structure size %#x.\n", rgn_data->rdh.dwSize);
|
|
|
|
ok(rgn_data->rdh.iType == RDH_RECTANGLES, "Got unexpected type %#x.\n", rgn_data->rdh.iType);
|
|
|
|
ok(rgn_data->rdh.nCount == 1, "Got unexpected count %u.\n", rgn_data->rdh.nCount);
|
|
|
|
ok(rgn_data->rdh.nRgnSize == 16, "Got unexpected region size %u.\n", rgn_data->rdh.nRgnSize);
|
|
|
|
ok(EqualRect(&rgn_data->rdh.rcBound, &client_rect),
|
|
|
|
"Got unexpected bounding rect {%d, %d, %d, %d}, expected {%d, %d, %d, %d}.\n",
|
|
|
|
rgn_data->rdh.rcBound.left, rgn_data->rdh.rcBound.top,
|
|
|
|
rgn_data->rdh.rcBound.right, rgn_data->rdh.rcBound.bottom,
|
|
|
|
client_rect.left, client_rect.top, client_rect.right, client_rect.bottom);
|
|
|
|
rect = (RECT *)&rgn_data->Buffer[0];
|
|
|
|
ok(EqualRect(rect, &client_rect),
|
|
|
|
"Got unexpected clip rect {%d, %d, %d, %d}, expected {%d, %d, %d, %d}.\n",
|
|
|
|
rect->left, rect->top, rect->right, rect->bottom,
|
|
|
|
client_rect.left, client_rect.top, client_rect.right, client_rect.bottom);
|
|
|
|
HeapFree(GetProcessHeap(), 0, rgn_data);
|
|
|
|
|
|
|
|
r1 = CreateRectRgn(0, 0, 320, 240);
|
|
|
|
ok(!!r1, "Failed to create region.\n");
|
|
|
|
r2 = CreateRectRgn(320, 240, 640, 480);
|
|
|
|
ok(!!r2, "Failed to create region.\n");
|
|
|
|
CombineRgn(r1, r1, r2, RGN_OR);
|
|
|
|
ret = GetRegionData(r1, 0, NULL);
|
|
|
|
rgn_data = HeapAlloc(GetProcessHeap(), 0, ret);
|
|
|
|
ret = GetRegionData(r1, ret, rgn_data);
|
|
|
|
ok(!!ret, "Failed to get region data.\n");
|
|
|
|
|
|
|
|
DeleteObject(r2);
|
|
|
|
DeleteObject(r1);
|
|
|
|
|
|
|
|
hr = IDirectDrawClipper_SetClipList(clipper, rgn_data, 0);
|
2012-01-04 23:34:53 +01:00
|
|
|
ok(hr == DDERR_CLIPPERISUSINGHWND, "Got unexpected hr %#x.\n", hr);
|
2012-01-04 23:34:52 +01:00
|
|
|
hr = IDirectDrawClipper_SetHWnd(clipper, 0, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
|
|
|
|
hr = IDirectDrawClipper_SetClipList(clipper, rgn_data, 0);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set clip list, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, rgn_data);
|
|
|
|
|
|
|
|
memset(&surface_desc, 0, sizeof(surface_desc));
|
|
|
|
surface_desc.dwSize = sizeof(surface_desc);
|
|
|
|
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
|
|
|
|
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
|
|
|
surface_desc.dwWidth = 640;
|
|
|
|
surface_desc.dwHeight = 480;
|
2012-01-09 09:27:56 +01:00
|
|
|
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;
|
2012-01-04 23:34:52 +01:00
|
|
|
|
|
|
|
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &src_surface, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to create source surface, hr %#x.\n", hr);
|
|
|
|
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &dst_surface, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to create destination surface, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
memset(&fx, 0, sizeof(fx));
|
|
|
|
fx.dwSize = sizeof(fx);
|
|
|
|
hr = IDirectDrawSurface4_Blt(src_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to clear source surface, hr %#x.\n", hr);
|
|
|
|
hr = IDirectDrawSurface4_Blt(dst_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#x.\n", hr);
|
|
|
|
|
2012-01-11 21:27:31 +01:00
|
|
|
hr = IDirectDrawSurface4_Lock(src_surface, NULL, &surface_desc, DDLOCK_WAIT, NULL);
|
2012-01-04 23:34:52 +01:00
|
|
|
ok(SUCCEEDED(hr), "Failed to lock source surface, hr %#x.\n", hr);
|
2012-01-22 19:26:47 +01:00
|
|
|
ok(U1(surface_desc).lPitch == 2560, "Got unexpected surface pitch %u.\n", U1(surface_desc).lPitch);
|
2012-01-17 21:13:33 +01:00
|
|
|
ptr = surface_desc.lpSurface;
|
|
|
|
memcpy(&ptr[ 0], &src_data[ 0], 6 * sizeof(DWORD));
|
|
|
|
memcpy(&ptr[ 640], &src_data[ 6], 6 * sizeof(DWORD));
|
|
|
|
memcpy(&ptr[1280], &src_data[12], 6 * sizeof(DWORD));
|
2012-01-04 23:34:52 +01:00
|
|
|
hr = IDirectDrawSurface4_Unlock(src_surface, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to unlock source surface, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDirectDrawSurface4_SetClipper(dst_surface, clipper);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set clipper, hr %#x.\n", hr);
|
|
|
|
|
2012-01-17 21:13:33 +01:00
|
|
|
SetRect(&src_rect, 1, 1, 5, 2);
|
2012-01-04 23:34:52 +01:00
|
|
|
hr = IDirectDrawSurface4_Blt(dst_surface, NULL, src_surface, &src_rect, DDBLT_WAIT, NULL);
|
2012-01-06 11:20:05 +01:00
|
|
|
ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
|
2012-01-04 23:34:52 +01:00
|
|
|
for (i = 0; i < 4; ++i)
|
|
|
|
{
|
|
|
|
for (j = 0; j < 4; ++j)
|
|
|
|
{
|
|
|
|
x = 80 * ((2 * j) + 1);
|
|
|
|
y = 60 * ((2 * i) + 1);
|
|
|
|
color = get_surface_color(dst_surface, x, y);
|
2012-01-06 11:20:05 +01:00
|
|
|
ok(compare_color(color, expected1[i * 4 + j], 1),
|
|
|
|
"Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected1[i * 4 + j], x, y, color);
|
2012-01-04 23:34:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
U5(fx).dwFillColor = 0xff0000ff;
|
|
|
|
hr = IDirectDrawSurface4_Blt(dst_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
|
2012-01-06 11:20:04 +01:00
|
|
|
ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#x.\n", hr);
|
2012-01-04 23:34:52 +01:00
|
|
|
for (i = 0; i < 4; ++i)
|
|
|
|
{
|
|
|
|
for (j = 0; j < 4; ++j)
|
|
|
|
{
|
|
|
|
x = 80 * ((2 * j) + 1);
|
|
|
|
y = 60 * ((2 * i) + 1);
|
|
|
|
color = get_surface_color(dst_surface, x, y);
|
2012-01-06 11:20:04 +01:00
|
|
|
ok(compare_color(color, expected2[i * 4 + j], 1),
|
|
|
|
"Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected2[i * 4 + j], x, y, color);
|
2012-01-04 23:34:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDirectDrawSurface4_BltFast(dst_surface, 0, 0, src_surface, NULL, DDBLTFAST_WAIT);
|
2012-01-04 23:34:54 +01:00
|
|
|
ok(hr == DDERR_BLTFASTCANTCLIP, "Got unexpected hr %#x.\n", hr);
|
2012-01-04 23:34:52 +01:00
|
|
|
|
2012-01-09 22:16:48 +01:00
|
|
|
hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
|
|
|
|
hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#x.\n", hr);
|
|
|
|
DestroyWindow(window);
|
|
|
|
hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
|
|
|
|
ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
|
|
|
|
hr = IDirectDrawClipper_SetHWnd(clipper, 0, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
|
|
|
|
hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#x.\n", hr);
|
2012-01-09 22:16:49 +01:00
|
|
|
hr = IDirectDrawClipper_SetClipList(clipper, NULL, 0);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set clip list, hr %#x.\n", hr);
|
|
|
|
hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
|
|
|
|
ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#x.\n", hr);
|
|
|
|
hr = IDirectDrawSurface4_Blt(dst_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
|
|
|
|
ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#x.\n", hr);
|
2012-01-09 22:16:48 +01:00
|
|
|
|
2012-01-04 23:34:52 +01:00
|
|
|
IDirectDrawSurface4_Release(dst_surface);
|
|
|
|
IDirectDrawSurface4_Release(src_surface);
|
|
|
|
IDirectDrawClipper_Release(clipper);
|
|
|
|
IDirectDraw4_Release(ddraw);
|
|
|
|
}
|
|
|
|
|
2012-01-17 21:13:34 +01:00
|
|
|
static void test_coop_level_d3d_state(void)
|
|
|
|
{
|
|
|
|
D3DRECT clear_rect = {{0}, {0}, {640}, {480}};
|
|
|
|
IDirectDrawSurface4 *rt, *surface;
|
|
|
|
IDirect3DViewport3 *viewport;
|
|
|
|
IDirect3DDevice3 *device;
|
|
|
|
IDirectDraw4 *ddraw;
|
|
|
|
IDirect3D3 *d3d;
|
|
|
|
D3DCOLOR color;
|
|
|
|
DWORD value;
|
|
|
|
HWND window;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-03-26 20:28:08 +02:00
|
|
|
viewport = create_viewport(device, 0, 0, 640, 480);
|
2012-01-17 21:13:34 +01:00
|
|
|
|
|
|
|
hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
|
|
|
|
hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_ZENABLE, &value);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
|
|
|
|
ok(!!value, "Got unexpected z-enable state %#x.\n", value);
|
|
|
|
hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, &value);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
|
|
|
|
ok(!value, "Got unexpected alpha blend enable state %#x.\n", value);
|
|
|
|
hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
|
|
|
|
hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xffff0000, 0.0f, 0);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
|
|
|
|
color = get_surface_color(rt, 320, 240);
|
|
|
|
ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
|
|
|
|
|
2012-03-26 20:28:08 +02:00
|
|
|
hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
|
2012-01-17 21:13:34 +01:00
|
|
|
hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
|
|
|
|
IDirect3D3_Release(d3d);
|
|
|
|
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
|
|
|
|
hr = IDirectDrawSurface4_IsLost(rt);
|
|
|
|
ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
|
|
|
|
hr = IDirectDraw4_RestoreAllSurfaces(ddraw);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to restore surfaces, hr %#x.\n", hr);
|
|
|
|
IDirectDraw4_Release(ddraw);
|
|
|
|
|
|
|
|
hr = IDirect3DDevice3_GetRenderTarget(device, &surface);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
|
|
|
|
ok(surface == rt, "Got unexpected surface %p.\n", surface);
|
|
|
|
hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_ZENABLE, &value);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
|
2012-01-17 21:13:35 +01:00
|
|
|
ok(!!value, "Got unexpected z-enable state %#x.\n", value);
|
2012-01-17 21:13:34 +01:00
|
|
|
hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, &value);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
|
2012-01-17 21:13:35 +01:00
|
|
|
ok(!!value, "Got unexpected alpha blend enable state %#x.\n", value);
|
2012-01-17 21:13:34 +01:00
|
|
|
hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xff00ff00, 0.0f, 0);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
|
|
|
|
color = get_surface_color(rt, 320, 240);
|
2012-01-17 21:13:35 +01:00
|
|
|
ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
|
2012-01-17 21:13:34 +01:00
|
|
|
|
2012-03-26 20:28:08 +02:00
|
|
|
destroy_viewport(device, viewport);
|
2012-01-17 21:13:34 +01:00
|
|
|
IDirectDrawSurface4_Release(surface);
|
|
|
|
IDirectDrawSurface4_Release(rt);
|
|
|
|
IDirect3DDevice3_Release(device);
|
|
|
|
DestroyWindow(window);
|
|
|
|
}
|
|
|
|
|
2012-01-23 22:34:48 +01:00
|
|
|
static void test_surface_interface_mismatch(void)
|
|
|
|
{
|
|
|
|
IDirectDraw4 *ddraw = NULL;
|
|
|
|
IDirect3D3 *d3d = NULL;
|
|
|
|
IDirectDrawSurface4 *surface = NULL, *ds;
|
|
|
|
IDirectDrawSurface3 *surface3 = NULL;
|
|
|
|
IDirect3DDevice3 *device = NULL;
|
|
|
|
IDirect3DViewport3 *viewport = NULL;
|
|
|
|
DDSURFACEDESC2 surface_desc;
|
|
|
|
DDPIXELFORMAT z_fmt;
|
2012-01-30 21:19:48 +01:00
|
|
|
ULONG refcount;
|
2012-01-23 22:34:48 +01:00
|
|
|
HRESULT hr;
|
|
|
|
D3DCOLOR color;
|
|
|
|
HWND window;
|
|
|
|
D3DRECT clear_rect = {{0}, {0}, {640}, {480}};
|
|
|
|
|
|
|
|
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
|
|
|
|
0, 0, 640, 480, 0, 0, 0, 0);
|
|
|
|
|
|
|
|
if (!(ddraw = create_ddraw()))
|
|
|
|
{
|
|
|
|
skip("Failed to create a ddraw object, skipping test.\n");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set cooperative level, 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;
|
|
|
|
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
|
|
|
|
surface_desc.dwWidth = 640;
|
|
|
|
surface_desc.dwHeight = 480;
|
|
|
|
|
|
|
|
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDirectDrawSurface4_QueryInterface(surface, &IID_IDirectDrawSurface3, (void **)&surface3);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to QI IDirectDrawSurface3, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDirectDraw4_QueryInterface(ddraw, &IID_IDirect3D3, (void **)&d3d);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
skip("Failed to get the IDirect3D7 interface, skipping test.\n");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&z_fmt, 0, sizeof(z_fmt));
|
|
|
|
hr = IDirect3D3_EnumZBufferFormats(d3d, &IID_IDirect3DHALDevice, enum_z_fmt, &z_fmt);
|
|
|
|
if (FAILED(hr) || !z_fmt.dwSize)
|
|
|
|
{
|
|
|
|
skip("No depth buffer formats available, skipping test.\n");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&surface_desc, 0, sizeof(surface_desc));
|
|
|
|
surface_desc.dwSize = sizeof(surface_desc);
|
|
|
|
surface_desc.dwFlags = DDSD_CAPS | DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT;
|
|
|
|
surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
|
|
|
|
U4(surface_desc).ddpfPixelFormat = z_fmt;
|
|
|
|
surface_desc.dwWidth = 640;
|
|
|
|
surface_desc.dwHeight = 480;
|
|
|
|
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &ds, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to create depth buffer, hr %#x.\n", hr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* Using a different surface interface version still works */
|
|
|
|
hr = IDirectDrawSurface3_AddAttachedSurface(surface3, (IDirectDrawSurface3 *)ds);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x.\n", hr);
|
2012-01-30 21:19:48 +01:00
|
|
|
refcount = IDirectDrawSurface4_Release(ds);
|
|
|
|
ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
|
2012-01-23 22:34:48 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* Here too */
|
|
|
|
hr = IDirect3D3_CreateDevice(d3d, &IID_IDirect3DHALDevice, (IDirectDrawSurface4 *)surface3, &device, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to create d3d device.\n");
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2012-03-26 20:28:08 +02:00
|
|
|
viewport = create_viewport(device, 0, 0, 640, 480);
|
2012-01-23 22:34:48 +01:00
|
|
|
|
|
|
|
hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xffff0000, 0.0f, 0);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
|
|
|
|
color = get_surface_color(surface, 320, 240);
|
|
|
|
ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (viewport)
|
2012-03-26 20:28:08 +02:00
|
|
|
destroy_viewport(device, viewport);
|
2012-01-23 22:34:48 +01:00
|
|
|
if (surface3) IDirectDrawSurface3_Release(surface3);
|
|
|
|
if (surface) IDirectDrawSurface4_Release(surface);
|
|
|
|
if (device) IDirect3DDevice3_Release(device);
|
|
|
|
if (d3d) IDirect3D3_Release(d3d);
|
|
|
|
if (ddraw) IDirectDraw4_Release(ddraw);
|
|
|
|
DestroyWindow(window);
|
|
|
|
}
|
|
|
|
|
2012-01-26 23:04:20 +01:00
|
|
|
static void test_coop_level_threaded(void)
|
|
|
|
{
|
|
|
|
struct create_window_thread_param p;
|
|
|
|
IDirectDraw4 *ddraw;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (!(ddraw = create_ddraw()))
|
|
|
|
{
|
|
|
|
skip("Failed to create a ddraw object, skipping test.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
create_window_thread(&p);
|
|
|
|
|
|
|
|
hr = IDirectDraw4_SetCooperativeLevel(ddraw, p.window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
IDirectDraw4_Release(ddraw);
|
|
|
|
destroy_window_thread(&p);
|
|
|
|
}
|
|
|
|
|
2012-01-30 08:41:58 +01:00
|
|
|
static void test_depth_blit(void)
|
|
|
|
{
|
|
|
|
static struct
|
|
|
|
{
|
|
|
|
float x, y, z;
|
|
|
|
DWORD color;
|
|
|
|
}
|
|
|
|
quad1[] =
|
|
|
|
{
|
|
|
|
{ -1.0, 1.0, 0.50f, 0xff00ff00},
|
|
|
|
{ 1.0, 1.0, 0.50f, 0xff00ff00},
|
|
|
|
{ -1.0, -1.0, 0.50f, 0xff00ff00},
|
|
|
|
{ 1.0, -1.0, 0.50f, 0xff00ff00},
|
|
|
|
};
|
|
|
|
static const D3DCOLOR expected_colors[4][4] =
|
|
|
|
{
|
|
|
|
{0x00ff0000, 0x00ff0000, 0x0000ff00, 0x0000ff00},
|
|
|
|
{0x00ff0000, 0x00ff0000, 0x0000ff00, 0x0000ff00},
|
|
|
|
{0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00},
|
|
|
|
{0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00},
|
|
|
|
};
|
|
|
|
DDSURFACEDESC2 ddsd_new, ddsd_existing;
|
|
|
|
|
|
|
|
IDirect3DDevice3 *device;
|
|
|
|
IDirectDrawSurface4 *ds1, *ds2, *ds3, *rt;
|
|
|
|
IDirect3DViewport3 *viewport;
|
|
|
|
RECT src_rect, dst_rect;
|
|
|
|
unsigned int i, j;
|
|
|
|
D3DCOLOR color;
|
|
|
|
HRESULT hr;
|
|
|
|
IDirect3D3 *d3d;
|
|
|
|
IDirectDraw4 *ddraw;
|
|
|
|
DDBLTFX fx;
|
|
|
|
HWND window;
|
|
|
|
D3DRECT d3drect;
|
|
|
|
|
|
|
|
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 Direct3D3 interface, hr %#x.\n", hr);
|
|
|
|
hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to get DirectDraw4 interface, hr %#x.\n", hr);
|
|
|
|
IDirect3D3_Release(d3d);
|
|
|
|
|
|
|
|
ds1 = get_depth_stencil(device);
|
|
|
|
|
|
|
|
memset(&ddsd_new, 0, sizeof(ddsd_new));
|
|
|
|
ddsd_new.dwSize = sizeof(ddsd_new);
|
|
|
|
memset(&ddsd_existing, 0, sizeof(ddsd_existing));
|
|
|
|
ddsd_existing.dwSize = sizeof(ddsd_existing);
|
|
|
|
hr = IDirectDrawSurface4_GetSurfaceDesc(ds1, &ddsd_existing);
|
|
|
|
ddsd_new.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
|
|
|
|
ddsd_new.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
|
|
|
|
ddsd_new.dwWidth = ddsd_existing.dwWidth;
|
|
|
|
ddsd_new.dwHeight = ddsd_existing.dwHeight;
|
|
|
|
U4(ddsd_new).ddpfPixelFormat = U4(ddsd_existing).ddpfPixelFormat;
|
|
|
|
hr = IDirectDraw4_CreateSurface(ddraw, &ddsd_new, &ds2, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to create a surface, hr %#x.\n", hr);
|
|
|
|
hr = IDirectDraw4_CreateSurface(ddraw, &ddsd_new, &ds3, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to create a surface, hr %#x.\n", hr);
|
|
|
|
IDirectDraw4_Release(ddraw);
|
|
|
|
|
2012-03-26 20:28:08 +02:00
|
|
|
viewport = create_viewport(device, 0, 0, ddsd_existing.dwWidth, ddsd_existing.dwHeight);
|
2012-01-30 08:41:58 +01:00
|
|
|
hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_TRUE);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to enable z testing, hr %#x.\n", hr);
|
|
|
|
hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZFUNC, D3DCMP_LESSEQUAL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set the z function, hr %#x.\n", hr);
|
|
|
|
hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
U1(d3drect).x1 = U2(d3drect).y1 = 0;
|
2012-03-26 20:28:08 +02:00
|
|
|
U3(d3drect).x2 = ddsd_existing.dwWidth; U4(d3drect).y2 = ddsd_existing.dwHeight;
|
2012-01-30 08:41:58 +01:00
|
|
|
hr = IDirect3DViewport3_Clear2(viewport, 1, &d3drect, D3DCLEAR_ZBUFFER, 0, 0.0f, 0);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to clear the z buffer, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
/* Partial blit. */
|
|
|
|
SetRect(&src_rect, 0, 0, 320, 240);
|
|
|
|
SetRect(&dst_rect, 0, 0, 320, 240);
|
|
|
|
hr = IDirectDrawSurface4_Blt(ds2, &dst_rect, ds1, &src_rect, DDBLT_WAIT, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
|
|
|
|
/* Different locations. */
|
|
|
|
SetRect(&src_rect, 0, 0, 320, 240);
|
|
|
|
SetRect(&dst_rect, 320, 240, 640, 480);
|
|
|
|
hr = IDirectDrawSurface4_Blt(ds2, &dst_rect, ds1, &src_rect, DDBLT_WAIT, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
|
|
|
|
/* Streched. */
|
|
|
|
SetRect(&src_rect, 0, 0, 320, 240);
|
|
|
|
SetRect(&dst_rect, 0, 0, 640, 480);
|
|
|
|
hr = IDirectDrawSurface4_Blt(ds2, &dst_rect, ds1, &src_rect, DDBLT_WAIT, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
|
|
|
|
/* Flipped. */
|
|
|
|
SetRect(&src_rect, 0, 480, 640, 0);
|
|
|
|
SetRect(&dst_rect, 0, 0, 640, 480);
|
|
|
|
hr = IDirectDrawSurface4_Blt(ds2, &dst_rect, ds1, &src_rect, DDBLT_WAIT, NULL);
|
|
|
|
ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
|
|
|
|
SetRect(&src_rect, 0, 0, 640, 480);
|
|
|
|
SetRect(&dst_rect, 0, 480, 640, 0);
|
|
|
|
hr = IDirectDrawSurface4_Blt(ds2, &dst_rect, ds1, &src_rect, DDBLT_WAIT, NULL);
|
|
|
|
ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
|
|
|
|
/* Full, explicit. */
|
|
|
|
SetRect(&src_rect, 0, 0, 640, 480);
|
|
|
|
SetRect(&dst_rect, 0, 0, 640, 480);
|
|
|
|
hr = IDirectDrawSurface4_Blt(ds2, &dst_rect, ds1, &src_rect, DDBLT_WAIT, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
|
|
|
|
/* Depth -> color blit: Succeeds on Win7 + Radeon HD 5700, fails on WinXP + Radeon X1600 */
|
|
|
|
|
|
|
|
/* Depth blit inside a BeginScene / EndScene pair */
|
|
|
|
hr = IDirect3DDevice3_BeginScene(device);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to start a scene, hr %#x.\n", hr);
|
|
|
|
/* From the current depth stencil */
|
|
|
|
hr = IDirectDrawSurface4_Blt(ds2, NULL, ds1, NULL, DDBLT_WAIT, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
|
|
|
|
/* To the current depth stencil */
|
|
|
|
hr = IDirectDrawSurface4_Blt(ds1, NULL, ds2, NULL, DDBLT_WAIT, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
|
|
|
|
/* Between unbound surfaces */
|
|
|
|
hr = IDirectDrawSurface4_Blt(ds3, NULL, ds2, NULL, DDBLT_WAIT, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
|
|
|
|
hr = IDirect3DDevice3_EndScene(device);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to end a scene, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
/* Avoid changing the depth stencil, it doesn't work properly on Windows.
|
|
|
|
* Instead use DDBLT_DEPTHFILL to clear the depth stencil. Unfortunately
|
|
|
|
* drivers disagree on the meaning of dwFillDepth. Only 0 seems to produce
|
|
|
|
* a reliable result(z = 0.0) */
|
|
|
|
memset(&fx, 0, sizeof(fx));
|
|
|
|
fx.dwSize = sizeof(fx);
|
|
|
|
hr = IDirectDrawSurface4_Blt(ds2, NULL, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to clear the source z buffer, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDirect3DViewport3_Clear2(viewport, 1, &d3drect, D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET, 0xffff0000, 1.0f, 0);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to clear the color and z buffers, hr %#x.\n", hr);
|
|
|
|
SetRect(&dst_rect, 0, 0, 320, 240);
|
|
|
|
hr = IDirectDrawSurface4_Blt(ds1, &dst_rect, ds2, NULL, DDBLT_WAIT, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
|
|
|
|
IDirectDrawSurface4_Release(ds3);
|
|
|
|
IDirectDrawSurface4_Release(ds2);
|
|
|
|
IDirectDrawSurface4_Release(ds1);
|
|
|
|
|
|
|
|
hr = IDirect3DDevice3_BeginScene(device);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to start a scene, hr %#x.\n", hr);
|
|
|
|
hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE,
|
|
|
|
quad1, 4, 0);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
|
|
|
|
hr = IDirect3DDevice3_EndScene(device);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to end a scene, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
|
|
|
|
for (i = 0; i < 4; ++i)
|
|
|
|
{
|
|
|
|
for (j = 0; j < 4; ++j)
|
|
|
|
{
|
|
|
|
unsigned int x = 80 * ((2 * j) + 1);
|
|
|
|
unsigned int y = 60 * ((2 * i) + 1);
|
|
|
|
color = get_surface_color(rt, x, y);
|
|
|
|
ok(compare_color(color, expected_colors[i][j], 1),
|
|
|
|
"Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected_colors[i][j], x, y, color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
IDirectDrawSurface4_Release(rt);
|
|
|
|
|
2012-03-26 20:28:08 +02:00
|
|
|
destroy_viewport(device, viewport);
|
2012-01-30 08:41:58 +01:00
|
|
|
IDirect3DDevice3_Release(device);
|
|
|
|
DestroyWindow(window);
|
|
|
|
}
|
|
|
|
|
2012-01-31 14:49:18 +01:00
|
|
|
static void test_texture_load_ckey(void)
|
|
|
|
{
|
|
|
|
IDirectDraw4 *ddraw;
|
|
|
|
IDirectDrawSurface4 *src;
|
|
|
|
IDirectDrawSurface4 *dst;
|
|
|
|
IDirect3DTexture2 *src_tex;
|
|
|
|
IDirect3DTexture2 *dst_tex;
|
|
|
|
DDSURFACEDESC2 ddsd;
|
|
|
|
HRESULT hr;
|
|
|
|
DDCOLORKEY ckey;
|
|
|
|
|
|
|
|
if (!(ddraw = create_ddraw()))
|
|
|
|
{
|
|
|
|
skip("Failed to create ddraw object, skipping test.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
memset(&ddsd, 0, sizeof(ddsd));
|
|
|
|
ddsd.dwSize = sizeof(ddsd);
|
|
|
|
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
|
|
|
ddsd.dwHeight = 128;
|
|
|
|
ddsd.dwWidth = 128;
|
|
|
|
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY;
|
|
|
|
hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &src, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to create source texture, hr %#x.\n", hr);
|
|
|
|
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
|
|
|
|
hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &dst, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to create destination texture, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDirectDrawSurface4_QueryInterface(src, &IID_IDirect3DTexture2, (void **)&src_tex);
|
|
|
|
ok(SUCCEEDED(hr) || hr == E_NOINTERFACE, "Failed to get Direct3DTexture2 interface, hr %#x.\n", hr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
/* 64 bit ddraw does not support d3d */
|
|
|
|
skip("Could not get Direct3DTexture2 interface, skipping texture::Load color keying tests.\n");
|
|
|
|
IDirectDrawSurface4_Release(dst);
|
|
|
|
IDirectDrawSurface4_Release(src);
|
|
|
|
IDirectDraw4_Release(ddraw);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
hr = IDirectDrawSurface4_QueryInterface(dst, &IID_IDirect3DTexture2, (void **)&dst_tex);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to get Direct3DTexture2 interface, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
/* No surface has a color key */
|
|
|
|
hr = IDirect3DTexture2_Load(dst_tex, src_tex);
|
|
|
|
ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
|
|
|
|
ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0xdeadbeef;
|
|
|
|
hr = IDirectDrawSurface4_GetColorKey(dst, DDCKEY_SRCBLT, &ckey);
|
|
|
|
ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x.\n", hr);
|
|
|
|
ok(ckey.dwColorSpaceLowValue == 0xdeadbeef, "dwColorSpaceLowValue is %#x.\n", ckey.dwColorSpaceLowValue);
|
|
|
|
ok(ckey.dwColorSpaceHighValue == 0xdeadbeef, "dwColorSpaceHighValue is %#x.\n", ckey.dwColorSpaceHighValue);
|
|
|
|
|
|
|
|
/* Source surface has a color key */
|
|
|
|
ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0x0000ff00;
|
|
|
|
hr = IDirectDrawSurface4_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
|
|
|
|
hr = IDirect3DTexture2_Load(dst_tex, src_tex);
|
|
|
|
ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
|
|
|
|
hr = IDirectDrawSurface4_GetColorKey(dst, DDCKEY_SRCBLT, &ckey);
|
|
|
|
ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
|
|
|
|
ok(ckey.dwColorSpaceLowValue == 0x0000ff00, "dwColorSpaceLowValue is %#x.\n", ckey.dwColorSpaceLowValue);
|
|
|
|
ok(ckey.dwColorSpaceHighValue == 0x0000ff00, "dwColorSpaceHighValue is %#x.\n", ckey.dwColorSpaceHighValue);
|
|
|
|
|
|
|
|
/* Both surfaces have a color key: Dest ckey is overwritten */
|
|
|
|
ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0x000000ff;
|
|
|
|
hr = IDirectDrawSurface4_SetColorKey(dst, DDCKEY_SRCBLT, &ckey);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
|
|
|
|
hr = IDirect3DTexture2_Load(dst_tex, src_tex);
|
|
|
|
ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
|
|
|
|
hr = IDirectDrawSurface4_GetColorKey(dst, DDCKEY_SRCBLT, &ckey);
|
|
|
|
ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
|
|
|
|
ok(ckey.dwColorSpaceLowValue == 0x0000ff00, "dwColorSpaceLowValue is %#x.\n", ckey.dwColorSpaceLowValue);
|
|
|
|
ok(ckey.dwColorSpaceHighValue == 0x0000ff00, "dwColorSpaceHighValue is %#x.\n", ckey.dwColorSpaceHighValue);
|
|
|
|
|
|
|
|
/* Only the destination has a color key: It is not deleted */
|
|
|
|
hr = IDirectDrawSurface4_SetColorKey(src, DDCKEY_SRCBLT, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
|
|
|
|
hr = IDirectDrawSurface4_GetColorKey(src, DDCKEY_SRCBLT, &ckey);
|
|
|
|
ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x.\n", hr);
|
|
|
|
hr = IDirect3DTexture2_Load(dst_tex, src_tex);
|
|
|
|
ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
|
|
|
|
hr = IDirectDrawSurface4_GetColorKey(dst, DDCKEY_SRCBLT, &ckey);
|
|
|
|
ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
|
|
|
|
ok(ckey.dwColorSpaceLowValue == 0x0000ff00, "dwColorSpaceLowValue is %#x.\n", ckey.dwColorSpaceLowValue);
|
|
|
|
ok(ckey.dwColorSpaceHighValue == 0x0000ff00, "dwColorSpaceHighValue is %#x.\n", ckey.dwColorSpaceHighValue);
|
|
|
|
|
|
|
|
IDirect3DTexture2_Release(dst_tex);
|
|
|
|
IDirect3DTexture2_Release(src_tex);
|
|
|
|
IDirectDrawSurface4_Release(dst);
|
|
|
|
IDirectDrawSurface4_Release(src);
|
|
|
|
IDirectDraw4_Release(ddraw);
|
|
|
|
}
|
|
|
|
|
2012-02-27 12:11:15 +01:00
|
|
|
static ULONG get_refcount(IUnknown *test_iface)
|
2012-02-02 12:56:00 +01:00
|
|
|
{
|
|
|
|
IUnknown_AddRef(test_iface);
|
|
|
|
return IUnknown_Release(test_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_viewport_interfaces(void)
|
|
|
|
{
|
|
|
|
IDirectDraw4 *ddraw;
|
|
|
|
IDirect3D3 *d3d;
|
|
|
|
HRESULT hr, old_d3d_ref;
|
2012-02-27 12:11:15 +01:00
|
|
|
ULONG ref;
|
2012-02-02 12:56:00 +01:00
|
|
|
IDirect3DViewport *viewport;
|
|
|
|
IDirect3DViewport2 *viewport2;
|
|
|
|
IDirect3DViewport3 *viewport3;
|
|
|
|
IDirectDrawGammaControl *gamma;
|
|
|
|
IUnknown *unknown;
|
|
|
|
|
|
|
|
if (!(ddraw = create_ddraw()))
|
|
|
|
{
|
|
|
|
skip("Failed to create ddraw object, skipping test.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
hr = IDirectDraw4_QueryInterface(ddraw, &IID_IDirect3D3, (void **)&d3d);
|
|
|
|
ok(SUCCEEDED(hr) || hr == E_NOINTERFACE, "Failed to get d3d interface, hr %#x.\n", hr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
skip("Direct3D not available, skipping tests\n");
|
|
|
|
IDirectDraw4_Release(ddraw);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
old_d3d_ref = get_refcount((IUnknown *)d3d);
|
|
|
|
|
|
|
|
hr = IDirect3D3_CreateViewport(d3d, &viewport3, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to create viewport, hr %#x.\n", hr);
|
|
|
|
ref = get_refcount((IUnknown *)viewport3);
|
2012-02-27 12:11:15 +01:00
|
|
|
ok(ref == 1, "Initial IDirect3DViewport3 refcount is %u\n", ref);
|
2012-02-02 12:56:00 +01:00
|
|
|
ref = get_refcount((IUnknown *)d3d);
|
2012-02-27 12:11:15 +01:00
|
|
|
ok(ref == old_d3d_ref, "IDirect3D3 refcount is %u\n", ref);
|
2012-02-02 12:56:00 +01:00
|
|
|
|
|
|
|
gamma = (IDirectDrawGammaControl *)0xdeadbeef;
|
|
|
|
hr = IDirect3DViewport2_QueryInterface(viewport3, &IID_IDirectDrawGammaControl, (void **)&gamma);
|
|
|
|
ok(hr == E_NOINTERFACE, "Got unexpected hr %#x.\n", hr);
|
|
|
|
ok(gamma == NULL, "Interface not set to NULL by failed QI call: %p\n", gamma);
|
|
|
|
if (SUCCEEDED(hr)) IDirectDrawGammaControl_Release(gamma);
|
|
|
|
/* NULL iid: Segfaults */
|
|
|
|
|
|
|
|
hr = IDirect3DViewport3_QueryInterface(viewport3, &IID_IDirect3DViewport, (void **)&viewport);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to QI IDirect3DViewport, hr %#x.\n", hr);
|
|
|
|
if (viewport)
|
|
|
|
{
|
|
|
|
ref = get_refcount((IUnknown *)viewport);
|
2012-02-27 12:11:15 +01:00
|
|
|
ok(ref == 2, "IDirect3DViewport refcount is %u\n", ref);
|
2012-02-02 12:56:00 +01:00
|
|
|
ref = get_refcount((IUnknown *)viewport3);
|
2012-02-27 12:11:15 +01:00
|
|
|
ok(ref == 2, "IDirect3DViewport3 refcount is %u\n", ref);
|
2012-02-02 12:56:00 +01:00
|
|
|
IDirect3DViewport_Release(viewport);
|
|
|
|
viewport = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDirect3DViewport3_QueryInterface(viewport3, &IID_IDirect3DViewport3, (void **)&viewport2);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to QI IDirect3DViewport3, hr %#x.\n", hr);
|
|
|
|
if (viewport2)
|
|
|
|
{
|
|
|
|
ref = get_refcount((IUnknown *)viewport2);
|
2012-02-27 12:11:15 +01:00
|
|
|
ok(ref == 2, "IDirect3DViewport2 refcount is %u\n", ref);
|
2012-02-02 12:56:00 +01:00
|
|
|
ref = get_refcount((IUnknown *)viewport3);
|
2012-02-27 12:11:15 +01:00
|
|
|
ok(ref == 2, "IDirect3DViewport3 refcount is %u\n", ref);
|
2012-02-02 12:56:00 +01:00
|
|
|
IDirect3DViewport3_Release(viewport2);
|
|
|
|
}
|
|
|
|
|
2012-02-27 12:11:15 +01:00
|
|
|
hr = IDirect3DViewport3_QueryInterface(viewport3, &IID_IUnknown, (void **)&unknown);
|
2012-02-02 12:56:00 +01:00
|
|
|
ok(SUCCEEDED(hr), "Failed to QI IUnknown, hr %#x.\n", hr);
|
|
|
|
if (unknown)
|
|
|
|
{
|
|
|
|
ref = get_refcount((IUnknown *)viewport3);
|
2012-02-27 12:11:15 +01:00
|
|
|
ok(ref == 2, "IDirect3DViewport3 refcount is %u\n", ref);
|
2012-02-02 12:56:00 +01:00
|
|
|
ref = get_refcount(unknown);
|
2012-02-27 12:11:15 +01:00
|
|
|
ok(ref == 2, "IUnknown refcount is %u\n", ref);
|
2012-02-02 12:56:00 +01:00
|
|
|
IUnknown_Release(unknown);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDirect3DViewport3_Release(viewport3);
|
|
|
|
IDirect3D3_Release(d3d);
|
|
|
|
IDirectDraw4_Release(ddraw);
|
|
|
|
}
|
|
|
|
|
2012-02-23 22:45:47 +01:00
|
|
|
static void test_zenable(void)
|
|
|
|
{
|
|
|
|
static D3DRECT clear_rect = {{0}, {0}, {640}, {480}};
|
|
|
|
static struct
|
|
|
|
{
|
|
|
|
struct vec4 position;
|
|
|
|
D3DCOLOR diffuse;
|
|
|
|
}
|
|
|
|
tquad[] =
|
|
|
|
{
|
|
|
|
{{ 0.0f, 480.0f, -0.5f, 1.0f}, 0xff00ff00},
|
|
|
|
{{ 0.0f, 0.0f, -0.5f, 1.0f}, 0xff00ff00},
|
|
|
|
{{640.0f, 480.0f, 1.5f, 1.0f}, 0xff00ff00},
|
|
|
|
{{640.0f, 0.0f, 1.5f, 1.0f}, 0xff00ff00},
|
|
|
|
};
|
|
|
|
IDirect3DViewport3 *viewport;
|
|
|
|
IDirect3DDevice3 *device;
|
|
|
|
IDirectDrawSurface4 *rt;
|
|
|
|
D3DCOLOR color;
|
|
|
|
HWND window;
|
|
|
|
HRESULT hr;
|
|
|
|
UINT x, y;
|
|
|
|
UINT i, j;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-03-26 20:28:08 +02:00
|
|
|
viewport = create_viewport(device, 0, 0, 640, 480);
|
2012-02-23 22:45:47 +01:00
|
|
|
hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to disable z-buffering, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffff0000, 0.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_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZRHW | D3DFVF_DIFFUSE, tquad, 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);
|
|
|
|
|
|
|
|
hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
|
|
|
|
for (i = 0; i < 4; ++i)
|
|
|
|
{
|
|
|
|
for (j = 0; j < 4; ++j)
|
|
|
|
{
|
|
|
|
x = 80 * ((2 * j) + 1);
|
|
|
|
y = 60 * ((2 * i) + 1);
|
|
|
|
color = get_surface_color(rt, x, y);
|
|
|
|
ok(compare_color(color, 0x0000ff00, 1),
|
|
|
|
"Expected color 0x0000ff00 at %u, %u, got 0x%08x.\n", x, y, color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
IDirectDrawSurface4_Release(rt);
|
|
|
|
|
2012-03-26 20:28:08 +02:00
|
|
|
destroy_viewport(device, viewport);
|
2012-02-23 22:45:47 +01:00
|
|
|
IDirect3DDevice3_Release(device);
|
|
|
|
DestroyWindow(window);
|
|
|
|
}
|
|
|
|
|
2012-02-28 19:48:41 +01:00
|
|
|
static void test_ck_rgba(void)
|
|
|
|
{
|
|
|
|
static D3DRECT clear_rect = {{0}, {0}, {640}, {480}};
|
|
|
|
static struct
|
|
|
|
{
|
|
|
|
struct vec4 position;
|
|
|
|
struct vec2 texcoord;
|
|
|
|
}
|
|
|
|
tquad[] =
|
|
|
|
{
|
|
|
|
{{ 0.0f, 480.0f, 0.25f, 1.0f}, {0.0f, 0.0f}},
|
|
|
|
{{ 0.0f, 0.0f, 0.25f, 1.0f}, {0.0f, 1.0f}},
|
|
|
|
{{640.0f, 480.0f, 0.25f, 1.0f}, {1.0f, 0.0f}},
|
|
|
|
{{640.0f, 0.0f, 0.25f, 1.0f}, {1.0f, 1.0f}},
|
|
|
|
{{ 0.0f, 480.0f, 0.75f, 1.0f}, {0.0f, 0.0f}},
|
|
|
|
{{ 0.0f, 0.0f, 0.75f, 1.0f}, {0.0f, 1.0f}},
|
|
|
|
{{640.0f, 480.0f, 0.75f, 1.0f}, {1.0f, 0.0f}},
|
|
|
|
{{640.0f, 0.0f, 0.75f, 1.0f}, {1.0f, 1.0f}},
|
|
|
|
};
|
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
D3DCOLOR fill_color;
|
|
|
|
BOOL color_key;
|
|
|
|
BOOL blend;
|
|
|
|
D3DCOLOR result1;
|
|
|
|
D3DCOLOR result2;
|
|
|
|
}
|
|
|
|
tests[] =
|
|
|
|
{
|
|
|
|
{0xff00ff00, TRUE, TRUE, 0x00ff0000, 0x000000ff},
|
|
|
|
{0xff00ff00, TRUE, FALSE, 0x00ff0000, 0x000000ff},
|
|
|
|
{0xff00ff00, FALSE, TRUE, 0x0000ff00, 0x0000ff00},
|
|
|
|
{0xff00ff00, FALSE, FALSE, 0x0000ff00, 0x0000ff00},
|
|
|
|
{0x7f00ff00, TRUE, TRUE, 0x00807f00, 0x00807f00},
|
|
|
|
{0x7f00ff00, TRUE, FALSE, 0x0000ff00, 0x0000ff00},
|
|
|
|
{0x7f00ff00, FALSE, TRUE, 0x00807f00, 0x00807f00},
|
|
|
|
{0x7f00ff00, FALSE, FALSE, 0x0000ff00, 0x0000ff00},
|
|
|
|
};
|
|
|
|
|
|
|
|
IDirectDrawSurface4 *surface;
|
|
|
|
IDirect3DViewport3 *viewport;
|
|
|
|
DDSURFACEDESC2 surface_desc;
|
|
|
|
IDirect3DTexture2 *texture;
|
|
|
|
IDirect3DDevice3 *device;
|
|
|
|
IDirectDrawSurface4 *rt;
|
|
|
|
IDirectDraw4 *ddraw;
|
|
|
|
IDirect3D3 *d3d;
|
|
|
|
D3DCOLOR color;
|
|
|
|
HWND window;
|
|
|
|
DDBLTFX fx;
|
|
|
|
HRESULT hr;
|
|
|
|
UINT i;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-03-26 20:28:08 +02:00
|
|
|
viewport = create_viewport(device, 0, 0, 640, 480);
|
2012-02-28 19:48:41 +01:00
|
|
|
hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
|
2012-03-26 20:28:08 +02:00
|
|
|
|
|
|
|
hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
|
2012-02-28 19:48:41 +01:00
|
|
|
hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
|
|
|
|
IDirect3D3_Release(d3d);
|
|
|
|
|
|
|
|
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 | DDPF_ALPHAPIXELS;
|
|
|
|
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;
|
|
|
|
U5(U4(surface_desc).ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
|
|
|
|
surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0xff00ff00;
|
|
|
|
surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0xff00ff00;
|
|
|
|
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to create destination 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);
|
|
|
|
hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to enable alpha blending, hr %#x.\n", hr);
|
|
|
|
hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to enable alpha blending, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
|
|
|
|
{
|
|
|
|
hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, tests[i].color_key);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to enable color keying, hr %#x.\n", hr);
|
|
|
|
hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, tests[i].blend);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to enable alpha blending, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
memset(&fx, 0, sizeof(fx));
|
|
|
|
fx.dwSize = sizeof(fx);
|
|
|
|
U5(fx).dwFillColor = tests[i].fill_color;
|
|
|
|
hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to fill texture, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect,
|
|
|
|
D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffff0000, 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_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);
|
|
|
|
if (i == 2)
|
|
|
|
todo_wine ok(compare_color(color, tests[i].result1, 1), "Expected color 0x%08x for test %u, got 0x%08x.\n",
|
|
|
|
tests[i].result1, i, color);
|
|
|
|
else
|
|
|
|
ok(compare_color(color, tests[i].result1, 1), "Expected color 0x%08x for test %u, got 0x%08x.\n",
|
|
|
|
tests[i].result1, i, color);
|
|
|
|
|
|
|
|
U5(fx).dwFillColor = 0xff0000ff;
|
|
|
|
hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to fill texture, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IDirect3DDevice3_BeginScene(device);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
|
|
|
|
hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZRHW | D3DFVF_TEX1, &tquad[4], 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);
|
|
|
|
|
|
|
|
/* This tests that fragments that are masked out by the color key are
|
|
|
|
* discarded, instead of just fully transparent. */
|
|
|
|
color = get_surface_color(rt, 320, 240);
|
|
|
|
if (i == 2)
|
|
|
|
todo_wine ok(compare_color(color, tests[i].result2, 1), "Expected color 0x%08x for test %u, got 0x%08x.\n",
|
|
|
|
tests[i].result2, i, color);
|
|
|
|
else
|
|
|
|
ok(compare_color(color, tests[i].result2, 1), "Expected color 0x%08x for test %u, got 0x%08x.\n",
|
|
|
|
tests[i].result2, i, color);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDirectDrawSurface4_Release(rt);
|
|
|
|
IDirect3DTexture2_Release(texture);
|
|
|
|
IDirectDrawSurface4_Release(surface);
|
2012-03-26 20:28:08 +02:00
|
|
|
destroy_viewport(device, viewport);
|
2012-02-28 19:48:41 +01:00
|
|
|
IDirectDraw4_Release(ddraw);
|
|
|
|
IDirect3DDevice3_Release(device);
|
|
|
|
DestroyWindow(window);
|
|
|
|
}
|
|
|
|
|
2012-04-03 11:14:10 +02:00
|
|
|
struct qi_test
|
|
|
|
{
|
|
|
|
REFIID iid;
|
|
|
|
REFIID refcount_iid;
|
|
|
|
HRESULT hr;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void test_qi(const char *test_name, IUnknown *base_iface,
|
|
|
|
REFIID refcount_iid, const struct qi_test *tests, UINT entry_count)
|
|
|
|
{
|
|
|
|
ULONG refcount, expected_refcount;
|
|
|
|
IUnknown *iface1, *iface2;
|
|
|
|
HRESULT hr;
|
|
|
|
UINT i, j;
|
|
|
|
|
|
|
|
for (i = 0; i < entry_count; ++i)
|
|
|
|
{
|
|
|
|
hr = IUnknown_QueryInterface(base_iface, tests[i].iid, (void **)&iface1);
|
|
|
|
ok(hr == tests[i].hr, "Got hr %#x for test \"%s\" %u.\n", hr, test_name, i);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
for (j = 0; j < entry_count; ++j)
|
|
|
|
{
|
|
|
|
hr = IUnknown_QueryInterface(iface1, tests[j].iid, (void **)&iface2);
|
|
|
|
ok(hr == tests[j].hr, "Got hr %#x for test \"%s\" %u, %u.\n", hr, test_name, i, j);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
expected_refcount = 0;
|
|
|
|
if (IsEqualGUID(refcount_iid, tests[j].refcount_iid))
|
|
|
|
++expected_refcount;
|
|
|
|
if (IsEqualGUID(tests[i].refcount_iid, tests[j].refcount_iid))
|
|
|
|
++expected_refcount;
|
|
|
|
refcount = IUnknown_Release(iface2);
|
|
|
|
ok(refcount == expected_refcount, "Got refcount %u for test \"%s\" %u, %u, expected %u.\n",
|
|
|
|
refcount, test_name, i, j, expected_refcount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expected_refcount = 0;
|
|
|
|
if (IsEqualGUID(refcount_iid, tests[i].refcount_iid))
|
|
|
|
++expected_refcount;
|
|
|
|
refcount = IUnknown_Release(iface1);
|
|
|
|
ok(refcount == expected_refcount, "Got refcount %u for test \"%s\" %u, expected %u.\n",
|
|
|
|
refcount, test_name, i, expected_refcount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_surface_qi(void)
|
|
|
|
{
|
|
|
|
static const struct qi_test tests[] =
|
|
|
|
{
|
|
|
|
{&IID_IDirect3DTexture2, &IID_IDirectDrawSurface4, S_OK },
|
|
|
|
{&IID_IDirect3DTexture, &IID_IDirectDrawSurface4, S_OK },
|
|
|
|
{&IID_IDirectDrawGammaControl, &IID_IDirectDrawGammaControl, S_OK },
|
|
|
|
{&IID_IDirectDrawColorControl, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirectDrawSurface7, &IID_IDirectDrawSurface7, S_OK },
|
|
|
|
{&IID_IDirectDrawSurface4, &IID_IDirectDrawSurface4, S_OK },
|
|
|
|
{&IID_IDirectDrawSurface3, &IID_IDirectDrawSurface3, S_OK },
|
|
|
|
{&IID_IDirectDrawSurface2, &IID_IDirectDrawSurface2, S_OK },
|
|
|
|
{&IID_IDirectDrawSurface, &IID_IDirectDrawSurface, S_OK },
|
|
|
|
{&IID_IDirect3DDevice7, NULL, E_INVALIDARG },
|
|
|
|
{&IID_IDirect3DDevice3, NULL, E_INVALIDARG },
|
|
|
|
{&IID_IDirect3DDevice2, NULL, E_INVALIDARG },
|
|
|
|
{&IID_IDirect3DDevice, NULL, E_INVALIDARG },
|
|
|
|
{&IID_IDirect3D7, NULL, E_INVALIDARG },
|
|
|
|
{&IID_IDirect3D3, NULL, E_INVALIDARG },
|
|
|
|
{&IID_IDirect3D2, NULL, E_INVALIDARG },
|
|
|
|
{&IID_IDirect3D, NULL, E_INVALIDARG },
|
|
|
|
{&IID_IDirectDraw7, NULL, E_INVALIDARG },
|
|
|
|
{&IID_IDirectDraw4, NULL, E_INVALIDARG },
|
|
|
|
{&IID_IDirectDraw3, NULL, E_INVALIDARG },
|
|
|
|
{&IID_IDirectDraw2, NULL, E_INVALIDARG },
|
|
|
|
{&IID_IDirectDraw, NULL, E_INVALIDARG },
|
|
|
|
{&IID_IDirect3DLight, NULL, E_INVALIDARG },
|
|
|
|
{&IID_IDirect3DMaterial, NULL, E_INVALIDARG },
|
|
|
|
{&IID_IDirect3DMaterial2, NULL, E_INVALIDARG },
|
|
|
|
{&IID_IDirect3DMaterial3, NULL, E_INVALIDARG },
|
|
|
|
{&IID_IDirect3DExecuteBuffer, NULL, E_INVALIDARG },
|
|
|
|
{&IID_IDirect3DViewport, NULL, E_INVALIDARG },
|
|
|
|
{&IID_IDirect3DViewport2, NULL, E_INVALIDARG },
|
|
|
|
{&IID_IDirect3DViewport3, NULL, E_INVALIDARG },
|
|
|
|
{&IID_IDirect3DVertexBuffer, NULL, E_INVALIDARG },
|
|
|
|
{&IID_IDirect3DVertexBuffer7, NULL, E_INVALIDARG },
|
|
|
|
{&IID_IDirectDrawPalette, NULL, E_INVALIDARG },
|
|
|
|
{&IID_IDirectDrawClipper, NULL, E_INVALIDARG },
|
|
|
|
{&IID_IUnknown, &IID_IDirectDrawSurface, S_OK },
|
|
|
|
};
|
|
|
|
|
|
|
|
IDirectDrawSurface4 *surface;
|
|
|
|
DDSURFACEDESC2 surface_desc;
|
|
|
|
IDirect3DDevice3 *device;
|
|
|
|
IDirectDraw4 *ddraw;
|
|
|
|
HWND window;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (!GetProcAddress(GetModuleHandleA("ddraw.dll"), "DirectDrawCreateEx"))
|
|
|
|
{
|
|
|
|
win_skip("DirectDrawCreateEx not available, skipping test.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
|
|
|
|
0, 0, 640, 480, 0, 0, 0, 0);
|
|
|
|
/* Try to create a D3D device to see if the ddraw implementation supports
|
|
|
|
* D3D. 64-bit ddraw in particular doesn't seem to support D3D, and
|
|
|
|
* doesn't support e.g. the IDirect3DTexture interfaces. */
|
|
|
|
if (!(device = create_device(window, DDSCL_NORMAL)))
|
|
|
|
{
|
|
|
|
skip("Failed to create D3D device, skipping test.\n");
|
|
|
|
DestroyWindow(window);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
IDirect3DDevice_Release(device);
|
|
|
|
if (!(ddraw = create_ddraw()))
|
|
|
|
{
|
|
|
|
skip("Failed to create a ddraw object, skipping test.\n");
|
|
|
|
DestroyWindow(window);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to set cooperative level, 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;
|
|
|
|
surface_desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
|
|
|
|
surface_desc.dwWidth = 512;
|
|
|
|
surface_desc.dwHeight = 512;
|
|
|
|
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
test_qi("surface_qi", (IUnknown *)surface, &IID_IDirectDrawSurface4, tests, sizeof(tests) / sizeof(*tests));
|
|
|
|
|
|
|
|
IDirectDrawSurface4_Release(surface);
|
|
|
|
IDirectDraw4_Release(ddraw);
|
|
|
|
DestroyWindow(window);
|
|
|
|
}
|
|
|
|
|
2012-04-05 19:55:36 +02:00
|
|
|
static void test_device_qi(void)
|
|
|
|
{
|
|
|
|
static const struct qi_test tests[] =
|
|
|
|
{
|
|
|
|
{&IID_IDirect3DTexture2, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirect3DTexture, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirectDrawGammaControl, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirectDrawColorControl, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirectDrawSurface7, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirectDrawSurface4, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirectDrawSurface3, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirectDrawSurface2, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirectDrawSurface, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirect3DDevice7, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirect3DDevice3, &IID_IDirect3DDevice3, S_OK },
|
|
|
|
{&IID_IDirect3DDevice2, &IID_IDirect3DDevice3, S_OK },
|
|
|
|
{&IID_IDirect3DDevice, &IID_IDirect3DDevice3, S_OK },
|
|
|
|
{&IID_IDirect3DRampDevice, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirect3DRGBDevice, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirect3DHALDevice, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirect3DMMXDevice, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirect3DRefDevice, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirect3DTnLHalDevice, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirect3DNullDevice, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirect3D7, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirect3D3, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirect3D2, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirect3D, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirectDraw7, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirectDraw4, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirectDraw3, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirectDraw2, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirectDraw, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirect3DLight, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirect3DMaterial, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirect3DMaterial2, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirect3DMaterial3, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirect3DExecuteBuffer, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirect3DViewport, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirect3DViewport2, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirect3DViewport3, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirect3DVertexBuffer, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirect3DVertexBuffer7, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirectDrawPalette, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IDirectDrawClipper, NULL, E_NOINTERFACE},
|
|
|
|
{&IID_IUnknown, &IID_IDirect3DDevice3, S_OK },
|
|
|
|
};
|
|
|
|
|
|
|
|
IDirect3DDevice3 *device;
|
|
|
|
HWND window;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
test_qi("device_qi", (IUnknown *)device, &IID_IDirect3DDevice3, tests, sizeof(tests) / sizeof(*tests));
|
|
|
|
|
|
|
|
IDirect3DDevice3_Release(device);
|
|
|
|
DestroyWindow(window);
|
|
|
|
}
|
|
|
|
|
2011-12-19 21:00:06 +01:00
|
|
|
START_TEST(ddraw4)
|
|
|
|
{
|
|
|
|
test_process_vertices();
|
2011-12-21 21:34:58 +01:00
|
|
|
test_coop_level_create_device_window();
|
2012-01-04 23:34:52 +01:00
|
|
|
test_clipper_blt();
|
2012-01-17 21:13:34 +01:00
|
|
|
test_coop_level_d3d_state();
|
2012-01-23 22:34:48 +01:00
|
|
|
test_surface_interface_mismatch();
|
2012-01-26 23:04:20 +01:00
|
|
|
test_coop_level_threaded();
|
2012-01-30 08:41:58 +01:00
|
|
|
test_depth_blit();
|
2012-01-31 14:49:18 +01:00
|
|
|
test_texture_load_ckey();
|
2012-02-02 12:56:00 +01:00
|
|
|
test_viewport_interfaces();
|
2012-02-23 22:45:47 +01:00
|
|
|
test_zenable();
|
2012-02-28 19:48:41 +01:00
|
|
|
test_ck_rgba();
|
2012-04-03 11:14:10 +02:00
|
|
|
test_surface_qi();
|
2012-04-05 19:55:36 +02:00
|
|
|
test_device_qi();
|
2011-12-19 21:00:06 +01:00
|
|
|
}
|