2 * Copyright 2011-2012 Henri Verbeet for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "wine/test.h"
23 struct create_window_thread_param
26 HANDLE window_created
;
27 HANDLE destroy_window
;
31 static BOOL
compare_color(D3DCOLOR c1
, D3DCOLOR c2
, BYTE max_diff
)
33 if (abs((c1
& 0xff) - (c2
& 0xff)) > max_diff
) return FALSE
;
35 if (abs((c1
& 0xff) - (c2
& 0xff)) > max_diff
) return FALSE
;
37 if (abs((c1
& 0xff) - (c2
& 0xff)) > max_diff
) return FALSE
;
39 if (abs((c1
& 0xff) - (c2
& 0xff)) > max_diff
) return FALSE
;
43 static DWORD WINAPI
create_window_thread_proc(void *param
)
45 struct create_window_thread_param
*p
= param
;
49 p
->window
= CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW
,
50 0, 0, 640, 480, 0, 0, 0, 0);
51 ret
= SetEvent(p
->window_created
);
52 ok(ret
, "SetEvent failed, last error %#x.\n", GetLastError());
58 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
59 DispatchMessage(&msg
);
60 res
= WaitForSingleObject(p
->destroy_window
, 100);
61 if (res
== WAIT_OBJECT_0
)
63 if (res
!= WAIT_TIMEOUT
)
65 ok(0, "Wait failed (%#x), last error %#x.\n", res
, GetLastError());
70 DestroyWindow(p
->window
);
75 static void create_window_thread(struct create_window_thread_param
*p
)
79 p
->window_created
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
80 ok(!!p
->window_created
, "CreateEvent failed, last error %#x.\n", GetLastError());
81 p
->destroy_window
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
82 ok(!!p
->destroy_window
, "CreateEvent failed, last error %#x.\n", GetLastError());
83 p
->thread
= CreateThread(NULL
, 0, create_window_thread_proc
, p
, 0, &tid
);
84 ok(!!p
->thread
, "Failed to create thread, last error %#x.\n", GetLastError());
85 res
= WaitForSingleObject(p
->window_created
, INFINITE
);
86 ok(res
== WAIT_OBJECT_0
, "Wait failed (%#x), last error %#x.\n", res
, GetLastError());
89 static void destroy_window_thread(struct create_window_thread_param
*p
)
91 SetEvent(p
->destroy_window
);
92 WaitForSingleObject(p
->thread
, INFINITE
);
93 CloseHandle(p
->destroy_window
);
94 CloseHandle(p
->window_created
);
95 CloseHandle(p
->thread
);
98 static IDirectDrawSurface
*get_depth_stencil(IDirect3DDevice2
*device
)
100 IDirectDrawSurface
*rt
, *ret
;
101 DDSCAPS caps
= {DDSCAPS_ZBUFFER
};
104 hr
= IDirect3DDevice2_GetRenderTarget(device
, &rt
);
105 ok(SUCCEEDED(hr
), "Failed to get render target, hr %#x.\n", hr
);
106 hr
= IDirectDrawSurface_GetAttachedSurface(rt
, &caps
, &ret
);
107 ok(SUCCEEDED(hr
) || hr
== DDERR_NOTFOUND
, "Failed to get the z buffer, hr %#x.\n", hr
);
108 IDirectDrawSurface_Release(rt
);
112 static D3DCOLOR
get_surface_color(IDirectDrawSurface
*surface
, UINT x
, UINT y
)
114 RECT rect
= {x
, y
, x
+ 1, y
+ 1};
115 DDSURFACEDESC surface_desc
;
119 memset(&surface_desc
, 0, sizeof(surface_desc
));
120 surface_desc
.dwSize
= sizeof(surface_desc
);
122 hr
= IDirectDrawSurface_Lock(surface
, &rect
, &surface_desc
, DDLOCK_READONLY
| DDLOCK_WAIT
, NULL
);
123 ok(SUCCEEDED(hr
), "Failed to lock surface, hr %#x.\n", hr
);
127 color
= *((DWORD
*)surface_desc
.lpSurface
) & 0x00ffffff;
129 hr
= IDirectDrawSurface_Unlock(surface
, NULL
);
130 ok(SUCCEEDED(hr
), "Failed to unlock surface, hr %#x.\n", hr
);
135 static HRESULT CALLBACK
enum_z_fmt(GUID
*guid
, char *description
, char *name
,
136 D3DDEVICEDESC
*hal_desc
, D3DDEVICEDESC
*hel_desc
, void *ctx
)
138 DWORD
*z_depth
= ctx
;
140 if (!IsEqualGUID(&IID_IDirect3DHALDevice
, guid
))
141 return D3DENUMRET_OK
;
143 if (hal_desc
->dwDeviceZBufferBitDepth
& DDBD_32
)
145 else if (hal_desc
->dwDeviceZBufferBitDepth
& DDBD_24
)
147 else if (hal_desc
->dwDeviceZBufferBitDepth
& DDBD_16
)
153 static IDirectDraw2
*create_ddraw(void)
155 IDirectDraw2
*ddraw2
;
159 if (FAILED(DirectDrawCreate(NULL
, &ddraw1
, NULL
)))
162 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirectDraw2
, (void **)&ddraw2
);
163 IDirectDraw_Release(ddraw1
);
170 static IDirect3DDevice2
*create_device(IDirectDraw2
*ddraw
, HWND window
, DWORD coop_level
)
172 IDirectDrawSurface
*surface
, *ds
;
173 IDirect3DDevice2
*device
= NULL
;
174 DDSURFACEDESC surface_desc
;
179 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, window
, coop_level
);
180 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#x.\n", hr
);
182 memset(&surface_desc
, 0, sizeof(surface_desc
));
183 surface_desc
.dwSize
= sizeof(surface_desc
);
184 surface_desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
185 surface_desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
;
186 surface_desc
.dwWidth
= 640;
187 surface_desc
.dwHeight
= 480;
189 hr
= IDirectDraw2_CreateSurface(ddraw
, &surface_desc
, &surface
, NULL
);
190 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
192 if (coop_level
& DDSCL_NORMAL
)
194 IDirectDrawClipper
*clipper
;
196 hr
= IDirectDraw2_CreateClipper(ddraw
, 0, &clipper
, NULL
);
197 ok(SUCCEEDED(hr
), "Failed to create clipper, hr %#x.\n", hr
);
198 hr
= IDirectDrawClipper_SetHWnd(clipper
, 0, window
);
199 ok(SUCCEEDED(hr
), "Failed to set clipper window, hr %#x.\n", hr
);
200 hr
= IDirectDrawSurface_SetClipper(surface
, clipper
);
201 ok(SUCCEEDED(hr
), "Failed to set surface clipper, hr %#x.\n", hr
);
202 IDirectDrawClipper_Release(clipper
);
205 hr
= IDirectDraw2_QueryInterface(ddraw
, &IID_IDirect3D2
, (void **)&d3d
);
208 IDirectDrawSurface_Release(surface
);
212 hr
= IDirect3D2_EnumDevices(d3d
, enum_z_fmt
, &z_depth
);
213 ok(SUCCEEDED(hr
), "Failed to enumerate z-formats, hr %#x.\n", hr
);
214 if (FAILED(hr
) || !z_depth
)
216 IDirect3D2_Release(d3d
);
217 IDirectDrawSurface_Release(surface
);
221 memset(&surface_desc
, 0, sizeof(surface_desc
));
222 surface_desc
.dwSize
= sizeof(surface_desc
);
223 surface_desc
.dwFlags
= DDSD_CAPS
| DDSD_ZBUFFERBITDEPTH
| DDSD_WIDTH
| DDSD_HEIGHT
;
224 surface_desc
.ddsCaps
.dwCaps
= DDSCAPS_ZBUFFER
;
225 U2(surface_desc
).dwZBufferBitDepth
= z_depth
;
226 surface_desc
.dwWidth
= 640;
227 surface_desc
.dwHeight
= 480;
228 hr
= IDirectDraw2_CreateSurface(ddraw
, &surface_desc
, &ds
, NULL
);
229 ok(SUCCEEDED(hr
), "Failed to create depth buffer, hr %#x.\n", hr
);
232 IDirect3D2_Release(d3d
);
233 IDirectDrawSurface_Release(surface
);
237 hr
= IDirectDrawSurface_AddAttachedSurface(surface
, ds
);
238 ok(SUCCEEDED(hr
), "Failed to attach depth buffer, hr %#x.\n", hr
);
239 IDirectDrawSurface_Release(ds
);
242 IDirect3D2_Release(d3d
);
243 IDirectDrawSurface_Release(surface
);
247 hr
= IDirect3D2_CreateDevice(d3d
, &IID_IDirect3DHALDevice
, surface
, &device
);
248 IDirect3D2_Release(d3d
);
249 IDirectDrawSurface_Release(surface
);
256 static IDirect3DViewport2
*create_viewport(IDirect3DDevice2
*device
, UINT x
, UINT y
, UINT w
, UINT h
)
258 IDirect3DViewport2
*viewport
;
263 hr
= IDirect3DDevice2_GetDirect3D(device
, &d3d
);
264 ok(SUCCEEDED(hr
), "Failed to get d3d interface, hr %#x.\n", hr
);
265 hr
= IDirect3D2_CreateViewport(d3d
, &viewport
, NULL
);
266 ok(SUCCEEDED(hr
), "Failed to create viewport, hr %#x.\n", hr
);
267 hr
= IDirect3DDevice2_AddViewport(device
, viewport
);
268 ok(SUCCEEDED(hr
), "Failed to add viewport, hr %#x.\n", hr
);
269 memset(&vp
, 0, sizeof(vp
));
270 vp
.dwSize
= sizeof(vp
);
277 vp
.dvClipWidth
= 2.0f
;
278 vp
.dvClipHeight
= 2.0f
;
281 hr
= IDirect3DViewport2_SetViewport2(viewport
, &vp
);
282 ok(SUCCEEDED(hr
), "Failed to set viewport data, hr %#x.\n", hr
);
283 IDirect3D2_Release(d3d
);
288 static void destroy_viewport(IDirect3DDevice2
*device
, IDirect3DViewport2
*viewport
)
292 hr
= IDirect3DDevice2_DeleteViewport(device
, viewport
);
293 ok(SUCCEEDED(hr
), "Failed to delete viewport, hr %#x.\n", hr
);
294 IDirect3DViewport2_Release(viewport
);
297 static IDirect3DMaterial2
*create_diffuse_material(IDirect3DDevice2
*device
, float r
, float g
, float b
, float a
)
299 IDirect3DMaterial2
*material
;
304 hr
= IDirect3DDevice2_GetDirect3D(device
, &d3d
);
305 ok(SUCCEEDED(hr
), "Failed to get d3d interface, hr %#x.\n", hr
);
306 hr
= IDirect3D2_CreateMaterial(d3d
, &material
, NULL
);
307 ok(SUCCEEDED(hr
), "Failed to create material, hr %#x.\n", hr
);
308 memset(&mat
, 0, sizeof(mat
));
309 mat
.dwSize
= sizeof(mat
);
310 U1(U(mat
).diffuse
).r
= r
;
311 U2(U(mat
).diffuse
).g
= g
;
312 U3(U(mat
).diffuse
).b
= b
;
313 U4(U(mat
).diffuse
).a
= a
;
314 hr
= IDirect3DMaterial2_SetMaterial(material
, &mat
);
315 ok(SUCCEEDED(hr
), "Failed to set material data, hr %#x.\n", hr
);
316 IDirect3D2_Release(d3d
);
321 static void destroy_material(IDirect3DMaterial2
*material
)
323 IDirect3DMaterial2_Release(material
);
326 static HRESULT CALLBACK
restore_callback(IDirectDrawSurface
*surface
, DDSURFACEDESC
*desc
, void *context
)
328 HRESULT hr
= IDirectDrawSurface_Restore(surface
);
329 ok(SUCCEEDED(hr
), "Failed to restore surface, hr %#x.\n", hr
);
330 IDirectDrawSurface_Release(surface
);
335 static HRESULT
restore_surfaces(IDirectDraw2
*ddraw
)
337 return IDirectDraw2_EnumSurfaces(ddraw
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
338 NULL
, NULL
, restore_callback
);
341 static void test_coop_level_create_device_window(void)
343 HWND focus_window
, device_window
;
347 focus_window
= CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW
,
348 0, 0, 640, 480, 0, 0, 0, 0);
349 if (!(ddraw
= create_ddraw()))
351 skip("Failed to create a ddraw object, skipping test.\n");
352 DestroyWindow(focus_window
);
356 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, NULL
, DDSCL_NORMAL
);
357 ok(hr
== DD_OK
, "Got unexpected hr %#x.\n", hr
);
358 device_window
= FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
359 ok(!device_window
, "Unexpected device window found.\n");
360 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, NULL
, DDSCL_CREATEDEVICEWINDOW
);
361 ok(hr
== DDERR_INVALIDPARAMS
, "Got unexpected hr %#x.\n", hr
);
362 device_window
= FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
363 ok(!device_window
, "Unexpected device window found.\n");
364 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, NULL
, DDSCL_CREATEDEVICEWINDOW
| DDSCL_NORMAL
);
365 ok(hr
== DDERR_INVALIDPARAMS
, "Got unexpected hr %#x.\n", hr
);
366 device_window
= FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
367 ok(!device_window
, "Unexpected device window found.\n");
368 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, NULL
, DDSCL_CREATEDEVICEWINDOW
| DDSCL_NORMAL
| DDSCL_FULLSCREEN
);
369 ok(hr
== DDERR_INVALIDPARAMS
, "Got unexpected hr %#x.\n", hr
);
370 device_window
= FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
371 ok(!device_window
, "Unexpected device window found.\n");
372 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, NULL
, DDSCL_CREATEDEVICEWINDOW
| DDSCL_EXCLUSIVE
| DDSCL_FULLSCREEN
);
373 ok(hr
== DDERR_NOFOCUSWINDOW
|| broken(hr
== DDERR_INVALIDPARAMS
), "Got unexpected hr %#x.\n", hr
);
374 device_window
= FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
375 ok(!device_window
, "Unexpected device window found.\n");
377 /* Windows versions before 98 / NT5 don't support DDSCL_CREATEDEVICEWINDOW. */
378 if (broken(hr
== DDERR_INVALIDPARAMS
))
380 win_skip("DDSCL_CREATEDEVICEWINDOW not supported, skipping test.\n");
381 IDirectDraw2_Release(ddraw
);
382 DestroyWindow(focus_window
);
386 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, NULL
, DDSCL_NORMAL
);
387 ok(hr
== DD_OK
, "Got unexpected hr %#x.\n", hr
);
388 device_window
= FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
389 ok(!device_window
, "Unexpected device window found.\n");
390 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, focus_window
, DDSCL_EXCLUSIVE
| DDSCL_FULLSCREEN
);
391 ok(hr
== DD_OK
, "Got unexpected hr %#x.\n", hr
);
392 device_window
= FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
393 ok(!device_window
, "Unexpected device window found.\n");
395 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, NULL
, DDSCL_NORMAL
);
396 ok(hr
== DD_OK
, "Got unexpected hr %#x.\n", hr
);
397 device_window
= FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
398 ok(!device_window
, "Unexpected device window found.\n");
399 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, NULL
, DDSCL_SETFOCUSWINDOW
400 | DDSCL_CREATEDEVICEWINDOW
| DDSCL_EXCLUSIVE
| DDSCL_FULLSCREEN
);
401 ok(hr
== DDERR_NOHWND
, "Got unexpected hr %#x.\n", hr
);
402 device_window
= FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
403 ok(!!device_window
, "Device window not found.\n");
405 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, NULL
, DDSCL_NORMAL
);
406 ok(hr
== DD_OK
, "Got unexpected hr %#x.\n", hr
);
407 device_window
= FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
408 ok(!device_window
, "Unexpected device window found.\n");
409 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, focus_window
, DDSCL_SETFOCUSWINDOW
410 | DDSCL_CREATEDEVICEWINDOW
| DDSCL_EXCLUSIVE
| DDSCL_FULLSCREEN
);
411 ok(hr
== DD_OK
, "Got unexpected hr %#x.\n", hr
);
412 device_window
= FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
413 ok(!!device_window
, "Device window not found.\n");
415 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, NULL
, DDSCL_NORMAL
);
416 ok(hr
== DD_OK
, "Got unexpected hr %#x.\n", hr
);
417 device_window
= FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
418 ok(!device_window
, "Unexpected device window found.\n");
419 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, NULL
, DDSCL_CREATEDEVICEWINDOW
| DDSCL_EXCLUSIVE
| DDSCL_FULLSCREEN
);
420 ok(hr
== DDERR_NOFOCUSWINDOW
, "Got unexpected hr %#x.\n", hr
);
421 device_window
= FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
422 ok(!device_window
, "Unexpected device window found.\n");
423 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, focus_window
, DDSCL_SETFOCUSWINDOW
);
424 ok(hr
== DD_OK
, "Got unexpected hr %#x.\n", hr
);
425 device_window
= FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
426 ok(!device_window
, "Unexpected device window found.\n");
427 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, NULL
, DDSCL_CREATEDEVICEWINDOW
| DDSCL_EXCLUSIVE
| DDSCL_FULLSCREEN
);
428 ok(hr
== DD_OK
, "Got unexpected hr %#x.\n", hr
);
429 device_window
= FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
430 ok(!!device_window
, "Device window not found.\n");
432 IDirectDraw2_Release(ddraw
);
433 DestroyWindow(focus_window
);
436 static void test_clipper_blt(void)
438 IDirectDrawSurface
*src_surface
, *dst_surface
;
439 RECT client_rect
, src_rect
, *rect
;
440 IDirectDrawClipper
*clipper
;
441 DDSURFACEDESC surface_desc
;
442 unsigned int i
, j
, x
, y
;
453 static const DWORD src_data
[] =
455 0xff0000ff, 0xff0000ff, 0xff00ff00, 0xffff0000, 0xffffffff, 0xffffffff,
456 0xff0000ff, 0xff0000ff, 0xff00ff00, 0xffff0000, 0xffffffff, 0xffffffff,
457 0xff0000ff, 0xff0000ff, 0xff00ff00, 0xffff0000, 0xffffffff, 0xffffffff,
459 static const D3DCOLOR expected1
[] =
461 0x000000ff, 0x0000ff00, 0x00000000, 0x00000000,
462 0x000000ff, 0x0000ff00, 0x00000000, 0x00000000,
463 0x00000000, 0x00000000, 0x00ff0000, 0x00ffffff,
464 0x00000000, 0x00000000, 0x00ff0000, 0x00ffffff,
466 static const D3DCOLOR expected2
[] =
468 0x000000ff, 0x000000ff, 0x00000000, 0x00000000,
469 0x000000ff, 0x000000ff, 0x00000000, 0x00000000,
470 0x00000000, 0x00000000, 0x000000ff, 0x000000ff,
471 0x00000000, 0x00000000, 0x000000ff, 0x000000ff,
474 window
= CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW
,
475 10, 10, 640, 480, 0, 0, 0, 0);
476 ShowWindow(window
, SW_SHOW
);
477 if (!(ddraw
= create_ddraw()))
479 skip("Failed to create a ddraw object, skipping test.\n");
480 DestroyWindow(window
);
484 ret
= GetClientRect(window
, &client_rect
);
485 ok(ret
, "Failed to get client rect.\n");
486 ret
= MapWindowPoints(window
, NULL
, (POINT
*)&client_rect
, 2);
487 ok(ret
, "Failed to map client rect.\n");
489 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, window
, DDSCL_NORMAL
);
490 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#x.\n", hr
);
492 hr
= IDirectDraw2_CreateClipper(ddraw
, 0, &clipper
, NULL
);
493 ok(SUCCEEDED(hr
), "Failed to create clipper, hr %#x.\n", hr
);
494 hr
= IDirectDrawClipper_GetClipList(clipper
, NULL
, NULL
, &ret
);
495 ok(hr
== DDERR_NOCLIPLIST
, "Got unexpected hr %#x.\n", hr
);
496 hr
= IDirectDrawClipper_SetHWnd(clipper
, 0, window
);
497 ok(SUCCEEDED(hr
), "Failed to set clipper window, hr %#x.\n", hr
);
498 hr
= IDirectDrawClipper_GetClipList(clipper
, NULL
, NULL
, &ret
);
499 ok(SUCCEEDED(hr
), "Failed to get clip list size, hr %#x.\n", hr
);
500 rgn_data
= HeapAlloc(GetProcessHeap(), 0, ret
);
501 hr
= IDirectDrawClipper_GetClipList(clipper
, NULL
, rgn_data
, &ret
);
502 ok(SUCCEEDED(hr
), "Failed to get clip list, hr %#x.\n", hr
);
503 ok(rgn_data
->rdh
.dwSize
== sizeof(rgn_data
->rdh
), "Got unexpected structure size %#x.\n", rgn_data
->rdh
.dwSize
);
504 ok(rgn_data
->rdh
.iType
== RDH_RECTANGLES
, "Got unexpected type %#x.\n", rgn_data
->rdh
.iType
);
505 ok(rgn_data
->rdh
.nCount
== 1, "Got unexpected count %u.\n", rgn_data
->rdh
.nCount
);
506 ok(rgn_data
->rdh
.nRgnSize
== 16 || broken(rgn_data
->rdh
.nRgnSize
== 168 /* NT4 */),
507 "Got unexpected region size %u.\n", rgn_data
->rdh
.nRgnSize
);
508 ok(EqualRect(&rgn_data
->rdh
.rcBound
, &client_rect
),
509 "Got unexpected bounding rect {%d, %d, %d, %d}, expected {%d, %d, %d, %d}.\n",
510 rgn_data
->rdh
.rcBound
.left
, rgn_data
->rdh
.rcBound
.top
,
511 rgn_data
->rdh
.rcBound
.right
, rgn_data
->rdh
.rcBound
.bottom
,
512 client_rect
.left
, client_rect
.top
, client_rect
.right
, client_rect
.bottom
);
513 rect
= (RECT
*)&rgn_data
->Buffer
[0];
514 ok(EqualRect(rect
, &client_rect
),
515 "Got unexpected clip rect {%d, %d, %d, %d}, expected {%d, %d, %d, %d}.\n",
516 rect
->left
, rect
->top
, rect
->right
, rect
->bottom
,
517 client_rect
.left
, client_rect
.top
, client_rect
.right
, client_rect
.bottom
);
518 HeapFree(GetProcessHeap(), 0, rgn_data
);
520 r1
= CreateRectRgn(0, 0, 320, 240);
521 ok(!!r1
, "Failed to create region.\n");
522 r2
= CreateRectRgn(320, 240, 640, 480);
523 ok(!!r2
, "Failed to create region.\n");
524 CombineRgn(r1
, r1
, r2
, RGN_OR
);
525 ret
= GetRegionData(r1
, 0, NULL
);
526 rgn_data
= HeapAlloc(GetProcessHeap(), 0, ret
);
527 ret
= GetRegionData(r1
, ret
, rgn_data
);
528 ok(!!ret
, "Failed to get region data.\n");
533 hr
= IDirectDrawClipper_SetClipList(clipper
, rgn_data
, 0);
534 ok(hr
== DDERR_CLIPPERISUSINGHWND
, "Got unexpected hr %#x.\n", hr
);
535 hr
= IDirectDrawClipper_SetHWnd(clipper
, 0, NULL
);
536 ok(SUCCEEDED(hr
), "Failed to set clipper window, hr %#x.\n", hr
);
537 hr
= IDirectDrawClipper_SetClipList(clipper
, rgn_data
, 0);
538 ok(SUCCEEDED(hr
), "Failed to set clip list, hr %#x.\n", hr
);
540 HeapFree(GetProcessHeap(), 0, rgn_data
);
542 memset(&surface_desc
, 0, sizeof(surface_desc
));
543 surface_desc
.dwSize
= sizeof(surface_desc
);
544 surface_desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PIXELFORMAT
;
545 surface_desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
;
546 surface_desc
.dwWidth
= 640;
547 surface_desc
.dwHeight
= 480;
548 surface_desc
.ddpfPixelFormat
.dwSize
= sizeof(surface_desc
.ddpfPixelFormat
);
549 surface_desc
.ddpfPixelFormat
.dwFlags
= DDPF_RGB
;
550 U1(surface_desc
.ddpfPixelFormat
).dwRGBBitCount
= 32;
551 U2(surface_desc
.ddpfPixelFormat
).dwRBitMask
= 0x00ff0000;
552 U3(surface_desc
.ddpfPixelFormat
).dwGBitMask
= 0x0000ff00;
553 U4(surface_desc
.ddpfPixelFormat
).dwBBitMask
= 0x000000ff;
555 hr
= IDirectDraw2_CreateSurface(ddraw
, &surface_desc
, &src_surface
, NULL
);
556 ok(SUCCEEDED(hr
), "Failed to create source surface, hr %#x.\n", hr
);
557 hr
= IDirectDraw2_CreateSurface(ddraw
, &surface_desc
, &dst_surface
, NULL
);
558 ok(SUCCEEDED(hr
), "Failed to create destination surface, hr %#x.\n", hr
);
560 memset(&fx
, 0, sizeof(fx
));
561 fx
.dwSize
= sizeof(fx
);
562 hr
= IDirectDrawSurface_Blt(src_surface
, NULL
, NULL
, NULL
, DDBLT_COLORFILL
| DDBLT_WAIT
, &fx
);
563 ok(SUCCEEDED(hr
), "Failed to clear source surface, hr %#x.\n", hr
);
564 hr
= IDirectDrawSurface_Blt(dst_surface
, NULL
, NULL
, NULL
, DDBLT_COLORFILL
| DDBLT_WAIT
, &fx
);
565 ok(SUCCEEDED(hr
), "Failed to clear destination surface, hr %#x.\n", hr
);
567 hr
= IDirectDrawSurface_Lock(src_surface
, NULL
, &surface_desc
, DDLOCK_WAIT
, NULL
);
568 ok(SUCCEEDED(hr
), "Failed to lock source surface, hr %#x.\n", hr
);
569 ok(U1(surface_desc
).lPitch
== 2560, "Got unexpected surface pitch %u.\n", U1(surface_desc
).lPitch
);
570 ptr
= surface_desc
.lpSurface
;
571 memcpy(&ptr
[ 0], &src_data
[ 0], 6 * sizeof(DWORD
));
572 memcpy(&ptr
[ 640], &src_data
[ 6], 6 * sizeof(DWORD
));
573 memcpy(&ptr
[1280], &src_data
[12], 6 * sizeof(DWORD
));
574 hr
= IDirectDrawSurface_Unlock(src_surface
, NULL
);
575 ok(SUCCEEDED(hr
), "Failed to unlock source surface, hr %#x.\n", hr
);
577 hr
= IDirectDrawSurface_SetClipper(dst_surface
, clipper
);
578 ok(SUCCEEDED(hr
), "Failed to set clipper, hr %#x.\n", hr
);
580 SetRect(&src_rect
, 1, 1, 5, 2);
581 hr
= IDirectDrawSurface_Blt(dst_surface
, NULL
, src_surface
, &src_rect
, DDBLT_WAIT
, NULL
);
582 ok(SUCCEEDED(hr
), "Failed to blit, hr %#x.\n", hr
);
583 for (i
= 0; i
< 4; ++i
)
585 for (j
= 0; j
< 4; ++j
)
587 x
= 80 * ((2 * j
) + 1);
588 y
= 60 * ((2 * i
) + 1);
589 color
= get_surface_color(dst_surface
, x
, y
);
590 ok(compare_color(color
, expected1
[i
* 4 + j
], 1),
591 "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected1
[i
* 4 + j
], x
, y
, color
);
595 U5(fx
).dwFillColor
= 0xff0000ff;
596 hr
= IDirectDrawSurface_Blt(dst_surface
, NULL
, NULL
, NULL
, DDBLT_COLORFILL
| DDBLT_WAIT
, &fx
);
597 ok(SUCCEEDED(hr
), "Failed to clear destination surface, hr %#x.\n", hr
);
598 for (i
= 0; i
< 4; ++i
)
600 for (j
= 0; j
< 4; ++j
)
602 x
= 80 * ((2 * j
) + 1);
603 y
= 60 * ((2 * i
) + 1);
604 color
= get_surface_color(dst_surface
, x
, y
);
605 ok(compare_color(color
, expected2
[i
* 4 + j
], 1),
606 "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected2
[i
* 4 + j
], x
, y
, color
);
610 hr
= IDirectDrawSurface_BltFast(dst_surface
, 0, 0, src_surface
, NULL
, DDBLTFAST_WAIT
);
611 ok(hr
== DDERR_BLTFASTCANTCLIP
|| broken(hr
== E_NOTIMPL
/* NT4 */), "Got unexpected hr %#x.\n", hr
);
613 hr
= IDirectDrawClipper_SetHWnd(clipper
, 0, window
);
614 ok(SUCCEEDED(hr
), "Failed to set clipper window, hr %#x.\n", hr
);
615 hr
= IDirectDrawClipper_GetClipList(clipper
, NULL
, NULL
, &ret
);
616 ok(SUCCEEDED(hr
), "Failed to get clip list size, hr %#x.\n", hr
);
617 DestroyWindow(window
);
618 hr
= IDirectDrawClipper_GetClipList(clipper
, NULL
, NULL
, &ret
);
619 ok(hr
== E_FAIL
, "Got unexpected hr %#x.\n", hr
);
620 hr
= IDirectDrawClipper_SetHWnd(clipper
, 0, NULL
);
621 ok(SUCCEEDED(hr
), "Failed to set clipper window, hr %#x.\n", hr
);
622 hr
= IDirectDrawClipper_GetClipList(clipper
, NULL
, NULL
, &ret
);
623 ok(SUCCEEDED(hr
), "Failed to get clip list size, hr %#x.\n", hr
);
624 hr
= IDirectDrawClipper_SetClipList(clipper
, NULL
, 0);
625 ok(SUCCEEDED(hr
), "Failed to set clip list, hr %#x.\n", hr
);
626 hr
= IDirectDrawClipper_GetClipList(clipper
, NULL
, NULL
, &ret
);
627 ok(hr
== DDERR_NOCLIPLIST
, "Got unexpected hr %#x.\n", hr
);
628 hr
= IDirectDrawSurface_Blt(dst_surface
, NULL
, NULL
, NULL
, DDBLT_COLORFILL
| DDBLT_WAIT
, &fx
);
629 ok(hr
== DDERR_NOCLIPLIST
, "Got unexpected hr %#x.\n", hr
);
631 IDirectDrawSurface_Release(dst_surface
);
632 IDirectDrawSurface_Release(src_surface
);
633 IDirectDrawClipper_Release(clipper
);
634 IDirectDraw2_Release(ddraw
);
637 static void test_coop_level_d3d_state(void)
639 D3DRECT clear_rect
= {{0}, {0}, {640}, {480}};
640 D3DMATERIALHANDLE background_handle
;
641 IDirectDrawSurface
*rt
, *surface
;
642 IDirect3DMaterial2
*background
;
643 IDirect3DViewport2
*viewport
;
644 IDirect3DDevice2
*device
;
645 D3DMATERIAL material
;
652 window
= CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW
,
653 0, 0, 640, 480, 0, 0, 0, 0);
654 if (!(ddraw
= create_ddraw()))
656 skip("Failed to create ddraw object, skipping test.\n");
657 DestroyWindow(window
);
660 if (!(device
= create_device(ddraw
, window
, DDSCL_NORMAL
)))
662 skip("Failed to create D3D device, skipping test.\n");
663 IDirectDraw2_Release(ddraw
);
664 DestroyWindow(window
);
668 background
= create_diffuse_material(device
, 1.0f
, 0.0f
, 0.0f
, 1.0f
);
669 viewport
= create_viewport(device
, 0, 0, 640, 480);
671 hr
= IDirect3DMaterial2_GetHandle(background
, device
, &background_handle
);
672 ok(SUCCEEDED(hr
), "Failed to get material handle, hr %#x.\n", hr
);
673 hr
= IDirect3DViewport2_SetBackground(viewport
, background_handle
);
674 ok(SUCCEEDED(hr
), "Failed to set viewport background, hr %#x.\n", hr
);
676 hr
= IDirect3DDevice2_GetRenderTarget(device
, &rt
);
677 ok(SUCCEEDED(hr
), "Failed to get render target, hr %#x.\n", hr
);
678 hr
= IDirect3DDevice2_GetRenderState(device
, D3DRENDERSTATE_ZENABLE
, &value
);
679 ok(SUCCEEDED(hr
), "Failed to get render state, hr %#x.\n", hr
);
680 ok(!!value
, "Got unexpected z-enable state %#x.\n", value
);
681 hr
= IDirect3DDevice2_GetRenderState(device
, D3DRENDERSTATE_ALPHABLENDENABLE
, &value
);
682 ok(SUCCEEDED(hr
), "Failed to get render state, hr %#x.\n", hr
);
683 ok(!value
, "Got unexpected alpha blend enable state %#x.\n", value
);
684 hr
= IDirect3DDevice2_SetRenderState(device
, D3DRENDERSTATE_ALPHABLENDENABLE
, TRUE
);
685 ok(SUCCEEDED(hr
), "Failed to set render state, hr %#x.\n", hr
);
686 hr
= IDirect3DViewport2_Clear(viewport
, 1, &clear_rect
, D3DCLEAR_TARGET
);
687 ok(SUCCEEDED(hr
), "Failed to clear viewport, hr %#x.\n", hr
);
688 color
= get_surface_color(rt
, 320, 240);
689 ok(compare_color(color
, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color
);
691 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, window
, DDSCL_EXCLUSIVE
| DDSCL_FULLSCREEN
);
692 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#x.\n", hr
);
693 hr
= IDirectDrawSurface_IsLost(rt
);
694 ok(hr
== DDERR_SURFACELOST
, "Got unexpected hr %#x.\n", hr
);
695 hr
= restore_surfaces(ddraw
);
696 ok(SUCCEEDED(hr
), "Failed to restore surfaces, hr %#x.\n", hr
);
698 memset(&material
, 0, sizeof(material
));
699 material
.dwSize
= sizeof(material
);
700 U1(U(material
).diffuse
).r
= 0.0f
;
701 U2(U(material
).diffuse
).g
= 1.0f
;
702 U3(U(material
).diffuse
).b
= 0.0f
;
703 U4(U(material
).diffuse
).a
= 1.0f
;
704 hr
= IDirect3DMaterial2_SetMaterial(background
, &material
);
705 ok(SUCCEEDED(hr
), "Failed to set material data, hr %#x.\n", hr
);
707 hr
= IDirect3DDevice2_GetRenderTarget(device
, &surface
);
708 ok(SUCCEEDED(hr
), "Failed to get render target, hr %#x.\n", hr
);
709 ok(surface
== rt
, "Got unexpected surface %p.\n", surface
);
710 hr
= IDirect3DDevice2_GetRenderState(device
, D3DRENDERSTATE_ZENABLE
, &value
);
711 ok(SUCCEEDED(hr
), "Failed to get render state, hr %#x.\n", hr
);
712 ok(!!value
, "Got unexpected z-enable state %#x.\n", value
);
713 hr
= IDirect3DDevice2_GetRenderState(device
, D3DRENDERSTATE_ALPHABLENDENABLE
, &value
);
714 ok(SUCCEEDED(hr
), "Failed to get render state, hr %#x.\n", hr
);
715 ok(!!value
, "Got unexpected alpha blend enable state %#x.\n", value
);
716 hr
= IDirect3DViewport2_Clear(viewport
, 1, &clear_rect
, D3DCLEAR_TARGET
);
717 ok(SUCCEEDED(hr
), "Failed to clear viewport, hr %#x.\n", hr
);
718 color
= get_surface_color(rt
, 320, 240);
719 ok(compare_color(color
, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color
);
721 destroy_viewport(device
, viewport
);
722 destroy_material(background
);
723 IDirectDrawSurface_Release(surface
);
724 IDirectDrawSurface_Release(rt
);
725 IDirect3DDevice2_Release(device
);
726 IDirectDraw2_Release(ddraw
);
727 DestroyWindow(window
);
730 static void test_surface_interface_mismatch(void)
732 IDirectDraw2
*ddraw
= NULL
;
733 IDirect3D2
*d3d
= NULL
;
734 IDirectDrawSurface
*surface
= NULL
, *ds
;
735 IDirectDrawSurface3
*surface3
= NULL
;
736 IDirect3DDevice2
*device
= NULL
;
737 IDirect3DViewport2
*viewport
= NULL
;
738 IDirect3DMaterial2
*background
= NULL
;
739 DDSURFACEDESC surface_desc
;
745 D3DMATERIALHANDLE background_handle
;
746 D3DRECT clear_rect
= {{0}, {0}, {640}, {480}};
748 window
= CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW
,
749 0, 0, 640, 480, 0, 0, 0, 0);
751 if (!(ddraw
= create_ddraw()))
753 skip("Failed to create a ddraw object, skipping test.\n");
757 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, window
, DDSCL_NORMAL
);
758 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#x.\n", hr
);
760 memset(&surface_desc
, 0, sizeof(surface_desc
));
761 surface_desc
.dwSize
= sizeof(surface_desc
);
762 surface_desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
763 surface_desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
;
764 surface_desc
.dwWidth
= 640;
765 surface_desc
.dwHeight
= 480;
767 hr
= IDirectDraw2_CreateSurface(ddraw
, &surface_desc
, &surface
, NULL
);
768 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
770 hr
= IDirectDrawSurface2_QueryInterface(surface
, &IID_IDirectDrawSurface3
, (void **)&surface3
);
773 skip("Failed to get the IDirectDrawSurface3 interface, skipping test.\n");
777 hr
= IDirectDraw2_QueryInterface(ddraw
, &IID_IDirect3D2
, (void **)&d3d
);
780 skip("Failed to get the IDirect3D2 interface, skipping test.\n");
784 hr
= IDirect3D2_EnumDevices(d3d
, enum_z_fmt
, &z_depth
);
785 if (FAILED(hr
) || !z_depth
)
787 skip("No depth buffer formats available, skipping test.\n");
791 memset(&surface_desc
, 0, sizeof(surface_desc
));
792 surface_desc
.dwSize
= sizeof(surface_desc
);
793 surface_desc
.dwFlags
= DDSD_CAPS
| DDSD_ZBUFFERBITDEPTH
| DDSD_WIDTH
| DDSD_HEIGHT
;
794 surface_desc
.ddsCaps
.dwCaps
= DDSCAPS_ZBUFFER
;
795 U2(surface_desc
).dwZBufferBitDepth
= z_depth
;
796 surface_desc
.dwWidth
= 640;
797 surface_desc
.dwHeight
= 480;
798 hr
= IDirectDraw2_CreateSurface(ddraw
, &surface_desc
, &ds
, NULL
);
799 ok(SUCCEEDED(hr
), "Failed to create depth buffer, hr %#x.\n", hr
);
803 /* Using a different surface interface version still works */
804 hr
= IDirectDrawSurface3_AddAttachedSurface(surface3
, (IDirectDrawSurface3
*)ds
);
805 ok(SUCCEEDED(hr
), "Failed to attach depth buffer, hr %#x.\n", hr
);
806 refcount
= IDirectDrawSurface_Release(ds
);
807 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
812 hr
= IDirect3D2_CreateDevice(d3d
, &IID_IDirect3DHALDevice
, (IDirectDrawSurface
*)surface3
, &device
);
813 ok(SUCCEEDED(hr
), "Failed to create d3d device.\n");
817 background
= create_diffuse_material(device
, 1.0f
, 0.0f
, 0.0f
, 1.0f
);
818 viewport
= create_viewport(device
, 0, 0, 640, 480);
820 hr
= IDirect3DMaterial2_GetHandle(background
, device
, &background_handle
);
821 ok(SUCCEEDED(hr
), "Failed to get material handle, hr %#x.\n", hr
);
822 hr
= IDirect3DViewport2_SetBackground(viewport
, background_handle
);
823 ok(SUCCEEDED(hr
), "Failed to set viewport background, hr %#x.\n", hr
);
825 hr
= IDirect3DViewport2_Clear(viewport
, 1, &clear_rect
, D3DCLEAR_TARGET
);
826 ok(SUCCEEDED(hr
), "Failed to clear render target, hr %#x.\n", hr
);
827 color
= get_surface_color(surface
, 320, 240);
828 ok(compare_color(color
, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color
);
832 destroy_viewport(device
, viewport
);
834 destroy_material(background
);
835 if (surface3
) IDirectDrawSurface3_Release(surface3
);
836 if (surface
) IDirectDrawSurface_Release(surface
);
837 if (device
) IDirect3DDevice2_Release(device
);
838 if (d3d
) IDirect3D2_Release(d3d
);
839 if (ddraw
) IDirectDraw2_Release(ddraw
);
840 DestroyWindow(window
);
843 static void test_coop_level_threaded(void)
845 struct create_window_thread_param p
;
849 if (!(ddraw
= create_ddraw()))
851 skip("Failed to create a ddraw object, skipping test.\n");
854 create_window_thread(&p
);
856 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, p
.window
, DDSCL_EXCLUSIVE
| DDSCL_FULLSCREEN
);
857 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#x.\n", hr
);
859 IDirectDraw2_Release(ddraw
);
860 destroy_window_thread(&p
);
863 static void test_depth_blit(void)
865 static D3DLVERTEX quad1
[] =
867 {{-1.0}, { 1.0}, {0.50f
}, 0, {0xff00ff00}},
868 {{ 1.0}, { 1.0}, {0.50f
}, 0, {0xff00ff00}},
869 {{-1.0}, {-1.0}, {0.50f
}, 0, {0xff00ff00}},
870 {{ 1.0}, {-1.0}, {0.50f
}, 0, {0xff00ff00}},
872 static const D3DCOLOR expected_colors
[4][4] =
874 {0x00ff0000, 0x00ff0000, 0x0000ff00, 0x0000ff00},
875 {0x00ff0000, 0x00ff0000, 0x0000ff00, 0x0000ff00},
876 {0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00},
877 {0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00},
879 static const BOOL todo
[4][4] =
881 {FALSE
, FALSE
, TRUE
, TRUE
},
882 {FALSE
, FALSE
, TRUE
, TRUE
},
883 {TRUE
, TRUE
, TRUE
, TRUE
},
884 {TRUE
, TRUE
, TRUE
, TRUE
},
886 DDSURFACEDESC ddsd_new
, ddsd_existing
;
888 IDirect3DDevice2
*device
;
889 IDirectDrawSurface
*ds1
, *ds2
, *ds3
, *rt
;
890 IDirect3DViewport2
*viewport
;
891 RECT src_rect
, dst_rect
;
899 IDirect3DMaterial2
*background
;
900 D3DMATERIALHANDLE background_handle
;
902 window
= CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW
,
903 0, 0, 640, 480, 0, 0, 0, 0);
904 if (!(ddraw
= create_ddraw()))
906 skip("Failed to create ddraw object, skipping test.\n");
907 DestroyWindow(window
);
910 if (!(device
= create_device(ddraw
, window
, DDSCL_NORMAL
)))
912 skip("Failed to create D3D device, skipping test.\n");
913 IDirectDraw2_Release(ddraw
);
914 DestroyWindow(window
);
918 ds1
= get_depth_stencil(device
);
920 memset(&ddsd_new
, 0, sizeof(ddsd_new
));
921 ddsd_new
.dwSize
= sizeof(ddsd_new
);
922 memset(&ddsd_existing
, 0, sizeof(ddsd_existing
));
923 ddsd_existing
.dwSize
= sizeof(ddsd_existing
);
924 hr
= IDirectDrawSurface_GetSurfaceDesc(ds1
, &ddsd_existing
);
925 ddsd_new
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PIXELFORMAT
;
926 ddsd_new
.ddsCaps
.dwCaps
= DDSCAPS_ZBUFFER
;
927 ddsd_new
.dwWidth
= ddsd_existing
.dwWidth
;
928 ddsd_new
.dwHeight
= ddsd_existing
.dwHeight
;
929 ddsd_new
.ddpfPixelFormat
= ddsd_existing
.ddpfPixelFormat
;
930 hr
= IDirectDraw2_CreateSurface(ddraw
, &ddsd_new
, &ds2
, NULL
);
931 ok(SUCCEEDED(hr
), "Failed to create a surface, hr %#x.\n", hr
);
932 hr
= IDirectDraw2_CreateSurface(ddraw
, &ddsd_new
, &ds3
, NULL
);
933 ok(SUCCEEDED(hr
), "Failed to create a surface, hr %#x.\n", hr
);
935 background
= create_diffuse_material(device
, 1.0f
, 0.0f
, 0.0f
, 1.0f
);
936 viewport
= create_viewport(device
, 0, 0, ddsd_existing
.dwWidth
, ddsd_existing
.dwHeight
);
937 hr
= IDirect3DDevice2_SetCurrentViewport(device
, viewport
);
938 ok(SUCCEEDED(hr
), "Failed to activate the viewport, hr %#x.\n", hr
);
940 hr
= IDirect3DMaterial2_GetHandle(background
, device
, &background_handle
);
941 ok(SUCCEEDED(hr
), "Failed to get material handle, hr %#x.\n", hr
);
942 hr
= IDirect3DViewport2_SetBackground(viewport
, background_handle
);
943 ok(SUCCEEDED(hr
), "Failed to set viewport background, hr %#x.\n", hr
);
945 hr
= IDirect3DDevice2_SetRenderState(device
, D3DRENDERSTATE_ZENABLE
, D3DZB_TRUE
);
946 ok(SUCCEEDED(hr
), "Failed to enable z testing, hr %#x.\n", hr
);
947 hr
= IDirect3DDevice2_SetRenderState(device
, D3DRENDERSTATE_ZFUNC
, D3DCMP_LESSEQUAL
);
948 ok(SUCCEEDED(hr
), "Failed to set the z function, hr %#x.\n", hr
);
950 U1(d3drect
).x1
= U2(d3drect
).y1
= 0;
951 U3(d3drect
).x2
= ddsd_existing
.dwWidth
; U4(d3drect
).y2
= ddsd_existing
.dwHeight
;
952 hr
= IDirect3DViewport2_Clear(viewport
, 1, &d3drect
, D3DCLEAR_ZBUFFER
);
953 ok(SUCCEEDED(hr
), "Failed to clear the z buffer, hr %#x.\n", hr
);
956 SetRect(&src_rect
, 0, 0, 320, 240);
957 SetRect(&dst_rect
, 0, 0, 320, 240);
958 hr
= IDirectDrawSurface_Blt(ds2
, &dst_rect
, ds1
, &src_rect
, DDBLT_WAIT
, NULL
);
959 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
960 /* Different locations. */
961 SetRect(&src_rect
, 0, 0, 320, 240);
962 SetRect(&dst_rect
, 320, 240, 640, 480);
963 hr
= IDirectDrawSurface_Blt(ds2
, &dst_rect
, ds1
, &src_rect
, DDBLT_WAIT
, NULL
);
964 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
966 SetRect(&src_rect
, 0, 0, 320, 240);
967 SetRect(&dst_rect
, 0, 0, 640, 480);
968 hr
= IDirectDrawSurface_Blt(ds2
, &dst_rect
, ds1
, &src_rect
, DDBLT_WAIT
, NULL
);
969 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
971 SetRect(&src_rect
, 0, 480, 640, 0);
972 SetRect(&dst_rect
, 0, 0, 640, 480);
973 hr
= IDirectDrawSurface_Blt(ds2
, &dst_rect
, ds1
, &src_rect
, DDBLT_WAIT
, NULL
);
974 ok(hr
== DDERR_INVALIDRECT
, "Got unexpected hr %#x.\n", hr
);
975 SetRect(&src_rect
, 0, 0, 640, 480);
976 SetRect(&dst_rect
, 0, 480, 640, 0);
977 hr
= IDirectDrawSurface_Blt(ds2
, &dst_rect
, ds1
, &src_rect
, DDBLT_WAIT
, NULL
);
978 ok(hr
== DDERR_INVALIDRECT
, "Got unexpected hr %#x.\n", hr
);
979 /* Full, explicit. */
980 SetRect(&src_rect
, 0, 0, 640, 480);
981 SetRect(&dst_rect
, 0, 0, 640, 480);
982 hr
= IDirectDrawSurface_Blt(ds2
, &dst_rect
, ds1
, &src_rect
, DDBLT_WAIT
, NULL
);
983 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
984 /* Depth -> color blit: Succeeds on Win7 + Radeon HD 5700, fails on WinXP + Radeon X1600 */
986 /* Depth blit inside a BeginScene / EndScene pair */
987 hr
= IDirect3DDevice2_BeginScene(device
);
988 ok(SUCCEEDED(hr
), "Failed to start a scene, hr %#x.\n", hr
);
989 /* From the current depth stencil */
990 hr
= IDirectDrawSurface_Blt(ds2
, NULL
, ds1
, NULL
, DDBLT_WAIT
, NULL
);
991 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
992 /* To the current depth stencil */
993 hr
= IDirectDrawSurface_Blt(ds1
, NULL
, ds2
, NULL
, DDBLT_WAIT
, NULL
);
994 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
995 /* Between unbound surfaces */
996 hr
= IDirectDrawSurface_Blt(ds3
, NULL
, ds2
, NULL
, DDBLT_WAIT
, NULL
);
997 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
998 hr
= IDirect3DDevice2_EndScene(device
);
999 ok(SUCCEEDED(hr
), "Failed to end a scene, hr %#x.\n", hr
);
1001 /* Avoid changing the depth stencil, it doesn't work properly on Windows.
1002 * Instead use DDBLT_DEPTHFILL to clear the depth stencil. Unfortunately
1003 * drivers disagree on the meaning of dwFillDepth. Only 0 seems to produce
1004 * a reliable result(z = 0.0) */
1005 memset(&fx
, 0, sizeof(fx
));
1006 fx
.dwSize
= sizeof(fx
);
1007 U5(fx
).dwFillDepth
= 0;
1008 hr
= IDirectDrawSurface_Blt(ds2
, NULL
, NULL
, NULL
, DDBLT_DEPTHFILL
| DDBLT_WAIT
, &fx
);
1009 ok(SUCCEEDED(hr
), "Failed to clear the source z buffer, hr %#x.\n", hr
);
1011 /* This clears the Z buffer with 1.0 */
1012 hr
= IDirect3DViewport2_Clear(viewport
, 1, &d3drect
, D3DCLEAR_ZBUFFER
| D3DCLEAR_TARGET
);
1013 ok(SUCCEEDED(hr
), "Failed to clear the color and z buffers, hr %#x.\n", hr
);
1015 SetRect(&dst_rect
, 0, 0, 320, 240);
1016 hr
= IDirectDrawSurface_Blt(ds1
, &dst_rect
, ds2
, NULL
, DDBLT_WAIT
, NULL
);
1017 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
1018 IDirectDrawSurface_Release(ds3
);
1019 IDirectDrawSurface_Release(ds2
);
1020 IDirectDrawSurface_Release(ds1
);
1022 hr
= IDirect3DDevice2_BeginScene(device
);
1023 ok(SUCCEEDED(hr
), "Failed to start a scene, hr %#x.\n", hr
);
1024 hr
= IDirect3DDevice2_DrawPrimitive(device
, D3DPT_TRIANGLESTRIP
, D3DVT_LVERTEX
, quad1
, 4, 0);
1025 ok(SUCCEEDED(hr
), "Failed to draw, hr %#x.\n", hr
);
1026 hr
= IDirect3DDevice2_EndScene(device
);
1027 ok(SUCCEEDED(hr
), "Failed to end a scene, hr %#x.\n", hr
);
1029 hr
= IDirect3DDevice2_GetRenderTarget(device
, &rt
);
1030 ok(SUCCEEDED(hr
), "Failed to get render target, hr %#x.\n", hr
);
1031 for (i
= 0; i
< 4; ++i
)
1033 for (j
= 0; j
< 4; ++j
)
1035 unsigned int x
= 80 * ((2 * j
) + 1);
1036 unsigned int y
= 60 * ((2 * i
) + 1);
1037 color
= get_surface_color(rt
, x
, y
);
1039 todo_wine
ok(compare_color(color
, expected_colors
[i
][j
], 1),
1040 "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected_colors
[i
][j
], x
, y
, color
);
1042 ok(compare_color(color
, expected_colors
[i
][j
], 1),
1043 "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected_colors
[i
][j
], x
, y
, color
);
1046 IDirectDrawSurface_Release(rt
);
1048 destroy_viewport(device
, viewport
);
1049 destroy_material(background
);
1050 IDirect3DDevice2_Release(device
);
1051 IDirectDraw2_Release(ddraw
);
1052 DestroyWindow(window
);
1055 static void test_texture_load_ckey(void)
1057 IDirectDraw2
*ddraw
= NULL
;
1058 IDirectDrawSurface
*src
= NULL
;
1059 IDirectDrawSurface
*dst
= NULL
;
1060 IDirect3DTexture
*src_tex
= NULL
;
1061 IDirect3DTexture
*dst_tex
= NULL
;
1066 if (!(ddraw
= create_ddraw()))
1068 skip("Failed to create ddraw object, skipping test.\n");
1071 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, NULL
, DDSCL_NORMAL
);
1072 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#x.\n", hr
);
1074 memset(&ddsd
, 0, sizeof(ddsd
));
1075 ddsd
.dwSize
= sizeof(ddsd
);
1076 ddsd
.dwFlags
= DDSD_CAPS
| DDSD_HEIGHT
| DDSD_WIDTH
;
1077 ddsd
.dwHeight
= 128;
1079 ddsd
.ddsCaps
.dwCaps
= DDSCAPS_TEXTURE
| DDSCAPS_SYSTEMMEMORY
;
1080 hr
= IDirectDraw2_CreateSurface(ddraw
, &ddsd
, &src
, NULL
);
1081 ok(SUCCEEDED(hr
), "Failed to create source texture, hr %#x.\n", hr
);
1082 ddsd
.ddsCaps
.dwCaps
= DDSCAPS_TEXTURE
;
1083 hr
= IDirectDraw2_CreateSurface(ddraw
, &ddsd
, &dst
, NULL
);
1084 ok(SUCCEEDED(hr
), "Failed to create destination texture, hr %#x.\n", hr
);
1086 hr
= IDirectDrawSurface_QueryInterface(src
, &IID_IDirect3DTexture
, (void **)&src_tex
);
1087 ok(SUCCEEDED(hr
) || hr
== E_NOINTERFACE
, "Failed to get Direct3DTexture interface, hr %#x.\n", hr
);
1090 /* 64 bit ddraw does not support d3d */
1091 skip("Could not get Direct3DTexture interface, skipping texture::Load color keying tests.\n");
1094 hr
= IDirectDrawSurface_QueryInterface(dst
, &IID_IDirect3DTexture
, (void **)&dst_tex
);
1095 ok(SUCCEEDED(hr
), "Failed to get Direct3DTexture interface, hr %#x.\n", hr
);
1097 /* No surface has a color key */
1098 hr
= IDirect3DTexture_Load(dst_tex
, src_tex
);
1099 ok(SUCCEEDED(hr
) || broken(hr
== DDERR_INVALIDCAPS
), "Got unexpected hr %#x.\n", hr
);
1102 /* Testbot Windows NT VMs */
1103 skip("IDirect3DTexture::Load does not work, skipping color keying tests.\n");
1107 ckey
.dwColorSpaceLowValue
= ckey
.dwColorSpaceHighValue
= 0xdeadbeef;
1108 hr
= IDirectDrawSurface_GetColorKey(dst
, DDCKEY_SRCBLT
, &ckey
);
1109 ok(hr
== DDERR_NOCOLORKEY
, "Got unexpected hr %#x.\n", hr
);
1110 ok(ckey
.dwColorSpaceLowValue
== 0xdeadbeef, "dwColorSpaceLowValue is %#x.\n", ckey
.dwColorSpaceLowValue
);
1111 ok(ckey
.dwColorSpaceHighValue
== 0xdeadbeef, "dwColorSpaceHighValue is %#x.\n", ckey
.dwColorSpaceHighValue
);
1113 /* Source surface has a color key */
1114 ckey
.dwColorSpaceLowValue
= ckey
.dwColorSpaceHighValue
= 0x0000ff00;
1115 hr
= IDirectDrawSurface_SetColorKey(src
, DDCKEY_SRCBLT
, &ckey
);
1116 ok(SUCCEEDED(hr
), "Failed to set color key, hr %#x.\n", hr
);
1117 hr
= IDirect3DTexture_Load(dst_tex
, src_tex
);
1118 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
1119 hr
= IDirectDrawSurface_GetColorKey(dst
, DDCKEY_SRCBLT
, &ckey
);
1120 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
1121 ok(ckey
.dwColorSpaceLowValue
== 0x0000ff00, "dwColorSpaceLowValue is %#x.\n", ckey
.dwColorSpaceLowValue
);
1122 ok(ckey
.dwColorSpaceHighValue
== 0x0000ff00, "dwColorSpaceHighValue is %#x.\n", ckey
.dwColorSpaceHighValue
);
1124 /* Both surfaces have a color key: Dest ckey is overwritten */
1125 ckey
.dwColorSpaceLowValue
= ckey
.dwColorSpaceHighValue
= 0x000000ff;
1126 hr
= IDirectDrawSurface_SetColorKey(dst
, DDCKEY_SRCBLT
, &ckey
);
1127 ok(SUCCEEDED(hr
), "Failed to set color key, hr %#x.\n", hr
);
1128 hr
= IDirect3DTexture_Load(dst_tex
, src_tex
);
1129 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
1130 hr
= IDirectDrawSurface_GetColorKey(dst
, DDCKEY_SRCBLT
, &ckey
);
1131 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
1132 ok(ckey
.dwColorSpaceLowValue
== 0x0000ff00, "dwColorSpaceLowValue is %#x.\n", ckey
.dwColorSpaceLowValue
);
1133 ok(ckey
.dwColorSpaceHighValue
== 0x0000ff00, "dwColorSpaceHighValue is %#x.\n", ckey
.dwColorSpaceHighValue
);
1135 /* Only the destination has a color key: It is not deleted */
1136 hr
= IDirectDrawSurface_SetColorKey(src
, DDCKEY_SRCBLT
, NULL
);
1137 ok(SUCCEEDED(hr
), "Failed to set color key, hr %#x.\n", hr
);
1138 hr
= IDirectDrawSurface_GetColorKey(src
, DDCKEY_SRCBLT
, &ckey
);
1139 ok(hr
== DDERR_NOCOLORKEY
, "Got unexpected hr %#x.\n", hr
);
1140 hr
= IDirect3DTexture_Load(dst_tex
, src_tex
);
1141 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
1142 hr
= IDirectDrawSurface_GetColorKey(dst
, DDCKEY_SRCBLT
, &ckey
);
1143 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
1144 ok(ckey
.dwColorSpaceLowValue
== 0x0000ff00, "dwColorSpaceLowValue is %#x.\n", ckey
.dwColorSpaceLowValue
);
1145 ok(ckey
.dwColorSpaceHighValue
== 0x0000ff00, "dwColorSpaceHighValue is %#x.\n", ckey
.dwColorSpaceHighValue
);
1148 if (dst_tex
) IDirect3DTexture_Release(dst_tex
);
1149 if (src_tex
) IDirect3DTexture_Release(src_tex
);
1150 if (dst
) IDirectDrawSurface_Release(dst
);
1151 if (src
) IDirectDrawSurface_Release(src
);
1152 if (ddraw
) IDirectDraw2_Release(ddraw
);
1155 static ULONG
get_refcount(IUnknown
*test_iface
)
1157 IUnknown_AddRef(test_iface
);
1158 return IUnknown_Release(test_iface
);
1161 static void test_viewport_interfaces(void)
1163 IDirectDraw2
*ddraw
;
1166 ULONG ref
, old_d3d_ref
;
1167 IDirect3DViewport
*viewport
;
1168 IDirect3DViewport2
*viewport2
;
1169 IDirect3DViewport3
*viewport3
;
1170 IDirectDrawGammaControl
*gamma
;
1173 if (!(ddraw
= create_ddraw()))
1175 skip("Failed to create ddraw object, skipping test.\n");
1179 hr
= IDirectDraw2_QueryInterface(ddraw
, &IID_IDirect3D2
, (void **)&d3d
);
1180 ok(SUCCEEDED(hr
) || hr
== E_NOINTERFACE
, "Failed to get d3d interface, hr %#x.\n", hr
);
1183 skip("Direct3D not available, skipping tests\n");
1184 IDirectDraw2_Release(ddraw
);
1187 old_d3d_ref
= get_refcount((IUnknown
*)d3d
);
1189 hr
= IDirect3D2_CreateViewport(d3d
, &viewport2
, NULL
);
1190 ok(SUCCEEDED(hr
), "Failed to create viewport, hr %#x.\n", hr
);
1191 ref
= get_refcount((IUnknown
*)viewport2
);
1192 ok(ref
== 1, "Initial IDirect3DViewport2 refcount is %u\n", ref
);
1193 ref
= get_refcount((IUnknown
*)d3d
);
1194 ok(ref
== old_d3d_ref
, "IDirect3D2 refcount is %u\n", ref
);
1196 gamma
= (IDirectDrawGammaControl
*)0xdeadbeef;
1197 hr
= IDirect3DViewport2_QueryInterface(viewport2
, &IID_IDirectDrawGammaControl
, (void **)&gamma
);
1198 ok(hr
== E_NOINTERFACE
, "Got unexpected hr %#x.\n", hr
);
1199 ok(gamma
== NULL
, "Interface not set to NULL by failed QI call: %p\n", gamma
);
1200 if (SUCCEEDED(hr
)) IDirectDrawGammaControl_Release(gamma
);
1201 /* NULL iid: Segfaults */
1203 hr
= IDirect3DViewport2_QueryInterface(viewport2
, &IID_IDirect3DViewport
, (void **)&viewport
);
1204 ok(SUCCEEDED(hr
), "Failed to QI IDirect3DViewport, hr %#x.\n", hr
);
1207 ref
= get_refcount((IUnknown
*)viewport
);
1208 ok(ref
== 2, "IDirect3DViewport refcount is %u\n", ref
);
1209 ref
= get_refcount((IUnknown
*)viewport2
);
1210 ok(ref
== 2, "IDirect3DViewport2 refcount is %u\n", ref
);
1211 IDirect3DViewport_Release(viewport
);
1215 hr
= IDirect3DViewport2_QueryInterface(viewport2
, &IID_IDirect3DViewport3
, (void **)&viewport3
);
1216 ok(SUCCEEDED(hr
) || hr
== E_NOINTERFACE
, "Failed to QI IDirect3DViewport3, hr %#x.\n", hr
);
1219 ref
= get_refcount((IUnknown
*)viewport2
);
1220 ok(ref
== 2, "IDirect3DViewport2 refcount is %u\n", ref
);
1221 ref
= get_refcount((IUnknown
*)viewport3
);
1222 ok(ref
== 2, "IDirect3DViewport3 refcount is %u\n", ref
);
1223 IDirect3DViewport3_Release(viewport3
);
1226 hr
= IDirect3DViewport2_QueryInterface(viewport2
, &IID_IUnknown
, (void **)&unknown
);
1227 ok(SUCCEEDED(hr
), "Failed to QI IUnknown, hr %#x.\n", hr
);
1230 ref
= get_refcount((IUnknown
*)viewport2
);
1231 ok(ref
== 2, "IDirect3DViewport2 refcount is %u\n", ref
);
1232 ref
= get_refcount(unknown
);
1233 ok(ref
== 2, "IUnknown refcount is %u\n", ref
);
1234 IUnknown_Release(unknown
);
1237 IDirect3DViewport2_Release(viewport2
);
1238 IDirect3D2_Release(d3d
);
1239 IDirectDraw2_Release(ddraw
);
1242 static void test_zenable(void)
1244 static D3DRECT clear_rect
= {{0}, {0}, {640}, {480}};
1245 static D3DTLVERTEX tquad
[] =
1247 {{ 0.0f
}, {480.0f
}, {-0.5f
}, {1.0f
}, {0xff00ff00}, {0x00000000}, {0.0f
}, {0.0f
}},
1248 {{ 0.0f
}, { 0.0f
}, {-0.5f
}, {1.0f
}, {0xff00ff00}, {0x00000000}, {0.0f
}, {0.0f
}},
1249 {{640.0f
}, {480.0f
}, { 1.5f
}, {1.0f
}, {0xff00ff00}, {0x00000000}, {0.0f
}, {0.0f
}},
1250 {{640.0f
}, { 0.0f
}, { 1.5f
}, {1.0f
}, {0xff00ff00}, {0x00000000}, {0.0f
}, {0.0f
}},
1252 D3DMATERIALHANDLE background_handle
;
1253 IDirect3DMaterial2
*background
;
1254 IDirect3DViewport2
*viewport
;
1255 IDirect3DDevice2
*device
;
1256 IDirectDrawSurface
*rt
;
1257 IDirectDraw2
*ddraw
;
1264 window
= CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW
,
1265 0, 0, 640, 480, 0, 0, 0, 0);
1266 if (!(ddraw
= create_ddraw()))
1268 skip("Failed to create ddraw object, skipping test.\n");
1269 DestroyWindow(window
);
1272 if (!(device
= create_device(ddraw
, window
, DDSCL_NORMAL
)))
1274 skip("Failed to create D3D device, skipping test.\n");
1275 IDirectDraw2_Release(ddraw
);
1276 DestroyWindow(window
);
1280 background
= create_diffuse_material(device
, 1.0f
, 0.0f
, 0.0f
, 1.0f
);
1281 viewport
= create_viewport(device
, 0, 0, 640, 480);
1282 hr
= IDirect3DDevice2_SetCurrentViewport(device
, viewport
);
1283 ok(SUCCEEDED(hr
), "Failed to set current viewport, hr %#x.\n", hr
);
1285 hr
= IDirect3DMaterial2_GetHandle(background
, device
, &background_handle
);
1286 ok(SUCCEEDED(hr
), "Failed to get material handle, hr %#x.\n", hr
);
1287 hr
= IDirect3DViewport2_SetBackground(viewport
, background_handle
);
1288 ok(SUCCEEDED(hr
), "Failed to set viewport background, hr %#x.\n", hr
);
1290 hr
= IDirect3DDevice2_SetRenderState(device
, D3DRENDERSTATE_ZENABLE
, D3DZB_FALSE
);
1291 ok(SUCCEEDED(hr
), "Failed to disable z-buffering, hr %#x.\n", hr
);
1293 hr
= IDirect3DViewport2_Clear(viewport
, 1, &clear_rect
, D3DCLEAR_TARGET
);
1294 ok(SUCCEEDED(hr
), "Failed to clear viewport, hr %#x.\n", hr
);
1295 hr
= IDirect3DDevice2_BeginScene(device
);
1296 ok(SUCCEEDED(hr
), "Failed to begin scene, hr %#x.\n", hr
);
1297 hr
= IDirect3DDevice2_DrawPrimitive(device
, D3DPT_TRIANGLESTRIP
, D3DVT_TLVERTEX
, tquad
, 4, 0);
1298 ok(SUCCEEDED(hr
), "Failed to draw, hr %#x.\n", hr
);
1299 hr
= IDirect3DDevice2_EndScene(device
);
1300 ok(SUCCEEDED(hr
), "Failed to end scene, hr %#x.\n", hr
);
1302 hr
= IDirect3DDevice2_GetRenderTarget(device
, &rt
);
1303 ok(SUCCEEDED(hr
), "Failed to get render target, hr %#x.\n", hr
);
1304 for (i
= 0; i
< 4; ++i
)
1306 for (j
= 0; j
< 4; ++j
)
1308 x
= 80 * ((2 * j
) + 1);
1309 y
= 60 * ((2 * i
) + 1);
1310 color
= get_surface_color(rt
, x
, y
);
1311 ok(compare_color(color
, 0x0000ff00, 1),
1312 "Expected color 0x0000ff00 at %u, %u, got 0x%08x.\n", x
, y
, color
);
1315 IDirectDrawSurface_Release(rt
);
1317 destroy_viewport(device
, viewport
);
1318 destroy_material(background
);
1319 IDirect3DDevice2_Release(device
);
1320 IDirectDraw2_Release(ddraw
);
1321 DestroyWindow(window
);
1324 static void test_ck_rgba(void)
1326 static D3DRECT clear_rect
= {{0}, {0}, {640}, {480}};
1327 static D3DTLVERTEX tquad
[] =
1329 {{ 0.0f
}, {480.0f
}, {0.25f
}, {1.0f
}, {0xffffffff}, {0x00000000}, {0.0f
}, {0.0f
}},
1330 {{ 0.0f
}, { 0.0f
}, {0.25f
}, {1.0f
}, {0xffffffff}, {0x00000000}, {0.0f
}, {1.0f
}},
1331 {{640.0f
}, {480.0f
}, {0.25f
}, {1.0f
}, {0xffffffff}, {0x00000000}, {1.0f
}, {0.0f
}},
1332 {{640.0f
}, { 0.0f
}, {0.25f
}, {1.0f
}, {0xffffffff}, {0x00000000}, {1.0f
}, {1.0f
}},
1333 {{ 0.0f
}, {480.0f
}, {0.75f
}, {1.0f
}, {0xffffffff}, {0x00000000}, {0.0f
}, {0.0f
}},
1334 {{ 0.0f
}, { 0.0f
}, {0.75f
}, {1.0f
}, {0xffffffff}, {0x00000000}, {0.0f
}, {1.0f
}},
1335 {{640.0f
}, {480.0f
}, {0.75f
}, {1.0f
}, {0xffffffff}, {0x00000000}, {1.0f
}, {0.0f
}},
1336 {{640.0f
}, { 0.0f
}, {0.75f
}, {1.0f
}, {0xffffffff}, {0x00000000}, {1.0f
}, {1.0f
}},
1340 D3DCOLOR fill_color
;
1348 {0xff00ff00, TRUE
, TRUE
, 0x00ff0000, 0x000000ff},
1349 {0xff00ff00, TRUE
, FALSE
, 0x00ff0000, 0x000000ff},
1350 {0xff00ff00, FALSE
, TRUE
, 0x0000ff00, 0x0000ff00},
1351 {0xff00ff00, FALSE
, FALSE
, 0x0000ff00, 0x0000ff00},
1352 {0x7f00ff00, TRUE
, TRUE
, 0x00807f00, 0x00807f00},
1353 {0x7f00ff00, TRUE
, FALSE
, 0x0000ff00, 0x0000ff00},
1354 {0x7f00ff00, FALSE
, TRUE
, 0x00807f00, 0x00807f00},
1355 {0x7f00ff00, FALSE
, FALSE
, 0x0000ff00, 0x0000ff00},
1358 D3DMATERIALHANDLE background_handle
;
1359 D3DTEXTUREHANDLE texture_handle
;
1360 IDirect3DMaterial2
*background
;
1361 IDirectDrawSurface
*surface
;
1362 IDirect3DViewport2
*viewport
;
1363 IDirect3DTexture2
*texture
;
1364 DDSURFACEDESC surface_desc
;
1365 IDirect3DDevice2
*device
;
1366 IDirectDrawSurface
*rt
;
1367 IDirectDraw2
*ddraw
;
1374 window
= CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW
,
1375 0, 0, 640, 480, 0, 0, 0, 0);
1376 if (!(ddraw
= create_ddraw()))
1378 skip("Failed to create ddraw object, skipping test.\n");
1379 DestroyWindow(window
);
1382 if (!(device
= create_device(ddraw
, window
, DDSCL_NORMAL
)))
1384 skip("Failed to create D3D device, skipping test.\n");
1385 DestroyWindow(window
);
1389 background
= create_diffuse_material(device
, 1.0f
, 0.0f
, 0.0f
, 1.0f
);
1390 viewport
= create_viewport(device
, 0, 0, 640, 480);
1391 hr
= IDirect3DDevice2_SetCurrentViewport(device
, viewport
);
1392 ok(SUCCEEDED(hr
), "Failed to set current viewport, hr %#x.\n", hr
);
1394 hr
= IDirect3DMaterial2_GetHandle(background
, device
, &background_handle
);
1395 ok(SUCCEEDED(hr
), "Failed to get material handle, hr %#x.\n", hr
);
1396 hr
= IDirect3DViewport2_SetBackground(viewport
, background_handle
);
1397 ok(SUCCEEDED(hr
), "Failed to set viewport background, hr %#x.\n", hr
);
1399 memset(&surface_desc
, 0, sizeof(surface_desc
));
1400 surface_desc
.dwSize
= sizeof(surface_desc
);
1401 surface_desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PIXELFORMAT
| DDSD_CKSRCBLT
;
1402 surface_desc
.ddsCaps
.dwCaps
= DDSCAPS_TEXTURE
;
1403 surface_desc
.dwWidth
= 256;
1404 surface_desc
.dwHeight
= 256;
1405 surface_desc
.ddpfPixelFormat
.dwSize
= sizeof(surface_desc
.ddpfPixelFormat
);
1406 surface_desc
.ddpfPixelFormat
.dwFlags
= DDPF_RGB
| DDPF_ALPHAPIXELS
;
1407 U1(surface_desc
.ddpfPixelFormat
).dwRGBBitCount
= 32;
1408 U2(surface_desc
.ddpfPixelFormat
).dwRBitMask
= 0x00ff0000;
1409 U3(surface_desc
.ddpfPixelFormat
).dwGBitMask
= 0x0000ff00;
1410 U4(surface_desc
.ddpfPixelFormat
).dwBBitMask
= 0x000000ff;
1411 U5(surface_desc
.ddpfPixelFormat
).dwRGBAlphaBitMask
= 0xff000000;
1412 surface_desc
.ddckCKSrcBlt
.dwColorSpaceLowValue
= 0xff00ff00;
1413 surface_desc
.ddckCKSrcBlt
.dwColorSpaceHighValue
= 0xff00ff00;
1414 hr
= IDirectDraw2_CreateSurface(ddraw
, &surface_desc
, &surface
, NULL
);
1415 ok(SUCCEEDED(hr
), "Failed to create destination surface, hr %#x.\n", hr
);
1416 hr
= IDirectDrawSurface_QueryInterface(surface
, &IID_IDirect3DTexture2
, (void **)&texture
);
1417 ok(SUCCEEDED(hr
), "Failed to get texture interface, hr %#x.\n", hr
);
1418 hr
= IDirect3DTexture2_GetHandle(texture
, device
, &texture_handle
);
1419 ok(SUCCEEDED(hr
), "Failed to get texture handle, hr %#x.\n", hr
);
1420 IDirect3DTexture2_Release(texture
);
1422 hr
= IDirect3DDevice2_SetRenderState(device
, D3DRENDERSTATE_TEXTUREHANDLE
, texture_handle
);
1423 ok(SUCCEEDED(hr
), "Failed to set texture, hr %#x.\n", hr
);
1424 hr
= IDirect3DDevice2_SetRenderState(device
, D3DRENDERSTATE_SRCBLEND
, D3DBLEND_SRCALPHA
);
1425 ok(SUCCEEDED(hr
), "Failed to enable alpha blending, hr %#x.\n", hr
);
1426 hr
= IDirect3DDevice2_SetRenderState(device
, D3DRENDERSTATE_DESTBLEND
, D3DBLEND_INVSRCALPHA
);
1427 ok(SUCCEEDED(hr
), "Failed to enable alpha blending, hr %#x.\n", hr
);
1429 hr
= IDirect3DDevice2_GetRenderTarget(device
, &rt
);
1430 ok(SUCCEEDED(hr
), "Failed to get render target, hr %#x.\n", hr
);
1432 for (i
= 0; i
< sizeof(tests
) / sizeof(*tests
); ++i
)
1434 hr
= IDirect3DDevice2_SetRenderState(device
, D3DRENDERSTATE_COLORKEYENABLE
, tests
[i
].color_key
);
1435 ok(SUCCEEDED(hr
), "Failed to enable color keying, hr %#x.\n", hr
);
1436 hr
= IDirect3DDevice2_SetRenderState(device
, D3DRENDERSTATE_ALPHABLENDENABLE
, tests
[i
].blend
);
1437 ok(SUCCEEDED(hr
), "Failed to enable alpha blending, hr %#x.\n", hr
);
1439 memset(&fx
, 0, sizeof(fx
));
1440 fx
.dwSize
= sizeof(fx
);
1441 U5(fx
).dwFillColor
= tests
[i
].fill_color
;
1442 hr
= IDirectDrawSurface_Blt(surface
, NULL
, NULL
, NULL
, DDBLT_COLORFILL
| DDBLT_WAIT
, &fx
);
1443 ok(SUCCEEDED(hr
), "Failed to fill texture, hr %#x.\n", hr
);
1445 hr
= IDirect3DViewport2_Clear(viewport
, 1, &clear_rect
, D3DCLEAR_TARGET
| D3DCLEAR_ZBUFFER
);
1446 ok(SUCCEEDED(hr
), "Failed to clear viewport, hr %#x.\n", hr
);
1447 hr
= IDirect3DDevice2_BeginScene(device
);
1448 ok(SUCCEEDED(hr
), "Failed to begin scene, hr %#x.\n", hr
);
1449 hr
= IDirect3DDevice2_DrawPrimitive(device
, D3DPT_TRIANGLESTRIP
, D3DVT_TLVERTEX
, &tquad
[0], 4, 0);
1450 ok(SUCCEEDED(hr
), "Failed to draw, hr %#x.\n", hr
);
1451 hr
= IDirect3DDevice2_EndScene(device
);
1452 ok(SUCCEEDED(hr
), "Failed to end scene, hr %#x.\n", hr
);
1454 color
= get_surface_color(rt
, 320, 240);
1456 todo_wine
ok(compare_color(color
, tests
[i
].result1
, 1), "Expected color 0x%08x for test %u, got 0x%08x.\n",
1457 tests
[i
].result1
, i
, color
);
1459 ok(compare_color(color
, tests
[i
].result1
, 1), "Expected color 0x%08x for test %u, got 0x%08x.\n",
1460 tests
[i
].result1
, i
, color
);
1462 U5(fx
).dwFillColor
= 0xff0000ff;
1463 hr
= IDirectDrawSurface_Blt(surface
, NULL
, NULL
, NULL
, DDBLT_COLORFILL
| DDBLT_WAIT
, &fx
);
1464 ok(SUCCEEDED(hr
), "Failed to fill texture, hr %#x.\n", hr
);
1466 hr
= IDirect3DDevice2_BeginScene(device
);
1467 ok(SUCCEEDED(hr
), "Failed to begin scene, hr %#x.\n", hr
);
1468 hr
= IDirect3DDevice2_DrawPrimitive(device
, D3DPT_TRIANGLESTRIP
, D3DVT_TLVERTEX
, &tquad
[4], 4, 0);
1469 ok(SUCCEEDED(hr
), "Failed to draw, hr %#x.\n", hr
);
1470 hr
= IDirect3DDevice2_EndScene(device
);
1471 ok(SUCCEEDED(hr
), "Failed to end scene, hr %#x.\n", hr
);
1473 /* This tests that fragments that are masked out by the color key are
1474 * discarded, instead of just fully transparent. */
1475 color
= get_surface_color(rt
, 320, 240);
1477 todo_wine
ok(compare_color(color
, tests
[i
].result2
, 1), "Expected color 0x%08x for test %u, got 0x%08x.\n",
1478 tests
[i
].result2
, i
, color
);
1480 ok(compare_color(color
, tests
[i
].result2
, 1), "Expected color 0x%08x for test %u, got 0x%08x.\n",
1481 tests
[i
].result2
, i
, color
);
1484 IDirectDrawSurface_Release(rt
);
1485 hr
= IDirect3DDevice2_SetRenderState(device
, D3DRENDERSTATE_TEXTUREHANDLE
, 0);
1486 ok(SUCCEEDED(hr
), "Failed to unset texture, hr %#x.\n", hr
);
1487 IDirectDrawSurface_Release(surface
);
1488 destroy_viewport(device
, viewport
);
1489 destroy_material(background
);
1490 IDirect3DDevice2_Release(device
);
1491 IDirectDraw2_Release(ddraw
);
1492 DestroyWindow(window
);
1498 REFIID refcount_iid
;
1502 static void test_qi(const char *test_name
, IUnknown
*base_iface
,
1503 REFIID refcount_iid
, const struct qi_test
*tests
, UINT entry_count
)
1505 ULONG refcount
, expected_refcount
;
1506 IUnknown
*iface1
, *iface2
;
1510 for (i
= 0; i
< entry_count
; ++i
)
1512 hr
= IUnknown_QueryInterface(base_iface
, tests
[i
].iid
, (void **)&iface1
);
1513 ok(hr
== tests
[i
].hr
, "Got hr %#x for test \"%s\" %u.\n", hr
, test_name
, i
);
1516 for (j
= 0; j
< entry_count
; ++j
)
1518 hr
= IUnknown_QueryInterface(iface1
, tests
[j
].iid
, (void **)&iface2
);
1519 ok(hr
== tests
[j
].hr
, "Got hr %#x for test \"%s\" %u, %u.\n", hr
, test_name
, i
, j
);
1522 expected_refcount
= 0;
1523 if (IsEqualGUID(refcount_iid
, tests
[j
].refcount_iid
))
1524 ++expected_refcount
;
1525 if (IsEqualGUID(tests
[i
].refcount_iid
, tests
[j
].refcount_iid
))
1526 ++expected_refcount
;
1527 refcount
= IUnknown_Release(iface2
);
1528 ok(refcount
== expected_refcount
, "Got refcount %u for test \"%s\" %u, %u, expected %u.\n",
1529 refcount
, test_name
, i
, j
, expected_refcount
);
1533 expected_refcount
= 0;
1534 if (IsEqualGUID(refcount_iid
, tests
[i
].refcount_iid
))
1535 ++expected_refcount
;
1536 refcount
= IUnknown_Release(iface1
);
1537 ok(refcount
== expected_refcount
, "Got refcount %u for test \"%s\" %u, expected %u.\n",
1538 refcount
, test_name
, i
, expected_refcount
);
1543 static void test_surface_qi(void)
1545 static const struct qi_test tests
[] =
1547 {&IID_IDirect3DTexture2
, &IID_IDirectDrawSurface
, S_OK
},
1548 {&IID_IDirect3DTexture
, &IID_IDirectDrawSurface
, S_OK
},
1549 {&IID_IDirectDrawGammaControl
, &IID_IDirectDrawGammaControl
, S_OK
},
1550 {&IID_IDirectDrawColorControl
, NULL
, E_NOINTERFACE
},
1551 {&IID_IDirectDrawSurface7
, &IID_IDirectDrawSurface7
, S_OK
},
1552 {&IID_IDirectDrawSurface4
, &IID_IDirectDrawSurface4
, S_OK
},
1553 {&IID_IDirectDrawSurface3
, &IID_IDirectDrawSurface3
, S_OK
},
1554 {&IID_IDirectDrawSurface2
, &IID_IDirectDrawSurface2
, S_OK
},
1555 {&IID_IDirectDrawSurface
, &IID_IDirectDrawSurface
, S_OK
},
1556 {&IID_IDirect3DDevice7
, NULL
, E_INVALIDARG
},
1557 {&IID_IDirect3DDevice3
, NULL
, E_INVALIDARG
},
1558 {&IID_IDirect3DDevice2
, NULL
, E_INVALIDARG
},
1559 {&IID_IDirect3DDevice
, NULL
, E_INVALIDARG
},
1560 {&IID_IDirect3D7
, NULL
, E_INVALIDARG
},
1561 {&IID_IDirect3D3
, NULL
, E_INVALIDARG
},
1562 {&IID_IDirect3D2
, NULL
, E_INVALIDARG
},
1563 {&IID_IDirect3D
, NULL
, E_INVALIDARG
},
1564 {&IID_IDirectDraw7
, NULL
, E_INVALIDARG
},
1565 {&IID_IDirectDraw4
, NULL
, E_INVALIDARG
},
1566 {&IID_IDirectDraw3
, NULL
, E_INVALIDARG
},
1567 {&IID_IDirectDraw2
, NULL
, E_INVALIDARG
},
1568 {&IID_IDirectDraw
, NULL
, E_INVALIDARG
},
1569 {&IID_IDirect3DLight
, NULL
, E_INVALIDARG
},
1570 {&IID_IDirect3DMaterial
, NULL
, E_INVALIDARG
},
1571 {&IID_IDirect3DMaterial2
, NULL
, E_INVALIDARG
},
1572 {&IID_IDirect3DMaterial3
, NULL
, E_INVALIDARG
},
1573 {&IID_IDirect3DExecuteBuffer
, NULL
, E_INVALIDARG
},
1574 {&IID_IDirect3DViewport
, NULL
, E_INVALIDARG
},
1575 {&IID_IDirect3DViewport2
, NULL
, E_INVALIDARG
},
1576 {&IID_IDirect3DViewport3
, NULL
, E_INVALIDARG
},
1577 {&IID_IDirect3DVertexBuffer
, NULL
, E_INVALIDARG
},
1578 {&IID_IDirect3DVertexBuffer7
, NULL
, E_INVALIDARG
},
1579 {&IID_IDirectDrawPalette
, NULL
, E_INVALIDARG
},
1580 {&IID_IDirectDrawClipper
, NULL
, E_INVALIDARG
},
1581 {&IID_IUnknown
, &IID_IDirectDrawSurface
, S_OK
},
1584 IDirectDrawSurface
*surface
;
1585 DDSURFACEDESC surface_desc
;
1586 IDirect3DDevice2
*device
;
1587 IDirectDraw2
*ddraw
;
1591 if (!GetProcAddress(GetModuleHandleA("ddraw.dll"), "DirectDrawCreateEx"))
1593 win_skip("DirectDrawCreateEx not available, skipping test.\n");
1597 window
= CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW
,
1598 0, 0, 640, 480, 0, 0, 0, 0);
1599 if (!(ddraw
= create_ddraw()))
1601 skip("Failed to create a ddraw object, skipping test.\n");
1604 /* Try to create a D3D device to see if the ddraw implementation supports
1605 * D3D. 64-bit ddraw in particular doesn't seem to support D3D, and
1606 * doesn't support e.g. the IDirect3DTexture interfaces. */
1607 if (!(device
= create_device(ddraw
, window
, DDSCL_NORMAL
)))
1609 skip("Failed to create D3D device, skipping test.\n");
1610 DestroyWindow(window
);
1613 IDirect3DDevice_Release(device
);
1615 memset(&surface_desc
, 0, sizeof(surface_desc
));
1616 surface_desc
.dwSize
= sizeof(surface_desc
);
1617 surface_desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
1618 surface_desc
.ddsCaps
.dwCaps
= DDSCAPS_TEXTURE
;
1619 surface_desc
.dwWidth
= 512;
1620 surface_desc
.dwHeight
= 512;
1621 hr
= IDirectDraw2_CreateSurface(ddraw
, &surface_desc
, &surface
, NULL
);
1622 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
1624 test_qi("surface_qi", (IUnknown
*)surface
, &IID_IDirectDrawSurface
, tests
, sizeof(tests
) / sizeof(*tests
));
1626 IDirectDrawSurface_Release(surface
);
1627 IDirectDraw2_Release(ddraw
);
1628 DestroyWindow(window
);
1631 static void test_device_qi(void)
1633 static const struct qi_test tests
[] =
1635 {&IID_IDirect3DTexture2
, NULL
, E_NOINTERFACE
},
1636 {&IID_IDirect3DTexture
, NULL
, E_NOINTERFACE
},
1637 {&IID_IDirectDrawGammaControl
, NULL
, E_NOINTERFACE
},
1638 {&IID_IDirectDrawColorControl
, NULL
, E_NOINTERFACE
},
1639 {&IID_IDirectDrawSurface7
, NULL
, E_NOINTERFACE
},
1640 {&IID_IDirectDrawSurface4
, NULL
, E_NOINTERFACE
},
1641 {&IID_IDirectDrawSurface3
, NULL
, E_NOINTERFACE
},
1642 {&IID_IDirectDrawSurface2
, NULL
, E_NOINTERFACE
},
1643 {&IID_IDirectDrawSurface
, NULL
, E_NOINTERFACE
},
1644 {&IID_IDirect3DDevice7
, NULL
, E_NOINTERFACE
},
1645 {&IID_IDirect3DDevice3
, NULL
, E_NOINTERFACE
},
1646 {&IID_IDirect3DDevice2
, &IID_IDirect3DDevice2
, S_OK
},
1647 {&IID_IDirect3DDevice
, &IID_IDirect3DDevice2
, S_OK
},
1648 {&IID_IDirect3DRampDevice
, NULL
, E_NOINTERFACE
},
1649 {&IID_IDirect3DRGBDevice
, NULL
, E_NOINTERFACE
},
1650 {&IID_IDirect3DHALDevice
, NULL
, E_NOINTERFACE
},
1651 {&IID_IDirect3DMMXDevice
, NULL
, E_NOINTERFACE
},
1652 {&IID_IDirect3DRefDevice
, NULL
, E_NOINTERFACE
},
1653 {&IID_IDirect3DTnLHalDevice
, NULL
, E_NOINTERFACE
},
1654 {&IID_IDirect3DNullDevice
, NULL
, E_NOINTERFACE
},
1655 {&IID_IDirect3D7
, NULL
, E_NOINTERFACE
},
1656 {&IID_IDirect3D3
, NULL
, E_NOINTERFACE
},
1657 {&IID_IDirect3D2
, NULL
, E_NOINTERFACE
},
1658 {&IID_IDirect3D
, NULL
, E_NOINTERFACE
},
1659 {&IID_IDirectDraw7
, NULL
, E_NOINTERFACE
},
1660 {&IID_IDirectDraw4
, NULL
, E_NOINTERFACE
},
1661 {&IID_IDirectDraw3
, NULL
, E_NOINTERFACE
},
1662 {&IID_IDirectDraw2
, NULL
, E_NOINTERFACE
},
1663 {&IID_IDirectDraw
, NULL
, E_NOINTERFACE
},
1664 {&IID_IDirect3DLight
, NULL
, E_NOINTERFACE
},
1665 {&IID_IDirect3DMaterial
, NULL
, E_NOINTERFACE
},
1666 {&IID_IDirect3DMaterial2
, NULL
, E_NOINTERFACE
},
1667 {&IID_IDirect3DMaterial3
, NULL
, E_NOINTERFACE
},
1668 {&IID_IDirect3DExecuteBuffer
, NULL
, E_NOINTERFACE
},
1669 {&IID_IDirect3DViewport
, NULL
, E_NOINTERFACE
},
1670 {&IID_IDirect3DViewport2
, NULL
, E_NOINTERFACE
},
1671 {&IID_IDirect3DViewport3
, NULL
, E_NOINTERFACE
},
1672 {&IID_IDirect3DVertexBuffer
, NULL
, E_NOINTERFACE
},
1673 {&IID_IDirect3DVertexBuffer7
, NULL
, E_NOINTERFACE
},
1674 {&IID_IDirectDrawPalette
, NULL
, E_NOINTERFACE
},
1675 {&IID_IDirectDrawClipper
, NULL
, E_NOINTERFACE
},
1676 {&IID_IUnknown
, &IID_IDirect3DDevice2
, S_OK
},
1679 IDirect3DDevice2
*device
;
1680 IDirectDraw2
*ddraw
;
1683 window
= CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW
,
1684 0, 0, 640, 480, 0, 0, 0, 0);
1685 if (!(ddraw
= create_ddraw()))
1687 skip("Failed to create ddraw object, skipping test.\n");
1688 DestroyWindow(window
);
1691 if (!(device
= create_device(ddraw
, window
, DDSCL_NORMAL
)))
1693 skip("Failed to create D3D device, skipping test.\n");
1694 DestroyWindow(window
);
1698 test_qi("device_qi", (IUnknown
*)device
, &IID_IDirect3DDevice2
, tests
, sizeof(tests
) / sizeof(*tests
));
1700 IDirect3DDevice2_Release(device
);
1701 IDirectDraw2_Release(ddraw
);
1702 DestroyWindow(window
);
1707 test_coop_level_create_device_window();
1709 test_coop_level_d3d_state();
1710 test_surface_interface_mismatch();
1711 test_coop_level_threaded();
1713 test_texture_load_ckey();
1714 test_viewport_interfaces();