2 * Copyright (C) 2007 Stefan Dösinger(for CodeWeavers)
3 * Copyright (C) 2008 Alexander Dorofeyev
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 /* See comment in dlls/d3d9/tests/visual.c for general guidelines */
22 #include "wine/test.h"
37 static IDirectDraw7
*DirectDraw
;
38 static IDirectDrawSurface7
*Surface
;
39 static IDirectDrawSurface7
*depth_buffer
;
40 static IDirect3D7
*Direct3D
;
41 static IDirect3DDevice7
*Direct3DDevice
;
43 static BOOL refdevice
= FALSE
;
45 static HRESULT (WINAPI
*pDirectDrawCreateEx
)(GUID
*driver_guid
,
46 void **ddraw
, REFIID interface_iid
, IUnknown
*outer
);
48 static BOOL
color_match(D3DCOLOR c1
, D3DCOLOR c2
, BYTE max_diff
)
50 if (abs((c1
& 0xff) - (c2
& 0xff)) > max_diff
) return FALSE
;
52 if (abs((c1
& 0xff) - (c2
& 0xff)) > max_diff
) return FALSE
;
54 if (abs((c1
& 0xff) - (c2
& 0xff)) > max_diff
) return FALSE
;
56 if (abs((c1
& 0xff) - (c2
& 0xff)) > max_diff
) return FALSE
;
60 static HRESULT WINAPI
enum_z_fmt(DDPIXELFORMAT
*fmt
, void *ctx
)
62 DDPIXELFORMAT
*zfmt
= ctx
;
64 if(U1(*fmt
).dwZBufferBitDepth
> U1(*zfmt
).dwZBufferBitDepth
)
71 static HRESULT WINAPI
enum_devtype_cb(char *desc_str
, char *name
, D3DDEVICEDESC7
*desc
, void *ctx
)
74 if (IsEqualGUID(&desc
->deviceGUID
, &IID_IDirect3DTnLHalDevice
))
77 return DDENUMRET_CANCEL
;
82 static BOOL
createObjects(void)
85 HMODULE hmod
= GetModuleHandleA("ddraw.dll");
90 const GUID
*devtype
= &IID_IDirect3DHALDevice
;
92 if(!hmod
) return FALSE
;
93 pDirectDrawCreateEx
= (void*)GetProcAddress(hmod
, "DirectDrawCreateEx");
94 if(!pDirectDrawCreateEx
) return FALSE
;
96 hr
= pDirectDrawCreateEx(NULL
, (void **) &DirectDraw
, &IID_IDirectDraw7
, NULL
);
97 ok(hr
==DD_OK
|| hr
==DDERR_NODIRECTDRAWSUPPORT
, "DirectDrawCreateEx returned: %x\n", hr
);
98 if(!DirectDraw
) goto err
;
100 wc
.lpfnWndProc
= DefWindowProcA
;
101 wc
.lpszClassName
= "d3d7_test_wc";
103 window
= CreateWindowA("d3d7_test_wc", "d3d7_test", WS_MAXIMIZE
| WS_VISIBLE
| WS_CAPTION
,
104 0, 0, 640, 480, 0, 0, 0, 0);
106 hr
= IDirectDraw7_SetCooperativeLevel(DirectDraw
, window
, DDSCL_EXCLUSIVE
| DDSCL_FULLSCREEN
);
107 ok(hr
== DD_OK
, "IDirectDraw7_SetCooperativeLevel failed with %08x\n", hr
);
108 if(FAILED(hr
)) goto err
;
109 hr
= IDirectDraw7_SetDisplayMode(DirectDraw
, 640, 480, 32, 0, 0);
111 /* 24 bit is fine too */
112 hr
= IDirectDraw7_SetDisplayMode(DirectDraw
, 640, 480, 24, 0, 0);
115 ok(hr
== DD_OK
|| hr
== DDERR_UNSUPPORTED
, "IDirectDraw7_SetDisplayMode failed with %08x\n", hr
);
117 /* use trace, the caller calls skip() */
118 trace("SetDisplayMode failed\n");
122 hr
= IDirectDraw7_QueryInterface(DirectDraw
, &IID_IDirect3D7
, (void**) &Direct3D
);
123 if (hr
== E_NOINTERFACE
) goto err
;
124 ok(hr
==DD_OK
, "QueryInterface returned: %08x\n", hr
);
126 /* DirectDraw Flipping behavior doesn't seem that well-defined. The reference rasterizer behaves differently
127 * than hardware implementations. Request single buffering, that seems to work everywhere
129 memset(&ddsd
, 0, sizeof(ddsd
));
130 ddsd
.dwSize
= sizeof(ddsd
);
131 ddsd
.dwFlags
= DDSD_CAPS
;
132 ddsd
.ddsCaps
.dwCaps
= DDSCAPS_PRIMARYSURFACE
| DDSCAPS_3DDEVICE
;
133 U5(ddsd
).dwBackBufferCount
= 1;
134 hr
= IDirectDraw7_CreateSurface(DirectDraw
, &ddsd
, &Surface
, NULL
);
135 if(FAILED(hr
)) goto err
;
137 hr
= IDirect3D7_EnumDevices(Direct3D
, enum_devtype_cb
, &hal_ok
);
138 ok(SUCCEEDED(hr
), "Failed to enumerate devices, hr %#x.\n", hr
);
139 if (hal_ok
) devtype
= &IID_IDirect3DTnLHalDevice
;
141 memset(&zfmt
, 0, sizeof(zfmt
));
142 hr
= IDirect3D7_EnumZBufferFormats(Direct3D
, devtype
, enum_z_fmt
, &zfmt
);
143 if (FAILED(hr
)) goto err
;
144 if (zfmt
.dwSize
== 0) goto err
;
146 memset(&ddsd
, 0, sizeof(ddsd
));
147 ddsd
.dwSize
= sizeof(ddsd
);
148 ddsd
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PIXELFORMAT
;
149 ddsd
.ddsCaps
.dwCaps
= DDSCAPS_ZBUFFER
;
150 U4(ddsd
).ddpfPixelFormat
= zfmt
;
153 hr
= IDirectDraw7_CreateSurface(DirectDraw
, &ddsd
, &depth_buffer
, NULL
);
154 ok(SUCCEEDED(hr
), "CreateSurface failed, hr %#x.\n", hr
);
155 if (FAILED(hr
)) goto err
;
157 hr
= IDirectDrawSurface_AddAttachedSurface(Surface
, depth_buffer
);
158 ok(SUCCEEDED(hr
), "AddAttachedSurface failed, hr %#x.\n", hr
);
159 if (FAILED(hr
)) goto err
;
161 hr
= IDirect3D7_CreateDevice(Direct3D
, devtype
, Surface
, &Direct3DDevice
);
162 if (FAILED(hr
) || !Direct3DDevice
) goto err
;
166 if(DirectDraw
) IDirectDraw7_Release(DirectDraw
);
167 if (depth_buffer
) IDirectDrawSurface7_Release(depth_buffer
);
168 if(Surface
) IDirectDrawSurface7_Release(Surface
);
169 if(Direct3D
) IDirect3D7_Release(Direct3D
);
170 if(Direct3DDevice
) IDirect3DDevice7_Release(Direct3DDevice
);
171 if(window
) DestroyWindow(window
);
175 static void releaseObjects(void)
177 IDirect3DDevice7_Release(Direct3DDevice
);
178 IDirect3D7_Release(Direct3D
);
179 IDirectDrawSurface7_Release(depth_buffer
);
180 IDirectDrawSurface7_Release(Surface
);
181 IDirectDraw7_Release(DirectDraw
);
182 DestroyWindow(window
);
185 static DWORD
getPixelColor(IDirect3DDevice7
*device
, UINT x
, UINT y
)
190 RECT rectToLock
= {x
, y
, x
+1, y
+1};
191 IDirectDrawSurface7
*surf
= NULL
;
193 /* Some implementations seem to dislike direct locking on the front buffer. Thus copy the front buffer
194 * to an offscreen surface and lock it instead of the front buffer
196 memset(&ddsd
, 0, sizeof(ddsd
));
197 ddsd
.dwSize
= sizeof(ddsd
);
198 U4(ddsd
).ddpfPixelFormat
.dwSize
= sizeof(U4(ddsd
).ddpfPixelFormat
);
199 ddsd
.dwFlags
= DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_CAPS
;
202 ddsd
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_SYSTEMMEMORY
;
203 hr
= IDirectDraw7_CreateSurface(DirectDraw
, &ddsd
, &surf
, NULL
);
204 ok(hr
== DD_OK
, "IDirectDraw7_CreateSurface failed with %08x\n", hr
);
207 trace("cannot create helper surface\n");
211 memset(&ddsd
, 0, sizeof(ddsd
));
212 ddsd
.dwSize
= sizeof(ddsd
);
213 U4(ddsd
).ddpfPixelFormat
.dwSize
= sizeof(U4(ddsd
).ddpfPixelFormat
);
215 hr
= IDirectDrawSurface_BltFast(surf
, 0, 0, Surface
, NULL
, 0);
216 ok(hr
== DD_OK
, "IDirectDrawSurface7_BltFast returned %08x\n", hr
);
219 trace("Cannot blit\n");
224 hr
= IDirectDrawSurface7_Lock(surf
, &rectToLock
, &ddsd
, DDLOCK_READONLY
| DDLOCK_WAIT
, NULL
);
227 trace("Can't lock the offscreen surface, hr=%08x\n", hr
);
232 /* Remove the X channel for now. DirectX and OpenGL have different ideas how to treat it apparently, and it isn't
233 * really important for these tests
235 ret
= ((DWORD
*) ddsd
.lpSurface
)[0] & 0x00ffffff;
236 hr
= IDirectDrawSurface7_Unlock(surf
, NULL
);
239 trace("Can't unlock the offscreen surface, hr=%08x\n", hr
);
243 IDirectDrawSurface7_Release(surf
);
247 static void set_viewport_size(IDirect3DDevice7
*device
)
249 D3DVIEWPORT7 vp
= {0};
252 IDirectDrawSurface7
*target
;
254 hr
= IDirect3DDevice7_GetRenderTarget(device
, &target
);
255 ok(hr
== D3D_OK
, "IDirect3DDevice7_GetRenderTarget returned %08x\n", hr
);
257 memset(&ddsd
, 0, sizeof(ddsd
));
258 ddsd
.dwSize
= sizeof(ddsd
);
259 hr
= IDirectDrawSurface7_GetSurfaceDesc(target
, &ddsd
);
260 ok(hr
== D3D_OK
, "IDirectDrawSurface7_GetSurfaceDesc returned %08x\n", hr
);
261 IDirectDrawSurface7_Release(target
);
263 vp
.dwWidth
= ddsd
.dwWidth
;
264 vp
.dwHeight
= ddsd
.dwHeight
;
265 hr
= IDirect3DDevice7_SetViewport(device
, &vp
);
266 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetViewport returned %08x\n", hr
);
270 static void clear_test(IDirect3DDevice7
*device
)
272 /* Tests the correctness of clearing parameters */
278 hr
= IDirect3DDevice7_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
, 0xffffffff, 0.0, 0);
279 ok(hr
== D3D_OK
, "IDirect3DDevice7_Clear failed with %08x\n", hr
);
281 /* Positive x, negative y */
283 U2(rect
[0]).y1
= 480;
284 U3(rect
[0]).x2
= 320;
285 U4(rect
[0]).y2
= 240;
287 /* Positive x, positive y */
290 U3(rect
[1]).x2
= 320;
291 U4(rect
[1]).y2
= 240;
292 /* Clear 2 rectangles with one call. Shows that a positive value is returned, but the negative rectangle
293 * is ignored, the positive is still cleared afterwards
295 hr
= IDirect3DDevice7_Clear(device
, 2, rect
, D3DCLEAR_TARGET
, 0xffff0000, 0.0, 0);
296 ok(hr
== D3D_OK
, "IDirect3DDevice7_Clear failed with %08x\n", hr
);
298 /* negative x, negative y */
299 U1(rect_negneg
).x1
= 640;
300 U2(rect_negneg
).y1
= 240;
301 U3(rect_negneg
).x2
= 320;
302 U4(rect_negneg
).y2
= 0;
303 hr
= IDirect3DDevice7_Clear(device
, 1, &rect_negneg
, D3DCLEAR_TARGET
, 0xff00ff00, 0.0, 0);
304 ok(hr
== D3D_OK
, "IDirect3DDevice7_Clear failed with %08x\n", hr
);
306 color
= getPixelColor(device
, 160, 360); /* lower left quad */
307 ok(color
== 0x00ffffff, "Clear rectangle 3(pos, neg) has color %08x\n", color
);
308 color
= getPixelColor(device
, 160, 120); /* upper left quad */
309 ok(color
== 0x00ff0000, "Clear rectangle 1(pos, pos) has color %08x\n", color
);
310 color
= getPixelColor(device
, 480, 360); /* lower right quad */
311 ok(color
== 0x00ffffff, "Clear rectangle 4(NULL) has color %08x\n", color
);
312 color
= getPixelColor(device
, 480, 120); /* upper right quad */
313 ok(color
== 0x00ffffff, "Clear rectangle 4(neg, neg) has color %08x\n", color
);
316 static void fog_test(IDirect3DDevice7
*device
)
320 float start
= 0.0, end
= 1.0;
325 struct vec3 position
;
329 /* Gets full z based fog with linear fog, no fog with specular color */
332 {{-1.0f
, -1.0f
, 0.1f
}, 0xffff0000, 0xff000000},
333 {{-1.0f
, 0.0f
, 0.1f
}, 0xffff0000, 0xff000000},
334 {{ 0.0f
, 0.0f
, 0.1f
}, 0xffff0000, 0xff000000},
335 {{ 0.0f
, -1.0f
, 0.1f
}, 0xffff0000, 0xff000000},
337 /* Ok, I am too lazy to deal with transform matrices */
340 {{-1.0f
, 0.0f
, 1.0f
}, 0xffff0000, 0xff000000},
341 {{-1.0f
, 1.0f
, 1.0f
}, 0xffff0000, 0xff000000},
342 {{ 0.0f
, 1.0f
, 1.0f
}, 0xffff0000, 0xff000000},
343 {{ 0.0f
, 0.0f
, 1.0f
}, 0xffff0000, 0xff000000},
347 {{-1.0f
, -1.0f
, 0.5f
}, 0xffff0000, 0xff000000},
348 {{-1.0f
, 0.0f
, 0.5f
}, 0xffff0000, 0xff000000},
349 {{ 0.0f
, 0.0f
, 0.5f
}, 0xffff0000, 0xff000000},
350 {{ 0.0f
, -1.0f
, 0.5f
}, 0xffff0000, 0xff000000},
354 {{-1.0f
, 0.0f
, 1.5f
}, 0xffff0000, 0xff000000},
355 {{-1.0f
, 1.0f
, 1.5f
}, 0xffff0000, 0xff000000},
356 {{ 0.0f
, 1.0f
, 1.5f
}, 0xffff0000, 0xff000000},
357 {{ 0.0f
, 0.0f
, 1.5f
}, 0xffff0000, 0xff000000},
359 /* Untransformed ones. Give them a different diffuse color to make the
360 * test look nicer. It also helps making sure that they are drawn
364 struct vec4 position
;
370 {{320.0f
, 0.0f
, 1.0f
, 1.0f
}, 0xffffff00, 0xff000000},
371 {{640.0f
, 0.0f
, 1.0f
, 1.0f
}, 0xffffff00, 0xff000000},
372 {{640.0f
, 240.0f
, 1.0f
, 1.0f
}, 0xffffff00, 0xff000000},
373 {{320.0f
, 240.0f
, 1.0f
, 1.0f
}, 0xffffff00, 0xff000000},
377 {{320.0f
, 240.0f
, 1.0f
, 1.0f
}, 0xffffff00, 0xff000000},
378 {{640.0f
, 240.0f
, 1.0f
, 1.0f
}, 0xffffff00, 0xff000000},
379 {{640.0f
, 480.0f
, 1.0f
, 1.0f
}, 0xffffff00, 0xff000000},
380 {{320.0f
, 480.0f
, 1.0f
, 1.0f
}, 0xffffff00, 0xff000000},
382 WORD Indices
[] = {0, 1, 2, 2, 3, 0};
383 D3DMATRIX ident_mat
=
385 1.0f
, 0.0f
, 0.0f
, 0.0f
,
386 0.0f
, 1.0f
, 0.0f
, 0.0f
,
387 0.0f
, 0.0f
, 1.0f
, 0.0f
,
388 0.0f
, 0.0f
, 0.0f
, 1.0f
,
390 D3DMATRIX world_mat1
=
392 1.0f
, 0.0f
, 0.0f
, 0.0f
,
393 0.0f
, 1.0f
, 0.0f
, 0.0f
,
394 0.0f
, 0.0f
, 1.0f
, 0.0f
,
395 0.0f
, 0.0f
, -0.5f
, 1.0f
,
397 D3DMATRIX world_mat2
=
399 1.0f
, 0.0f
, 0.0f
, 0.0f
,
400 0.0f
, 1.0f
, 0.0f
, 0.0f
,
401 0.0f
, 0.0f
, 1.0f
, 0.0f
,
402 0.0f
, 0.0f
, 1.0f
, 1.0f
,
406 1.0f
, 0.0f
, 0.0f
, 0.0f
,
407 0.0f
, 1.0f
, 0.0f
, 0.0f
,
408 0.0f
, 0.0f
, 1.0f
, 0.0f
,
409 0.0f
, 0.0f
, -1.0f
, 1.0f
,
412 memset(&caps
, 0, sizeof(caps
));
413 hr
= IDirect3DDevice7_GetCaps(device
, &caps
);
414 ok(hr
== D3D_OK
, "IDirect3DDevice7_GetCaps returned %08x\n", hr
);
415 hr
= IDirect3DDevice7_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
, 0xffff00ff, 0.0, 0);
416 ok(hr
== D3D_OK
, "IDirect3DDevice7_Clear returned %08x\n", hr
);
418 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_ZENABLE
, FALSE
);
419 ok(SUCCEEDED(hr
), "Failed to disable z test, hr %#x.\n", hr
);
420 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_CULLMODE
, D3DCULL_NONE
);
421 ok(SUCCEEDED(hr
), "Failed to disable culling, hr %#x.\n", hr
);
422 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_LIGHTING
, FALSE
);
423 ok(hr
== D3D_OK
, "Turning off lighting returned %08x\n", hr
);
424 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_FOGENABLE
, TRUE
);
425 ok(hr
== D3D_OK
, "Turning on fog calculations returned %08x\n", hr
);
426 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_FOGCOLOR
, 0xFF00FF00 /* A nice green */);
427 ok(hr
== D3D_OK
, "Setting fog color returned %08x\n", hr
);
429 /* First test: Both table fog and vertex fog off */
430 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_FOGTABLEMODE
, D3DFOG_NONE
);
431 ok(hr
== D3D_OK
, "Turning off table fog returned %08x\n", hr
);
432 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_FOGVERTEXMODE
, D3DFOG_NONE
);
433 ok(hr
== D3D_OK
, "Turning off vertex fog returned %08x\n", hr
);
435 /* Start = 0, end = 1. Should be default, but set them */
436 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_FOGSTART
, *((DWORD
*) &start
));
437 ok(hr
== D3D_OK
, "Setting fog start returned %08x\n", hr
);
438 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_FOGEND
, *((DWORD
*) &end
));
439 ok(hr
== D3D_OK
, "Setting fog end returned %08x\n", hr
);
441 if(IDirect3DDevice7_BeginScene(device
) == D3D_OK
)
443 /* Untransformed, vertex fog = NONE, table fog = NONE: Read the fog weighting from the specular color */
444 hr
= IDirect3DDevice7_DrawIndexedPrimitive(device
, D3DPT_TRIANGLELIST
, D3DFVF_XYZ
| D3DFVF_DIFFUSE
| D3DFVF_SPECULAR
,
445 untransformed_1
, 4, Indices
, 6, 0);
446 ok(hr
== D3D_OK
, "DrawIndexedPrimitive returned %08x\n", hr
);
448 /* That makes it use the Z value */
449 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_FOGVERTEXMODE
, D3DFOG_LINEAR
);
450 ok(hr
== D3D_OK
, "Setting fog vertex mode to D3DFOG_LINEAR returned %08x\n", hr
);
451 /* Untransformed, vertex fog != none (or table fog != none):
452 * Use the Z value as input into the equation
454 hr
= IDirect3DDevice7_DrawIndexedPrimitive(device
, D3DPT_TRIANGLELIST
, D3DFVF_XYZ
| D3DFVF_DIFFUSE
| D3DFVF_SPECULAR
,
455 untransformed_2
, 4, Indices
, 6, 0);
456 ok(hr
== D3D_OK
, "DrawIndexedPrimitive returned %08x\n", hr
);
458 /* Transformed, vertex fog != NONE, pixel fog == NONE: Use specular color alpha component */
459 hr
= IDirect3DDevice7_DrawIndexedPrimitive(device
, D3DPT_TRIANGLELIST
, D3DFVF_XYZRHW
| D3DFVF_DIFFUSE
| D3DFVF_SPECULAR
,
460 transformed_1
, 4, Indices
, 6, 0);
461 ok(hr
== D3D_OK
, "DrawIndexedPrimitive returned %08x\n", hr
);
463 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_FOGTABLEMODE
, D3DFOG_LINEAR
);
464 ok( hr
== D3D_OK
, "Setting fog table mode to D3DFOG_LINEAR returned %08x\n", hr
);
465 /* Transformed, table fog != none, vertex anything: Use Z value as input to the fog
468 hr
= IDirect3DDevice7_DrawIndexedPrimitive(device
, D3DPT_TRIANGLELIST
, D3DFVF_XYZRHW
| D3DFVF_DIFFUSE
| D3DFVF_SPECULAR
,
469 transformed_2
, 4, Indices
, 6, 0);
470 ok(hr
== D3D_OK
, "DrawIndexedPrimitive returned %08x\n", hr
);
472 hr
= IDirect3DDevice7_EndScene(device
);
473 ok(hr
== D3D_OK
, "EndScene returned %08x\n", hr
);
477 ok(FALSE
, "BeginScene failed\n");
480 color
= getPixelColor(device
, 160, 360);
481 ok(color_match(color
, 0x00FF0000, 1), "Untransformed vertex with no table or vertex fog has color %08x\n", color
);
482 color
= getPixelColor(device
, 160, 120);
483 ok(color_match(color
, 0x0000FF00, 1), "Untransformed vertex with linear vertex fog has color %08x\n", color
);
484 color
= getPixelColor(device
, 480, 120);
485 ok(color_match(color
, 0x00FFFF00, 1), "Transformed vertex with linear vertex fog has color %08x\n", color
);
486 if(caps
.dpcTriCaps
.dwRasterCaps
& D3DPRASTERCAPS_FOGTABLE
)
488 color
= getPixelColor(device
, 480, 360);
489 ok(color_match(color
, 0x0000FF00, 1), "Transformed vertex with linear table fog has color %08x\n", color
);
493 /* Without fog table support the vertex fog is still applied, even though table fog is turned on.
494 * The settings above result in no fogging with vertex fog
496 color
= getPixelColor(device
, 480, 120);
497 ok(color
== 0x00FFFF00, "Transformed vertex with linear vertex fog has color %08x\n", color
);
498 trace("Info: Table fog not supported by this device\n");
501 if (caps
.dpcTriCaps
.dwRasterCaps
& D3DPRASTERCAPS_FOGTABLE
)
503 /* A simple fog + non-identity world matrix test */
504 hr
= IDirect3DDevice7_SetTransform(device
, D3DTRANSFORMSTATE_WORLD
, &world_mat1
);
505 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetTransform returned %#08x\n", hr
);
507 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_FOGTABLEMODE
, D3DFOG_LINEAR
);
508 ok(hr
== D3D_OK
, "Setting fog table mode to D3DFOG_LINEAR returned %#08x\n", hr
);
509 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_FOGVERTEXMODE
, D3DFOG_NONE
);
510 ok(hr
== D3D_OK
, "Turning off vertex fog returned %#08x\n", hr
);
512 hr
= IDirect3DDevice7_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
, 0xffff00ff, 0.0, 0);
513 ok(hr
== D3D_OK
, "IDirect3DDevice7_Clear returned %#08x\n", hr
);
515 if (IDirect3DDevice7_BeginScene(device
) == D3D_OK
)
517 hr
= IDirect3DDevice7_DrawIndexedPrimitive(device
, D3DPT_TRIANGLELIST
,
518 D3DFVF_XYZ
| D3DFVF_DIFFUSE
| D3DFVF_SPECULAR
, far_quad1
, 4, Indices
, 6, 0);
519 ok(hr
== D3D_OK
, "DrawIndexedPrimitive returned %#08x\n", hr
);
521 hr
= IDirect3DDevice7_DrawIndexedPrimitive(device
, D3DPT_TRIANGLELIST
,
522 D3DFVF_XYZ
| D3DFVF_DIFFUSE
| D3DFVF_SPECULAR
, far_quad2
, 4, Indices
, 6, 0);
523 ok(hr
== D3D_OK
, "DrawIndexedPrimitive returned %#08x\n", hr
);
525 hr
= IDirect3DDevice7_EndScene(device
);
526 ok(hr
== D3D_OK
, "EndScene returned %#08x\n", hr
);
530 ok(FALSE
, "BeginScene failed\n");
533 color
= getPixelColor(device
, 160, 360);
534 ok(color_match(color
, 0x00ff0000, 4), "Unfogged quad has color %08x\n", color
);
535 color
= getPixelColor(device
, 160, 120);
536 ok(color_match(color
, 0x0000ff00, 1), "Fogged out quad has color %08x\n", color
);
538 /* Test fog behavior with an orthogonal (but not identity) projection matrix */
539 hr
= IDirect3DDevice7_SetTransform(device
, D3DTRANSFORMSTATE_WORLD
, &world_mat2
);
540 ok(hr
== D3D_OK
, "SetTransform returned %#08x\n", hr
);
541 hr
= IDirect3DDevice7_SetTransform(device
, D3DTRANSFORMSTATE_PROJECTION
, &proj_mat
);
542 ok(hr
== D3D_OK
, "SetTransform returned %#08x\n", hr
);
544 hr
= IDirect3DDevice7_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
, 0xffff00ff, 0.0, 0);
545 ok(hr
== D3D_OK
, "Clear returned %#08x\n", hr
);
547 if (IDirect3DDevice7_BeginScene(device
) == D3D_OK
)
549 hr
= IDirect3DDevice7_DrawIndexedPrimitive(device
, D3DPT_TRIANGLELIST
,
550 D3DFVF_XYZ
| D3DFVF_DIFFUSE
| D3DFVF_SPECULAR
, untransformed_1
, 4, Indices
, 6, 0);
551 ok(hr
== D3D_OK
, "DrawIndexedPrimitiveUP returned %#08x\n", hr
);
553 hr
= IDirect3DDevice7_DrawIndexedPrimitive(device
, D3DPT_TRIANGLELIST
,
554 D3DFVF_XYZ
| D3DFVF_DIFFUSE
| D3DFVF_SPECULAR
, untransformed_2
, 4, Indices
, 6, 0);
555 ok(hr
== D3D_OK
, "DrawIndexedPrimitiveUP returned %#08x\n", hr
);
557 hr
= IDirect3DDevice7_EndScene(device
);
558 ok(hr
== D3D_OK
, "EndScene returned %#08x\n", hr
);
562 ok(FALSE
, "BeginScene failed\n");
565 color
= getPixelColor(device
, 160, 360);
566 ok(color_match(color
, 0x00e51900, 4), "Partially fogged quad has color %08x\n", color
);
567 color
= getPixelColor(device
, 160, 120);
568 ok(color_match(color
, 0x0000ff00, 1), "Fogged out quad has color %08x\n", color
);
570 hr
= IDirect3DDevice7_SetTransform(device
, D3DTRANSFORMSTATE_WORLD
, &ident_mat
);
571 ok(hr
== D3D_OK
, "SetTransform returned %#08x\n", hr
);
572 hr
= IDirect3DDevice7_SetTransform(device
, D3DTRANSFORMSTATE_PROJECTION
, &ident_mat
);
573 ok(hr
== D3D_OK
, "SetTransform returned %#08x\n", hr
);
577 skip("D3DPRASTERCAPS_FOGTABLE not supported, skipping some fog tests\n");
580 /* Turn off the fog master switch to avoid confusing other tests */
581 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_FOGENABLE
, FALSE
);
582 ok(hr
== D3D_OK
, "Turning off fog calculations returned %08x\n", hr
);
585 static void offscreen_test(IDirect3DDevice7
*device
)
588 IDirectDrawSurface7
*backbuffer
= NULL
, *offscreen
= NULL
;
592 static float quad
[][5] = {
593 {-0.5f
, -0.5f
, 0.1f
, 0.0f
, 0.0f
},
594 {-0.5f
, 0.5f
, 0.1f
, 0.0f
, 1.0f
},
595 { 0.5f
, -0.5f
, 0.1f
, 1.0f
, 0.0f
},
596 { 0.5f
, 0.5f
, 0.1f
, 1.0f
, 1.0f
},
599 hr
= IDirect3DDevice7_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
, 0xffff0000, 0.0, 0);
600 ok(hr
== D3D_OK
, "Clear failed, hr = %08x\n", hr
);
602 memset(&ddsd
, 0, sizeof(ddsd
));
603 ddsd
.dwSize
= sizeof(ddsd
);
604 U4(ddsd
).ddpfPixelFormat
.dwSize
= sizeof(U4(ddsd
).ddpfPixelFormat
);
605 ddsd
.dwFlags
= DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_CAPS
;
608 ddsd
.ddsCaps
.dwCaps
= DDSCAPS_TEXTURE
| DDSCAPS_3DDEVICE
;
609 hr
= IDirectDraw7_CreateSurface(DirectDraw
, &ddsd
, &offscreen
, NULL
);
610 ok(hr
== D3D_OK
, "Creating the offscreen render target failed, hr = %08x\n", hr
);
615 hr
= IDirect3DDevice7_GetRenderTarget(device
, &backbuffer
);
616 ok(hr
== D3D_OK
, "Can't get back buffer, hr = %08x\n", hr
);
621 hr
= IDirect3DDevice7_SetTextureStageState(device
, 0, D3DTSS_COLOROP
, D3DTOP_SELECTARG1
);
622 ok(hr
== D3D_OK
, "SetTextureStageState failed, hr = %08x\n", hr
);
623 hr
= IDirect3DDevice7_SetTextureStageState(device
, 0, D3DTSS_COLORARG1
, D3DTA_TEXTURE
);
624 ok(hr
== D3D_OK
, "SetTextureStageState failed, hr = %08x\n", hr
);
625 hr
= IDirect3DDevice7_SetTextureStageState(device
, 0, D3DTSS_MINFILTER
, D3DFILTER_NEAREST
);
626 ok(SUCCEEDED(hr
), "SetTextureStageState D3DSAMP_MINFILTER failed (0x%08x)\n", hr
);
627 hr
= IDirect3DDevice7_SetTextureStageState(device
, 0, D3DTSS_MAGFILTER
, D3DFILTER_NEAREST
);
628 ok(SUCCEEDED(hr
), "SetTextureStageState D3DSAMP_MAGFILTER failed (0x%08x)\n", hr
);
629 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_LIGHTING
, FALSE
);
630 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetRenderState returned hr = %08x\n", hr
);
633 win_skip("Tests would crash on W2K with a refdevice\n");
637 if(IDirect3DDevice7_BeginScene(device
) == D3D_OK
) {
638 hr
= IDirect3DDevice7_SetRenderTarget(device
, offscreen
, 0);
639 ok(hr
== D3D_OK
, "SetRenderTarget failed, hr = %08x\n", hr
);
640 set_viewport_size(device
);
641 hr
= IDirect3DDevice7_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
, 0xffff00ff, 0.0, 0);
642 ok(hr
== D3D_OK
, "Clear failed, hr = %08x\n", hr
);
644 /* Draw without textures - Should result in a white quad */
645 hr
= IDirect3DDevice7_DrawPrimitive(device
, D3DPT_TRIANGLESTRIP
, D3DFVF_XYZ
| D3DFVF_TEX1
, quad
, 4, 0);
646 ok(hr
== D3D_OK
, "DrawPrimitive failed, hr = %08x\n", hr
);
648 hr
= IDirect3DDevice7_SetRenderTarget(device
, backbuffer
, 0);
649 ok(hr
== D3D_OK
, "SetRenderTarget failed, hr = %08x\n", hr
);
650 set_viewport_size(device
);
652 hr
= IDirect3DDevice7_SetTexture(device
, 0, offscreen
);
653 ok(hr
== D3D_OK
, "SetTexture failed, %08x\n", hr
);
655 /* This time with the texture */
656 hr
= IDirect3DDevice7_DrawPrimitive(device
, D3DPT_TRIANGLESTRIP
, D3DFVF_XYZ
| D3DFVF_TEX1
, quad
, 4, 0);
657 ok(hr
== D3D_OK
, "DrawPrimitive failed, hr = %08x\n", hr
);
659 IDirect3DDevice7_EndScene(device
);
662 /* Center quad - should be white */
663 color
= getPixelColor(device
, 320, 240);
664 ok(color
== 0x00ffffff, "Offscreen failed: Got color 0x%08x, expected 0x00ffffff.\n", color
);
665 /* Some quad in the cleared part of the texture */
666 color
= getPixelColor(device
, 170, 240);
667 ok(color
== 0x00ff00ff, "Offscreen failed: Got color 0x%08x, expected 0x00ff00ff.\n", color
);
668 /* Part of the originally cleared back buffer */
669 color
= getPixelColor(device
, 10, 10);
670 ok(color
== 0x00ff0000, "Offscreen failed: Got color 0x%08x, expected 0x00ff0000.\n", color
);
672 /* Lower left corner of the screen, where back buffer offscreen rendering draws the offscreen texture.
673 * It should be red, but the offscreen texture may leave some junk there. Not tested yet. Depending on
674 * the offscreen rendering mode this test would succeed or fail
676 color
= getPixelColor(device
, 10, 470);
677 ok(color
== 0x00ff0000, "Offscreen failed: Got color 0x%08x, expected 0x00ff0000.\n", color
);
681 hr
= IDirect3DDevice7_SetTexture(device
, 0, NULL
);
682 ok(SUCCEEDED(hr
), "IDirect3DDevice7_SetTexture returned %#x.\n", hr
);
686 hr
= IDirect3DDevice7_SetRenderTarget(device
, backbuffer
, 0);
687 ok(SUCCEEDED(hr
), "IDirect3DDevice7_SetRenderTarget returned %#x.\n", hr
);
688 IDirectDrawSurface7_Release(backbuffer
);
691 IDirectDrawSurface7_Release(offscreen
);
695 static void test_blend(IDirect3DDevice7
*device
)
698 IDirectDrawSurface7
*backbuffer
= NULL
, *offscreen
= NULL
;
699 DWORD color
, red
, green
, blue
;
704 struct vec3 position
;
709 {{-1.0f
, -1.0f
, 0.1f
}, 0x4000ff00},
710 {{-1.0f
, 0.0f
, 0.1f
}, 0x4000ff00},
711 {{ 1.0f
, -1.0f
, 0.1f
}, 0x4000ff00},
712 {{ 1.0f
, 0.0f
, 0.1f
}, 0x4000ff00},
716 {{-1.0f
, 0.0f
, 0.1f
}, 0xc00000ff},
717 {{-1.0f
, 1.0f
, 0.1f
}, 0xc00000ff},
718 {{ 1.0f
, 0.0f
, 0.1f
}, 0xc00000ff},
719 {{ 1.0f
, 1.0f
, 0.1f
}, 0xc00000ff},
721 static float composite_quad
[][5] = {
722 { 0.0f
, -1.0f
, 0.1f
, 0.0f
, 1.0f
},
723 { 0.0f
, 1.0f
, 0.1f
, 0.0f
, 0.0f
},
724 { 1.0f
, -1.0f
, 0.1f
, 1.0f
, 1.0f
},
725 { 1.0f
, 1.0f
, 0.1f
, 1.0f
, 0.0f
},
728 /* Clear the render target with alpha = 0.5 */
729 hr
= IDirect3DDevice7_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
, 0x80ff0000, 0.0, 0);
730 ok(hr
== D3D_OK
, "Clear failed, hr = %08x\n", hr
);
732 memset(&ddsd
, 0, sizeof(ddsd
));
733 ddsd
.dwSize
= sizeof(ddsd
);
734 ddsd
.dwFlags
= DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_CAPS
| DDSD_PIXELFORMAT
;
737 ddsd
.ddsCaps
.dwCaps
= DDSCAPS_TEXTURE
| DDSCAPS_3DDEVICE
;
738 U4(ddsd
).ddpfPixelFormat
.dwFlags
= DDPF_RGB
| DDPF_ALPHAPIXELS
;
739 U1(U4(ddsd
).ddpfPixelFormat
).dwRGBBitCount
= 32;
740 U2(U4(ddsd
).ddpfPixelFormat
).dwRBitMask
= 0x00ff0000;
741 U3(U4(ddsd
).ddpfPixelFormat
).dwGBitMask
= 0x0000ff00;
742 U4(U4(ddsd
).ddpfPixelFormat
).dwBBitMask
= 0x000000ff;
743 U5(U4(ddsd
).ddpfPixelFormat
).dwRGBAlphaBitMask
= 0xff000000;
744 hr
= IDirectDraw7_CreateSurface(DirectDraw
, &ddsd
, &offscreen
, NULL
);
745 ok(hr
== D3D_OK
, "Creating the offscreen render target failed, hr = %08x\n", hr
);
749 hr
= IDirect3DDevice7_GetRenderTarget(device
, &backbuffer
);
750 ok(hr
== D3D_OK
, "Can't get back buffer, hr = %08x\n", hr
);
755 hr
= IDirect3DDevice7_SetTextureStageState(device
, 0, D3DTSS_COLOROP
, D3DTOP_SELECTARG1
);
756 ok(hr
== D3D_OK
, "SetTextureStageState failed, hr = %08x\n", hr
);
757 hr
= IDirect3DDevice7_SetTextureStageState(device
, 0, D3DTSS_COLORARG1
, D3DTA_TEXTURE
);
758 ok(hr
== D3D_OK
, "SetTextureStageState failed, hr = %08x\n", hr
);
759 hr
= IDirect3DDevice7_SetTextureStageState(device
, 0, D3DTSS_MINFILTER
, D3DFILTER_NEAREST
);
760 ok(SUCCEEDED(hr
), "SetTextureStageState D3DSAMP_MINFILTER failed (0x%08x)\n", hr
);
761 hr
= IDirect3DDevice7_SetTextureStageState(device
, 0, D3DTSS_MAGFILTER
, D3DFILTER_NEAREST
);
762 ok(SUCCEEDED(hr
), "SetTextureStageState D3DSAMP_MAGFILTER failed (0x%08x)\n", hr
);
764 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_ALPHABLENDENABLE
, TRUE
);
765 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr
);
768 win_skip("Tests would crash on W2K with a refdevice\n");
772 if(IDirect3DDevice7_BeginScene(device
) == D3D_OK
) {
774 /* Draw two quads, one with src alpha blending, one with dest alpha blending. The
775 * SRCALPHA / INVSRCALPHA blend doesn't give any surprises. Colors are blended based on
778 * The DESTALPHA / INVDESTALPHA do not "work" on the regular buffer because there is no alpha.
779 * They give essentially ZERO and ONE blend factors
781 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_SRCBLEND
, D3DBLEND_SRCALPHA
);
782 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr
);
783 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_DESTBLEND
, D3DBLEND_INVSRCALPHA
);
784 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr
);
785 hr
= IDirect3DDevice7_DrawPrimitive(device
, D3DPT_TRIANGLESTRIP
, D3DFVF_XYZ
| D3DFVF_DIFFUSE
, quad1
, 4, 0);
786 ok(hr
== D3D_OK
, "DrawPrimitive failed, hr = %08x\n", hr
);
788 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_SRCBLEND
, D3DBLEND_DESTALPHA
);
789 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr
);
790 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_DESTBLEND
, D3DBLEND_INVDESTALPHA
);
791 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr
);
792 hr
= IDirect3DDevice7_DrawPrimitive(device
, D3DPT_TRIANGLESTRIP
, D3DFVF_XYZ
| D3DFVF_DIFFUSE
, quad2
, 4, 0);
793 ok(hr
== D3D_OK
, "DrawPrimitive failed, hr = %08x\n", hr
);
795 /* Switch to the offscreen buffer, and redo the testing. SRCALPHA and DESTALPHA. The offscreen buffer
796 * has an alpha channel on its own. Clear the offscreen buffer with alpha = 0.5 again, then draw the
797 * quads again. The SRCALPHA/INVSRCALPHA doesn't give any surprises, but the DESTALPHA/INVDESTALPHA
798 * blending works as supposed now - blend factor is 0.5 in both cases, not 0.75 as from the input
801 hr
= IDirect3DDevice7_SetRenderTarget(device
, offscreen
, 0);
802 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetRenderTarget failed, hr = %08x\n", hr
);
803 set_viewport_size(device
);
804 hr
= IDirect3DDevice7_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
, 0x80ff0000, 0.0, 0);
805 ok(hr
== D3D_OK
, "Clear failed, hr = %08x\n", hr
);
807 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_SRCBLEND
, D3DBLEND_SRCALPHA
);
808 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr
);
809 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_DESTBLEND
, D3DBLEND_INVSRCALPHA
);
810 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr
);
811 hr
= IDirect3DDevice7_DrawPrimitive(device
, D3DPT_TRIANGLESTRIP
, D3DFVF_XYZ
| D3DFVF_DIFFUSE
, quad1
, 4, 0);
812 ok(hr
== D3D_OK
, "DrawPrimitive failed, hr = %08x\n", hr
);
814 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_SRCBLEND
, D3DBLEND_DESTALPHA
);
815 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr
);
816 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_DESTBLEND
, D3DBLEND_INVDESTALPHA
);
817 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr
);
818 hr
= IDirect3DDevice7_DrawPrimitive(device
, D3DPT_TRIANGLESTRIP
, D3DFVF_XYZ
| D3DFVF_DIFFUSE
, quad2
, 4, 0);
819 ok(hr
== D3D_OK
, "DrawPrimitive failed, hr = %08x\n", hr
);
821 hr
= IDirect3DDevice7_SetRenderTarget(device
, backbuffer
, 0);
822 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetRenderTarget failed, hr = %08x\n", hr
);
823 set_viewport_size(device
);
825 /* Render the offscreen texture onto the frame buffer to be able to compare it regularly.
826 * Disable alpha blending for the final composition
828 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_ALPHABLENDENABLE
, FALSE
);
829 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr
);
831 hr
= IDirect3DDevice7_SetTexture(device
, 0, offscreen
);
832 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetTexture failed, hr = %08x\n", hr
);
833 hr
= IDirect3DDevice7_DrawPrimitive(device
, D3DPT_TRIANGLESTRIP
, D3DFVF_XYZ
| D3DFVF_TEX1
, composite_quad
, 4, 0);
834 ok(hr
== D3D_OK
, "DrawPrimitive failed, hr = %08x\n", hr
);
835 hr
= IDirect3DDevice7_SetTexture(device
, 0, NULL
);
836 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetTexture failed, hr = %08x\n", hr
);
838 hr
= IDirect3DDevice7_EndScene(device
);
839 ok(hr
== D3D_OK
, "IDirect3DDevice7_EndScene failed, hr = %08x\n", hr
);
842 color
= getPixelColor(device
, 160, 360);
843 red
= (color
& 0x00ff0000) >> 16;
844 green
= (color
& 0x0000ff00) >> 8;
845 blue
= (color
& 0x000000ff);
846 ok(red
>= 0xbe && red
<= 0xc0 && green
>= 0x39 && green
<= 0x41 && blue
== 0x00,
847 "SRCALPHA on frame buffer returned color 0x%08x, expected 0x00bf4000\n", color
);
849 color
= getPixelColor(device
, 160, 120);
850 red
= (color
& 0x00ff0000) >> 16;
851 green
= (color
& 0x0000ff00) >> 8;
852 blue
= (color
& 0x000000ff);
853 ok(red
== 0x00 && green
== 0x00 && blue
>= 0xfe && blue
<= 0xff ,
854 "DSTALPHA on frame buffer returned color 0x%08x, expected 0x000000ff\n", color
);
856 color
= getPixelColor(device
, 480, 360);
857 red
= (color
& 0x00ff0000) >> 16;
858 green
= (color
& 0x0000ff00) >> 8;
859 blue
= (color
& 0x000000ff);
860 ok(red
>= 0xbe && red
<= 0xc0 && green
>= 0x39 && green
<= 0x41 && blue
== 0x00,
861 "SRCALPHA on texture returned color 0x%08x, expected 0x00bf4000\n", color
);
863 color
= getPixelColor(device
, 480, 120);
864 red
= (color
& 0x00ff0000) >> 16;
865 green
= (color
& 0x0000ff00) >> 8;
866 blue
= (color
& 0x000000ff);
867 ok(red
>= 0x7e && red
<= 0x81 && green
== 0x00 && blue
>= 0x7e && blue
<= 0x81,
868 "DSTALPHA on texture returned color 0x%08x, expected 0x00800080\n", color
);
871 if(offscreen
) IDirectDrawSurface7_Release(offscreen
);
872 if(backbuffer
) IDirectDrawSurface7_Release(backbuffer
);
875 static void rhw_zero_test(IDirect3DDevice7
*device
)
877 /* Test if it will render a quad correctly when vertex rhw = 0 */
887 {0, 100, 0, 0, 0xffffffff},
888 {0, 0, 0, 0, 0xffffffff},
889 {100, 100, 0, 0, 0xffffffff},
890 {100, 0, 0, 0, 0xffffffff},
894 hr
= IDirect3DDevice7_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
, 0, 0.0, 0);
895 ok(hr
== D3D_OK
, "Clear failed, hr = %08x\n", hr
);
897 hr
= IDirect3DDevice7_BeginScene(device
);
898 ok(hr
== D3D_OK
, "IDirect3DDevice7_BeginScene failed with %08x\n", hr
);
901 hr
= IDirect3DDevice7_DrawPrimitive(device
, D3DPT_TRIANGLESTRIP
, D3DFVF_XYZRHW
| D3DFVF_DIFFUSE
, quad1
, 4, 0);
902 ok(hr
== D3D_OK
, "DrawPrimitive failed, hr = %08x\n", hr
);
904 hr
= IDirect3DDevice7_EndScene(device
);
905 ok(hr
== D3D_OK
, "IDirect3DDevice7_EndScene failed, hr = %08x\n", hr
);
908 color
= getPixelColor(device
, 5, 5);
909 ok(color
== 0xffffff ||
910 broken(color
== 0), /* VMware */
911 "Got color %08x, expected 00ffffff\n", color
);
913 color
= getPixelColor(device
, 105, 105);
914 ok(color
== 0, "Got color %08x, expected 00000000\n", color
);
917 static DWORD
D3D3_getPixelColor(IDirectDraw4
*DirectDraw
, IDirectDrawSurface4
*Surface
, UINT x
, UINT y
)
922 RECT rectToLock
= {x
, y
, x
+1, y
+1};
923 IDirectDrawSurface4
*surf
= NULL
;
925 /* Some implementations seem to dislike direct locking on the front buffer. Thus copy the front buffer
926 * to an offscreen surface and lock it instead of the front buffer
928 memset(&ddsd
, 0, sizeof(ddsd
));
929 ddsd
.dwSize
= sizeof(ddsd
);
930 U4(ddsd
).ddpfPixelFormat
.dwSize
= sizeof(U4(ddsd
).ddpfPixelFormat
);
931 ddsd
.dwFlags
= DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_CAPS
;
934 ddsd
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_SYSTEMMEMORY
;
935 hr
= IDirectDraw4_CreateSurface(DirectDraw
, &ddsd
, &surf
, NULL
);
936 ok(hr
== DD_OK
, "IDirectDraw_CreateSurface failed with %08x\n", hr
);
939 trace("cannot create helper surface\n");
943 memset(&ddsd
, 0, sizeof(ddsd
));
944 ddsd
.dwSize
= sizeof(ddsd
);
945 U4(ddsd
).ddpfPixelFormat
.dwSize
= sizeof(U4(ddsd
).ddpfPixelFormat
);
947 hr
= IDirectDrawSurface4_BltFast(surf
, 0, 0, Surface
, NULL
, 0);
948 ok(hr
== DD_OK
, "IDirectDrawSurface_BltFast returned %08x\n", hr
);
951 trace("Cannot blit\n");
956 hr
= IDirectDrawSurface4_Lock(surf
, &rectToLock
, &ddsd
, DDLOCK_READONLY
| DDLOCK_WAIT
, NULL
);
959 trace("Can't lock the offscreen surface, hr=%08x\n", hr
);
964 /* Remove the X channel for now. DirectX and OpenGL have different ideas how to treat it apparently, and it isn't
965 * really important for these tests
967 ret
= ((DWORD
*) ddsd
.lpSurface
)[0] & 0x00ffffff;
968 hr
= IDirectDrawSurface4_Unlock(surf
, NULL
);
971 trace("Can't unlock the offscreen surface, hr=%08x\n", hr
);
975 IDirectDrawSurface4_Release(surf
);
979 static void D3D3_ViewportClearTest(void)
982 IDirectDraw
*DirectDraw1
= NULL
;
983 IDirectDraw4
*DirectDraw4
= NULL
;
984 IDirectDrawSurface4
*Primary
= NULL
;
985 IDirect3D3
*Direct3D3
= NULL
;
986 IDirect3DViewport3
*Viewport3
= NULL
;
987 IDirect3DViewport3
*SmallViewport3
= NULL
;
988 IDirect3DDevice3
*Direct3DDevice3
= NULL
;
991 D3DVIEWPORT2 vp_data
;
992 DWORD color
, red
, green
, blue
;
996 1.0f
, 0.0f
, 0.0f
, 0.0f
,
997 0.0f
, 1.0f
, 0.0f
, 0.0f
,
998 0.0f
, 0.0f
, 1.0f
, 0.0f
,
999 0.0f
, 0.0f
, 0.0f
, 1.0f
,
1003 struct vec3 position
;
1008 {{-1.0f
, -1.0f
, 0.1f
}, 0xffffffff},
1009 {{-1.0f
, 1.0f
, 0.1f
}, 0xffffffff},
1010 {{ 1.0f
, 1.0f
, 0.1f
}, 0xffffffff},
1011 {{ 1.0f
, -1.0f
, 0.1f
}, 0xffffffff},
1014 WORD Indices
[] = {0, 1, 2, 2, 3, 0};
1015 DWORD fvf
= D3DFVF_XYZ
| D3DFVF_DIFFUSE
;
1017 wc
.lpfnWndProc
= DefWindowProcA
;
1018 wc
.lpszClassName
= "D3D3_ViewportClearTest_wc";
1019 RegisterClassA(&wc
);
1020 window
= CreateWindowA("D3D3_ViewportClearTest_wc", "D3D3_ViewportClearTest",
1021 WS_MAXIMIZE
| WS_VISIBLE
| WS_CAPTION
, 0, 0, 640, 480, 0, 0, 0, 0);
1023 hr
= DirectDrawCreate( NULL
, &DirectDraw1
, NULL
);
1024 ok(hr
==DD_OK
|| hr
==DDERR_NODIRECTDRAWSUPPORT
, "DirectDrawCreate returned: %x\n", hr
);
1025 if(FAILED(hr
)) goto out
;
1027 hr
= IDirectDraw_SetCooperativeLevel(DirectDraw1
, window
, DDSCL_EXCLUSIVE
| DDSCL_FULLSCREEN
);
1028 ok(hr
==DD_OK
, "SetCooperativeLevel returned: %x\n", hr
);
1029 if(FAILED(hr
)) goto out
;
1031 hr
= IDirectDraw_SetDisplayMode(DirectDraw1
, 640, 480, 32);
1033 /* 24 bit is fine too */
1034 hr
= IDirectDraw_SetDisplayMode(DirectDraw1
, 640, 480, 24);
1036 ok(hr
==DD_OK
|| hr
== DDERR_UNSUPPORTED
, "SetDisplayMode returned: %x\n", hr
);
1037 if (FAILED(hr
)) goto out
;
1039 hr
= IDirectDraw_QueryInterface(DirectDraw1
, &IID_IDirectDraw4
, (void**)&DirectDraw4
);
1040 ok(hr
==DD_OK
, "QueryInterface returned: %08x\n", hr
);
1041 if(FAILED(hr
)) goto out
;
1043 memset(&ddsd
, 0, sizeof(DDSURFACEDESC2
));
1044 ddsd
.dwSize
= sizeof(DDSURFACEDESC2
);
1045 ddsd
.dwFlags
= DDSD_CAPS
;
1046 ddsd
.ddsCaps
.dwCaps
= DDSCAPS_PRIMARYSURFACE
| DDSCAPS_3DDEVICE
;
1048 hr
= IDirectDraw_CreateSurface(DirectDraw4
, &ddsd
, &Primary
, NULL
);
1049 ok(hr
==DD_OK
, "IDirectDraw_CreateSurface returned: %08x\n", hr
);
1050 if(FAILED(hr
)) goto out
;
1052 hr
= IDirectDraw4_QueryInterface(DirectDraw4
, &IID_IDirect3D3
, (void**)&Direct3D3
);
1053 ok(hr
==DD_OK
, "IDirectDraw4_QueryInterface returned: %08x\n", hr
);
1054 if(FAILED(hr
)) goto out
;
1056 hr
= IDirect3D3_CreateDevice(Direct3D3
, &IID_IDirect3DHALDevice
, Primary
, &Direct3DDevice3
, NULL
);
1058 trace("Creating a HAL device failed, trying Ref\n");
1059 hr
= IDirect3D3_CreateDevice(Direct3D3
, &IID_IDirect3DRefDevice
, Primary
, &Direct3DDevice3
, NULL
);
1061 ok(hr
==D3D_OK
, "Creating 3D device returned: %x\n", hr
);
1062 if(FAILED(hr
)) goto out
;
1064 hr
= IDirect3D3_CreateViewport(Direct3D3
, &Viewport3
, NULL
);
1065 ok(hr
==DD_OK
, "IDirect3D3_CreateViewport returned: %08x\n", hr
);
1066 if(FAILED(hr
)) goto out
;
1068 hr
= IDirect3DDevice3_AddViewport(Direct3DDevice3
, Viewport3
);
1069 ok(hr
==DD_OK
, "IDirect3DDevice3_AddViewport returned: %08x\n", hr
);
1071 memset(&vp_data
, 0, sizeof(D3DVIEWPORT2
));
1072 vp_data
.dwSize
= sizeof(D3DVIEWPORT2
);
1073 vp_data
.dwWidth
= 640;
1074 vp_data
.dwHeight
= 480;
1075 vp_data
.dvClipX
= -1.0f
;
1076 vp_data
.dvClipWidth
= 2.0f
;
1077 vp_data
.dvClipY
= 1.0f
;
1078 vp_data
.dvClipHeight
= 2.0f
;
1079 vp_data
.dvMaxZ
= 1.0f
;
1080 hr
= IDirect3DViewport3_SetViewport2(Viewport3
, &vp_data
);
1081 ok(hr
==DD_OK
, "IDirect3DViewport3_SetViewport2 returned: %08x\n", hr
);
1083 hr
= IDirect3D3_CreateViewport(Direct3D3
, &SmallViewport3
, NULL
);
1084 ok(hr
==DD_OK
, "IDirect3D3_CreateViewport returned: %08x\n", hr
);
1085 if(FAILED(hr
)) goto out
;
1087 hr
= IDirect3DDevice3_AddViewport(Direct3DDevice3
, SmallViewport3
);
1088 ok(hr
==DD_OK
, "IDirect3DDevice3_AddViewport returned: %08x\n", hr
);
1090 memset(&vp_data
, 0, sizeof(D3DVIEWPORT2
));
1091 vp_data
.dwSize
= sizeof(D3DVIEWPORT2
);
1094 vp_data
.dwWidth
= 100;
1095 vp_data
.dwHeight
= 100;
1096 vp_data
.dvClipX
= -1.0f
;
1097 vp_data
.dvClipWidth
= 2.0f
;
1098 vp_data
.dvClipY
= 1.0f
;
1099 vp_data
.dvClipHeight
= 2.0f
;
1100 vp_data
.dvMaxZ
= 1.0f
;
1101 hr
= IDirect3DViewport3_SetViewport2(SmallViewport3
, &vp_data
);
1102 ok(hr
==DD_OK
, "IDirect3DViewport3_SetViewport2 returned: %08x\n", hr
);
1104 hr
= IDirect3DDevice3_BeginScene(Direct3DDevice3
);
1105 ok(hr
== D3D_OK
, "IDirect3DDevice3_BeginScene failed with %08x\n", hr
);
1107 hr
= IDirect3DDevice3_SetTransform(Direct3DDevice3
, D3DTRANSFORMSTATE_WORLD
, &mat
);
1108 ok(hr
== D3D_OK
, "IDirect3DDevice3_SetTransform returned %08x\n", hr
);
1109 hr
= IDirect3DDevice3_SetTransform(Direct3DDevice3
, D3DTRANSFORMSTATE_VIEW
, &mat
);
1110 ok(hr
== D3D_OK
, "IDirect3DDevice3_SetTransform returned %08x\n", hr
);
1111 hr
= IDirect3DDevice3_SetTransform(Direct3DDevice3
, D3DTRANSFORMSTATE_PROJECTION
, &mat
);
1112 ok(hr
== D3D_OK
, "IDirect3DDevice3_SetTransform returned %08x\n", hr
);
1113 hr
= IDirect3DDevice3_SetRenderState(Direct3DDevice3
, D3DRENDERSTATE_CLIPPING
, FALSE
);
1114 ok(hr
== D3D_OK
, "IDirect3DDevice3_SetRenderState returned %08x\n", hr
);
1115 hr
= IDirect3DDevice3_SetRenderState(Direct3DDevice3
, D3DRENDERSTATE_ZENABLE
, FALSE
);
1116 ok(hr
== D3D_OK
, "IDirect3DDevice3_SetRenderState returned %08x\n", hr
);
1117 hr
= IDirect3DDevice3_SetRenderState(Direct3DDevice3
, D3DRENDERSTATE_FOGENABLE
, FALSE
);
1118 ok(hr
== D3D_OK
, "IDirect3DDevice3_SetRenderState returned %08x\n", hr
);
1119 hr
= IDirect3DDevice3_SetRenderState(Direct3DDevice3
, D3DRENDERSTATE_STENCILENABLE
, FALSE
);
1120 ok(hr
== D3D_OK
, "IDirect3DDevice3_SetRenderState returned %08x\n", hr
);
1121 hr
= IDirect3DDevice3_SetRenderState(Direct3DDevice3
, D3DRENDERSTATE_ALPHATESTENABLE
, FALSE
);
1122 ok(hr
== D3D_OK
, "IDirect3DDevice3_SetRenderState returned %08x\n", hr
);
1123 hr
= IDirect3DDevice3_SetRenderState(Direct3DDevice3
, D3DRENDERSTATE_ALPHABLENDENABLE
, FALSE
);
1124 ok(hr
== D3D_OK
, "IDirect3DDevice3_SetRenderState returned %08x\n", hr
);
1125 hr
= IDirect3DDevice3_SetRenderState(Direct3DDevice3
, D3DRENDERSTATE_CULLMODE
, D3DCULL_NONE
);
1126 ok(hr
== D3D_OK
, "IDirect3DDevice3_SetRenderState failed with %08x\n", hr
);
1127 hr
= IDirect3DDevice3_SetRenderState(Direct3DDevice3
, D3DRENDERSTATE_LIGHTING
, FALSE
);
1128 ok(hr
== D3D_OK
, "IDirect3DDevice3_SetRenderState returned %08x\n", hr
);
1130 if (SUCCEEDED(hr
)) {
1131 U1(rect
).x1
= U2(rect
).y1
= 0;
1135 hr
= IDirect3DViewport3_Clear2(Viewport3
, 1, &rect
, D3DCLEAR_TARGET
, 0x00ff00, 0.0f
, 0);
1136 ok(hr
== D3D_OK
, "IDirect3DViewport3_Clear2 failed, hr = %08x\n", hr
);
1138 hr
= IDirect3DViewport3_Clear2(SmallViewport3
, 1, &rect
, D3DCLEAR_TARGET
, 0xff0000, 0.0f
, 0);
1139 ok(hr
== D3D_OK
, "IDirect3DViewport3_Clear2 failed, hr = %08x\n", hr
);
1141 hr
= IDirect3DDevice3_EndScene(Direct3DDevice3
);
1142 ok(hr
== D3D_OK
, "IDirect3DDevice3_EndScene failed, hr = %08x\n", hr
);
1145 color
= D3D3_getPixelColor(DirectDraw4
, Primary
, 5, 5);
1146 red
= (color
& 0x00ff0000) >> 16;
1147 green
= (color
& 0x0000ff00) >> 8;
1148 blue
= (color
& 0x000000ff);
1149 ok(red
== 0 && green
== 0xff && blue
== 0, "Got color %08x, expected 0000ff00\n", color
);
1151 color
= D3D3_getPixelColor(DirectDraw4
, Primary
, 405, 105);
1152 red
= (color
& 0x00ff0000) >> 16;
1153 green
= (color
& 0x0000ff00) >> 8;
1154 blue
= (color
& 0x000000ff);
1155 ok(red
== 0xff && green
== 0 && blue
== 0, "Got color %08x, expected 00ff0000\n", color
);
1157 /* Test that clearing viewport doesn't interfere with rendering to previously active viewport. */
1158 hr
= IDirect3DDevice3_BeginScene(Direct3DDevice3
);
1159 ok(hr
== D3D_OK
, "IDirect3DDevice3_BeginScene failed with %08x\n", hr
);
1161 if (SUCCEEDED(hr
)) {
1162 hr
= IDirect3DDevice3_SetCurrentViewport(Direct3DDevice3
, SmallViewport3
);
1163 ok(hr
== D3D_OK
, "IDirect3DDevice3_SetCurrentViewport failed with %08x\n", hr
);
1165 hr
= IDirect3DViewport3_Clear2(Viewport3
, 1, &rect
, D3DCLEAR_TARGET
, 0x000000, 0.0f
, 0);
1166 ok(hr
== D3D_OK
, "IDirect3DViewport3_Clear2 failed, hr = %08x\n", hr
);
1168 hr
= IDirect3DDevice3_DrawIndexedPrimitive(Direct3DDevice3
, D3DPT_TRIANGLELIST
, fvf
, quad
, 4 /* NumVerts */,
1169 Indices
, 6 /* Indexcount */, 0 /* flags */);
1170 ok(hr
== D3D_OK
, "IDirect3DDevice3_DrawIndexedPrimitive failed with %08x\n", hr
);
1172 hr
= IDirect3DDevice3_EndScene(Direct3DDevice3
);
1173 ok(hr
== D3D_OK
, "IDirect3DDevice3_EndScene failed, hr = %08x\n", hr
);
1176 color
= D3D3_getPixelColor(DirectDraw4
, Primary
, 5, 5);
1177 red
= (color
& 0x00ff0000) >> 16;
1178 green
= (color
& 0x0000ff00) >> 8;
1179 blue
= (color
& 0x000000ff);
1180 ok(red
== 0 && green
== 0 && blue
== 0, "Got color %08x, expected 00000000\n", color
);
1182 color
= D3D3_getPixelColor(DirectDraw4
, Primary
, 405, 105);
1183 red
= (color
& 0x00ff0000) >> 16;
1184 green
= (color
& 0x0000ff00) >> 8;
1185 blue
= (color
& 0x000000ff);
1186 ok(red
== 0xff && green
== 0xff && blue
== 0xff, "Got color %08x, expected 00ffffff\n", color
);
1190 if (SmallViewport3
) IDirect3DViewport3_Release(SmallViewport3
);
1191 if (Viewport3
) IDirect3DViewport3_Release(Viewport3
);
1192 if (Direct3DDevice3
) IDirect3DDevice3_Release(Direct3DDevice3
);
1193 if (Direct3D3
) IDirect3D3_Release(Direct3D3
);
1194 if (Primary
) IDirectDrawSurface4_Release(Primary
);
1195 if (DirectDraw1
) IDirectDraw_Release(DirectDraw1
);
1196 if (DirectDraw4
) IDirectDraw4_Release(DirectDraw4
);
1197 if(window
) DestroyWindow(window
);
1200 static COLORREF
getPixelColor_GDI(IDirectDrawSurface
*Surface
, UINT x
, UINT y
)
1202 COLORREF clr
= CLR_INVALID
;
1206 hr
= IDirectDrawSurface_GetDC(Surface
, &hdc
);
1207 ok(hr
==DD_OK
, "IDirectDrawSurface_GetDC returned: %x\n", hr
);
1209 if (SUCCEEDED(hr
)) {
1210 clr
= GetPixel(hdc
, x
, y
);
1212 hr
= IDirectDrawSurface_ReleaseDC(Surface
, hdc
);
1213 ok(hr
==DD_OK
, "IDirectDrawSurface_ReleaseDC returned: %x\n", hr
);
1219 static void cubemap_test(IDirect3DDevice7
*device
)
1222 IDirectDraw7
*ddraw
;
1223 IDirectDrawSurface7
*cubemap
, *surface
;
1224 D3DDEVICEDESC7 d3dcaps
;
1227 DDSURFACEDESC2 ddsd
;
1230 static float quad
[] = {
1231 -1.0, -1.0, 0.1, 1.0, 0.0, 0.0, /* Lower left */
1232 0.0, -1.0, 0.1, 1.0, 0.0, 0.0,
1233 -1.0, 0.0, 0.1, 1.0, 0.0, 0.0,
1234 0.0, 0.0, 0.1, 1.0, 0.0, 0.0,
1236 0.0, -1.0, 0.1, 0.0, 1.0, 0.0, /* Lower right */
1237 1.0, -1.0, 0.1, 0.0, 1.0, 0.0,
1238 0.0, 0.0, 0.1, 0.0, 1.0, 0.0,
1239 1.0, 0.0, 0.1, 0.0, 1.0, 0.0,
1241 0.0, 0.0, 0.1, 0.0, 0.0, 1.0, /* upper right */
1242 1.0, 0.0, 0.1, 0.0, 0.0, 1.0,
1243 0.0, 1.0, 0.1, 0.0, 0.0, 1.0,
1244 1.0, 1.0, 0.1, 0.0, 0.0, 1.0,
1246 -1.0, 0.0, 0.1, -1.0, 0.0, 0.0, /* Upper left */
1247 0.0, 0.0, 0.1, -1.0, 0.0, 0.0,
1248 -1.0, 1.0, 0.1, -1.0, 0.0, 0.0,
1249 0.0, 1.0, 0.1, -1.0, 0.0, 0.0,
1252 memset(&DDBltFx
, 0, sizeof(DDBltFx
));
1253 DDBltFx
.dwSize
= sizeof(DDBltFx
);
1255 memset(&d3dcaps
, 0, sizeof(d3dcaps
));
1256 hr
= IDirect3DDevice7_GetCaps(device
, &d3dcaps
);
1257 ok(hr
== D3D_OK
, "IDirect3DDevice7_GetCaps returned %08x\n", hr
);
1258 if(!(d3dcaps
.dpcTriCaps
.dwTextureCaps
& D3DPTEXTURECAPS_CUBEMAP
))
1260 skip("No cubemap support\n");
1264 hr
= IDirect3DDevice7_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
, 0xff000000, 0.0, 0);
1265 ok(hr
== D3D_OK
, "IDirect3DDevice7_Clear failed with %08x\n", hr
);
1267 hr
= IDirect3DDevice7_GetDirect3D(device
, &d3d
);
1268 ok(hr
== D3D_OK
, "IDirect3DDevice7_GetDirect3D returned %08x\n", hr
);
1269 hr
= IDirect3D7_QueryInterface(d3d
, &IID_IDirectDraw7
, (void **) &ddraw
);
1270 ok(hr
== D3D_OK
, "IDirect3D7_QueryInterface returned %08x\n", hr
);
1271 IDirect3D7_Release(d3d
);
1274 memset(&ddsd
, 0, sizeof(ddsd
));
1275 ddsd
.dwSize
= sizeof(ddsd
);
1276 U4(ddsd
).ddpfPixelFormat
.dwSize
= sizeof(U4(ddsd
).ddpfPixelFormat
);
1277 ddsd
.dwFlags
= DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PIXELFORMAT
| DDSD_CAPS
;
1280 ddsd
.ddsCaps
.dwCaps
= DDSCAPS_TEXTURE
| DDSCAPS_COMPLEX
;
1281 ddsd
.ddsCaps
.dwCaps2
= DDSCAPS2_CUBEMAP
| DDSCAPS2_CUBEMAP_ALLFACES
| DDSCAPS2_TEXTUREMANAGE
;
1282 U4(ddsd
).ddpfPixelFormat
.dwFlags
= DDPF_RGB
;
1283 U1(U4(ddsd
).ddpfPixelFormat
).dwRGBBitCount
= 32;
1284 U2(U4(ddsd
).ddpfPixelFormat
).dwRBitMask
= 0x00FF0000;
1285 U3(U4(ddsd
).ddpfPixelFormat
).dwGBitMask
= 0x0000FF00;
1286 U4(U4(ddsd
).ddpfPixelFormat
).dwBBitMask
= 0x000000FF;
1288 hr
= IDirectDraw7_CreateSurface(ddraw
, &ddsd
, &cubemap
, NULL
);
1289 ok(hr
== DD_OK
, "IDirectDraw7_CreateSurface returned %08x\n", hr
);
1290 IDirectDraw7_Release(ddraw
);
1293 U5(DDBltFx
).dwFillColor
= 0x00ff0000;
1294 hr
= IDirectDrawSurface7_Blt(cubemap
, NULL
, NULL
, NULL
, DDBLT_COLORFILL
, &DDBltFx
);
1295 ok(hr
== DD_OK
, "IDirectDrawSurface7_Blt returned %08x\n", hr
);
1297 memset(&caps
, 0, sizeof(caps
));
1298 caps
.dwCaps
= DDSCAPS_TEXTURE
;
1299 caps
.dwCaps2
= DDSCAPS2_CUBEMAP
| DDSCAPS2_CUBEMAP_NEGATIVEX
;
1300 hr
= IDirectDrawSurface_GetAttachedSurface(cubemap
, &caps
, &surface
);
1301 ok(hr
== DD_OK
, "IDirectDrawSurface7_Lock returned %08x\n", hr
);
1302 U5(DDBltFx
).dwFillColor
= 0x0000ffff;
1303 hr
= IDirectDrawSurface7_Blt(surface
, NULL
, NULL
, NULL
, DDBLT_COLORFILL
, &DDBltFx
);
1304 ok(hr
== DD_OK
, "IDirectDrawSurface7_Blt returned %08x\n", hr
);
1306 caps
.dwCaps2
= DDSCAPS2_CUBEMAP
| DDSCAPS2_CUBEMAP_NEGATIVEZ
;
1307 hr
= IDirectDrawSurface_GetAttachedSurface(cubemap
, &caps
, &surface
);
1308 ok(hr
== DD_OK
, "IDirectDrawSurface7_Lock returned %08x\n", hr
);
1309 U5(DDBltFx
).dwFillColor
= 0x0000ff00;
1310 hr
= IDirectDrawSurface7_Blt(surface
, NULL
, NULL
, NULL
, DDBLT_COLORFILL
, &DDBltFx
);
1311 ok(hr
== DD_OK
, "IDirectDrawSurface7_Blt returned %08x\n", hr
);
1313 caps
.dwCaps2
= DDSCAPS2_CUBEMAP
| DDSCAPS2_CUBEMAP_POSITIVEZ
;
1314 hr
= IDirectDrawSurface_GetAttachedSurface(cubemap
, &caps
, &surface
);
1315 ok(hr
== DD_OK
, "IDirectDrawSurface7_Lock returned %08x\n", hr
);
1316 U5(DDBltFx
).dwFillColor
= 0x000000ff;
1317 hr
= IDirectDrawSurface7_Blt(surface
, NULL
, NULL
, NULL
, DDBLT_COLORFILL
, &DDBltFx
);
1318 ok(hr
== DD_OK
, "IDirectDrawSurface7_Blt returned %08x\n", hr
);
1320 caps
.dwCaps2
= DDSCAPS2_CUBEMAP
| DDSCAPS2_CUBEMAP_NEGATIVEY
;
1321 hr
= IDirectDrawSurface_GetAttachedSurface(cubemap
, &caps
, &surface
);
1322 ok(hr
== DD_OK
, "IDirectDrawSurface7_Lock returned %08x\n", hr
);
1323 U5(DDBltFx
).dwFillColor
= 0x00ffff00;
1324 hr
= IDirectDrawSurface7_Blt(surface
, NULL
, NULL
, NULL
, DDBLT_COLORFILL
, &DDBltFx
);
1325 ok(hr
== DD_OK
, "IDirectDrawSurface7_Blt returned %08x\n", hr
);
1327 caps
.dwCaps2
= DDSCAPS2_CUBEMAP
| DDSCAPS2_CUBEMAP_POSITIVEY
;
1328 hr
= IDirectDrawSurface_GetAttachedSurface(cubemap
, &caps
, &surface
);
1329 ok(hr
== DD_OK
, "IDirectDrawSurface7_Lock returned %08x\n", hr
);
1330 U5(DDBltFx
).dwFillColor
= 0x00ff00ff;
1331 hr
= IDirectDrawSurface7_Blt(surface
, NULL
, NULL
, NULL
, DDBLT_COLORFILL
, &DDBltFx
);
1332 ok(hr
== DD_OK
, "IDirectDrawSurface7_Blt returned %08x\n", hr
);
1334 hr
= IDirect3DDevice7_SetTexture(device
, 0, cubemap
);
1335 ok(hr
== DD_OK
, "IDirect3DDevice7_SetTexture returned %08x\n", hr
);
1336 hr
= IDirect3DDevice7_SetTextureStageState(device
, 0, D3DTSS_COLOROP
, D3DTOP_SELECTARG1
);
1337 ok(hr
== DD_OK
, "IDirect3DDevice7_SetTextureStageState returned %08x\n", hr
);
1338 hr
= IDirect3DDevice7_SetTextureStageState(device
, 0, D3DTSS_COLORARG1
, D3DTA_TEXTURE
);
1339 ok(hr
== DD_OK
, "IDirect3DDevice7_SetTextureStageState returned %08x\n", hr
);
1341 hr
= IDirect3DDevice7_BeginScene(device
);
1342 ok(hr
== DD_OK
, "IDirect3DDevice7_BeginScene returned %08x\n", hr
);
1345 hr
= IDirect3DDevice7_DrawPrimitive(device
, D3DPT_TRIANGLESTRIP
, D3DFVF_XYZ
| D3DFVF_TEXCOORDSIZE3(0) | D3DFVF_TEX1
, quad
+ 0 * 6, 4, 0);
1346 if (hr
== DDERR_UNSUPPORTED
|| hr
== DDERR_NODIRECTDRAWHW
)
1349 win_skip("IDirect3DDevice7_DrawPrimitive is not completely implemented, colors won't be tested\n");
1350 hr
= IDirect3DDevice7_EndScene(device
);
1351 ok(hr
== DD_OK
, "IDirect3DDevice7_EndScene returned %08x\n", hr
);
1354 ok(hr
== DD_OK
, "IDirect3DDevice7_DrawPrimitive returned %08x\n", hr
);
1355 hr
= IDirect3DDevice7_DrawPrimitive(device
, D3DPT_TRIANGLESTRIP
, D3DFVF_XYZ
| D3DFVF_TEXCOORDSIZE3(0) | D3DFVF_TEX1
, quad
+ 4 * 6, 4, 0);
1356 ok(hr
== DD_OK
, "IDirect3DDevice7_DrawPrimitive returned %08x\n", hr
);
1357 hr
= IDirect3DDevice7_DrawPrimitive(device
, D3DPT_TRIANGLESTRIP
, D3DFVF_XYZ
| D3DFVF_TEXCOORDSIZE3(0) | D3DFVF_TEX1
, quad
+ 8 * 6, 4, 0);
1358 ok(hr
== DD_OK
, "IDirect3DDevice7_DrawPrimitive returned %08x\n", hr
);
1359 hr
= IDirect3DDevice7_DrawPrimitive(device
, D3DPT_TRIANGLESTRIP
, D3DFVF_XYZ
| D3DFVF_TEXCOORDSIZE3(0) | D3DFVF_TEX1
, quad
+ 12* 6, 4, 0);
1360 ok(hr
== DD_OK
, "IDirect3DDevice7_DrawPrimitive returned %08x\n", hr
);
1362 hr
= IDirect3DDevice7_EndScene(device
);
1363 ok(hr
== DD_OK
, "IDirect3DDevice7_EndScene returned %08x\n", hr
);
1365 hr
= IDirect3DDevice7_SetTextureStageState(device
, 0, D3DTSS_COLOROP
, D3DTOP_DISABLE
);
1366 ok(hr
== DD_OK
, "IDirect3DDevice7_SetTextureStageState returned %08x\n", hr
);
1368 color
= getPixelColor(device
, 160, 360); /* lower left quad - positivex */
1369 ok(color
== 0x00ff0000, "DDSCAPS2_CUBEMAP_POSITIVEX has color 0x%08x, expected 0x00ff0000\n", color
);
1370 color
= getPixelColor(device
, 160, 120); /* upper left quad - negativex */
1371 ok(color
== 0x0000ffff, "DDSCAPS2_CUBEMAP_NEGATIVEX has color 0x%08x, expected 0x0000ffff\n", color
);
1372 color
= getPixelColor(device
, 480, 360); /* lower right quad - positivey */
1373 ok(color
== 0x00ff00ff, "DDSCAPS2_CUBEMAP_POSITIVEY has color 0x%08x, expected 0x00ff00ff\n", color
);
1374 color
= getPixelColor(device
, 480, 120); /* upper right quad - positivez */
1375 ok(color
== 0x000000ff, "DDSCAPS2_CUBEMAP_POSITIVEZ has color 0x%08x, expected 0x000000ff\n", color
);
1378 hr
= IDirect3DDevice7_SetTexture(device
, 0, NULL
);
1379 ok(hr
== DD_OK
, "IDirect3DDevice7_SetTexture returned %08x\n", hr
);
1380 IDirectDrawSurface7_Release(cubemap
);
1383 /* This test tests depth clamping / clipping behaviour:
1384 * - With software vertex processing, depth values are clamped to the
1385 * minimum / maximum z value when D3DRS_CLIPPING is disabled, and clipped
1386 * when D3DRS_CLIPPING is enabled. Pretransformed vertices behave the
1387 * same as regular vertices here.
1388 * - With hardware vertex processing, D3DRS_CLIPPING seems to be ignored.
1389 * Normal vertices are always clipped. Pretransformed vertices are
1390 * clipped when D3DPMISCCAPS_CLIPTLVERTS is set, clamped when it isn't.
1391 * - The viewport's MinZ/MaxZ is irrelevant for this.
1393 static void depth_clamp_test(IDirect3DDevice7
*device
)
1397 struct vec4 position
;
1402 {{ 0.0f
, 0.0f
, 5.0f
, 1.0f
}, 0xff002b7f},
1403 {{640.0f
, 0.0f
, 5.0f
, 1.0f
}, 0xff002b7f},
1404 {{ 0.0f
, 480.0f
, 5.0f
, 1.0f
}, 0xff002b7f},
1405 {{640.0f
, 480.0f
, 5.0f
, 1.0f
}, 0xff002b7f},
1409 {{ 0.0f
, 300.0f
, 10.0f
, 1.0f
}, 0xfff9e814},
1410 {{640.0f
, 300.0f
, 10.0f
, 1.0f
}, 0xfff9e814},
1411 {{ 0.0f
, 360.0f
, 10.0f
, 1.0f
}, 0xfff9e814},
1412 {{640.0f
, 360.0f
, 10.0f
, 1.0f
}, 0xfff9e814},
1416 {{112.0f
, 108.0f
, 5.0f
, 1.0f
}, 0xffffffff},
1417 {{208.0f
, 108.0f
, 5.0f
, 1.0f
}, 0xffffffff},
1418 {{112.0f
, 204.0f
, 5.0f
, 1.0f
}, 0xffffffff},
1419 {{208.0f
, 204.0f
, 5.0f
, 1.0f
}, 0xffffffff},
1423 {{ 42.0f
, 41.0f
, 10.0f
, 1.0f
}, 0xffffffff},
1424 {{112.0f
, 41.0f
, 10.0f
, 1.0f
}, 0xffffffff},
1425 {{ 42.0f
, 108.0f
, 10.0f
, 1.0f
}, 0xffffffff},
1426 {{112.0f
, 108.0f
, 10.0f
, 1.0f
}, 0xffffffff},
1430 struct vec3 position
;
1435 {{-0.5f
, 0.5f
, 10.0f
}, 0xff14f914},
1436 {{ 0.5f
, 0.5f
, 10.0f
}, 0xff14f914},
1437 {{-0.5f
, -0.5f
, 10.0f
}, 0xff14f914},
1438 {{ 0.5f
, -0.5f
, 10.0f
}, 0xff14f914},
1442 {{-1.0f
, 0.5f
, 10.0f
}, 0xfff91414},
1443 {{ 1.0f
, 0.5f
, 10.0f
}, 0xfff91414},
1444 {{-1.0f
, 0.25f
, 10.0f
}, 0xfff91414},
1445 {{ 1.0f
, 0.25f
, 10.0f
}, 0xfff91414},
1459 hr
= IDirect3DDevice7_SetViewport(device
, &vp
);
1460 ok(SUCCEEDED(hr
), "SetViewport failed, hr %#x.\n", hr
);
1462 hr
= IDirect3DDevice7_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
| D3DCLEAR_ZBUFFER
, 0xff00ff00, 1.0, 0);
1463 ok(SUCCEEDED(hr
), "Clear failed, hr %#x.\n", hr
);
1465 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_CLIPPING
, FALSE
);
1466 ok(SUCCEEDED(hr
), "SetRenderState failed, hr %#x.\n", hr
);
1467 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_LIGHTING
, FALSE
);
1468 ok(SUCCEEDED(hr
), "SetRenderState failed, hr %#x.\n", hr
);
1469 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_ZWRITEENABLE
, TRUE
);
1470 ok(SUCCEEDED(hr
), "SetRenderState failed, hr %#x.\n", hr
);
1471 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_ZFUNC
, D3DCMP_LESSEQUAL
);
1472 ok(SUCCEEDED(hr
), "SetRenderState failed, hr %#x.\n", hr
);
1474 hr
= IDirect3DDevice7_BeginScene(device
);
1475 ok(SUCCEEDED(hr
), "BeginScene failed, hr %#x.\n", hr
);
1477 hr
= IDirect3DDevice7_DrawPrimitive(device
, D3DPT_TRIANGLESTRIP
, D3DFVF_XYZRHW
| D3DFVF_DIFFUSE
, quad1
, 4, 0);
1478 ok(SUCCEEDED(hr
), "DrawPrimitive failed, hr %#x.\n", hr
);
1479 hr
= IDirect3DDevice7_DrawPrimitive(device
, D3DPT_TRIANGLESTRIP
, D3DFVF_XYZRHW
| D3DFVF_DIFFUSE
, quad2
, 4, 0);
1480 ok(SUCCEEDED(hr
), "DrawPrimitive failed, hr %#x.\n", hr
);
1482 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_CLIPPING
, TRUE
);
1483 ok(SUCCEEDED(hr
), "SetRenderState failed, hr %#x.\n", hr
);
1485 hr
= IDirect3DDevice7_DrawPrimitive(device
, D3DPT_TRIANGLESTRIP
, D3DFVF_XYZRHW
| D3DFVF_DIFFUSE
, quad3
, 4, 0);
1486 ok(SUCCEEDED(hr
), "DrawPrimitive failed, hr %#x.\n", hr
);
1487 hr
= IDirect3DDevice7_DrawPrimitive(device
, D3DPT_TRIANGLESTRIP
, D3DFVF_XYZRHW
| D3DFVF_DIFFUSE
, quad4
, 4, 0);
1488 ok(SUCCEEDED(hr
), "DrawPrimitive failed, hr %#x.\n", hr
);
1490 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_CLIPPING
, FALSE
);
1491 ok(SUCCEEDED(hr
), "SetRenderState failed, hr %#x.\n", hr
);
1493 hr
= IDirect3DDevice7_DrawPrimitive(device
, D3DPT_TRIANGLESTRIP
, D3DFVF_XYZ
| D3DFVF_DIFFUSE
, quad5
, 4, 0);
1494 ok(SUCCEEDED(hr
), "DrawPrimitive failed, hr %#x.\n", hr
);
1496 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_CLIPPING
, TRUE
);
1497 ok(SUCCEEDED(hr
), "SetRenderState failed, hr %#x.\n", hr
);
1499 hr
= IDirect3DDevice7_DrawPrimitive(device
, D3DPT_TRIANGLESTRIP
, D3DFVF_XYZ
| D3DFVF_DIFFUSE
, quad6
, 4, 0);
1500 ok(SUCCEEDED(hr
), "DrawPrimitive failed, hr %#x.\n", hr
);
1502 hr
= IDirect3DDevice7_EndScene(device
);
1503 ok(SUCCEEDED(hr
), "EndScene failed, hr %#x.\n", hr
);
1505 color
= getPixelColor(device
, 75, 75);
1506 ok(color_match(color
, 0x00ffffff, 1) || color_match(color
, 0x0000ff00, 1), "color 0x%08x.\n", color
);
1507 color
= getPixelColor(device
, 150, 150);
1508 ok(color_match(color
, 0x00ffffff, 1) || color_match(color
, 0x0000ff00, 1), "color 0x%08x.\n", color
);
1509 color
= getPixelColor(device
, 320, 240);
1510 ok(color_match(color
, 0x00002b7f, 1) || color_match(color
, 0x0000ff00, 1), "color 0x%08x.\n", color
);
1511 color
= getPixelColor(device
, 320, 330);
1512 ok(color_match(color
, 0x00f9e814, 1) || color_match(color
, 0x0000ff00, 1), "color 0x%08x.\n", color
);
1513 color
= getPixelColor(device
, 320, 330);
1514 ok(color_match(color
, 0x00f9e814, 1) || color_match(color
, 0x0000ff00, 1), "color 0x%08x.\n", color
);
1518 hr
= IDirect3DDevice7_SetViewport(device
, &vp
);
1519 ok(SUCCEEDED(hr
), "SetViewport failed, hr %#x.\n", hr
);
1522 static void DX1_BackBufferFlipTest(void)
1525 IDirectDraw
*DirectDraw1
= NULL
;
1526 IDirectDrawSurface
*Primary
= NULL
;
1527 IDirectDrawSurface
*Backbuffer
= NULL
;
1532 const DWORD white
= 0xffffff;
1533 const DWORD red
= 0xff0000;
1534 BOOL attached
= FALSE
;
1536 wc
.lpfnWndProc
= DefWindowProcA
;
1537 wc
.lpszClassName
= "DX1_BackBufferFlipTest_wc";
1538 RegisterClassA(&wc
);
1539 window
= CreateWindowA("DX1_BackBufferFlipTest_wc", "DX1_BackBufferFlipTest",
1540 WS_MAXIMIZE
| WS_VISIBLE
| WS_CAPTION
, 0, 0, 640, 480, 0, 0, 0, 0);
1542 hr
= DirectDrawCreate( NULL
, &DirectDraw1
, NULL
);
1543 ok(hr
==DD_OK
|| hr
==DDERR_NODIRECTDRAWSUPPORT
, "DirectDrawCreate returned: %x\n", hr
);
1544 if(FAILED(hr
)) goto out
;
1546 hr
= IDirectDraw_SetCooperativeLevel(DirectDraw1
, window
, DDSCL_EXCLUSIVE
| DDSCL_FULLSCREEN
);
1547 ok(hr
==DD_OK
, "SetCooperativeLevel returned: %x\n", hr
);
1548 if(FAILED(hr
)) goto out
;
1550 hr
= IDirectDraw_SetDisplayMode(DirectDraw1
, 640, 480, 32);
1552 /* 24 bit is fine too */
1553 hr
= IDirectDraw_SetDisplayMode(DirectDraw1
, 640, 480, 24);
1555 ok(hr
==DD_OK
|| hr
== DDERR_UNSUPPORTED
, "SetDisplayMode returned: %x\n", hr
);
1560 memset(&ddsd
, 0, sizeof(DDSURFACEDESC
));
1561 ddsd
.dwSize
= sizeof(DDSURFACEDESC
);
1562 ddsd
.dwFlags
= DDSD_CAPS
;
1563 ddsd
.ddsCaps
.dwCaps
= DDSCAPS_PRIMARYSURFACE
;
1565 hr
= IDirectDraw_CreateSurface(DirectDraw1
, &ddsd
, &Primary
, NULL
);
1566 ok(hr
==DD_OK
, "IDirectDraw_CreateSurface returned: %08x\n", hr
);
1568 memset(&ddsd
, 0, sizeof(DDSURFACEDESC
));
1569 ddsd
.dwSize
= sizeof(DDSURFACEDESC
);
1570 ddsd
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PIXELFORMAT
;
1571 ddsd
.ddsCaps
.dwCaps
= DDSCAPS_BACKBUFFER
;
1573 ddsd
.dwHeight
= 480;
1574 ddsd
.ddpfPixelFormat
.dwSize
= sizeof(ddsd
.ddpfPixelFormat
);
1575 ddsd
.ddpfPixelFormat
.dwFlags
= DDPF_RGB
;
1576 U1(ddsd
.ddpfPixelFormat
).dwRGBBitCount
= 32;
1577 U2(ddsd
.ddpfPixelFormat
).dwRBitMask
= 0x00ff0000;
1578 U3(ddsd
.ddpfPixelFormat
).dwGBitMask
= 0x0000ff00;
1579 U4(ddsd
.ddpfPixelFormat
).dwBBitMask
= 0x000000ff;
1581 hr
= IDirectDraw_CreateSurface(DirectDraw1
, &ddsd
, &Backbuffer
, NULL
);
1582 ok(hr
==DD_OK
, "IDirectDraw_CreateSurface returned: %08x\n", hr
);
1583 if(FAILED(hr
)) goto out
;
1585 hr
= IDirectDrawSurface_AddAttachedSurface(Primary
, Backbuffer
);
1586 todo_wine
ok(hr
== DD_OK
|| broken(hr
== DDERR_CANNOTATTACHSURFACE
),
1587 "Attaching a back buffer to a front buffer returned %08x\n", hr
);
1588 if (FAILED(hr
)) goto out
;
1592 memset(&ddbltfx
, 0, sizeof(ddbltfx
));
1593 ddbltfx
.dwSize
= sizeof(ddbltfx
);
1594 U5(ddbltfx
).dwFillColor
= red
;
1595 hr
= IDirectDrawSurface_Blt(Backbuffer
, NULL
, NULL
, NULL
, DDBLT_COLORFILL
| DDBLT_WAIT
, &ddbltfx
);
1596 ok(hr
== DD_OK
, "IDirectDrawSurface_Blt returned: %x\n", hr
);
1598 U5(ddbltfx
).dwFillColor
= white
;
1599 hr
= IDirectDrawSurface_Blt(Primary
, NULL
, NULL
, NULL
, DDBLT_COLORFILL
| DDBLT_WAIT
, &ddbltfx
);
1600 ok(hr
== DD_OK
, "IDirectDrawSurface_Blt returned: %x\n", hr
);
1603 color
= getPixelColor_GDI(Primary
, 5, 5);
1604 ok(GetRValue(color
) == 0xFF && GetGValue(color
) == 0xFF && GetBValue(color
) == 0xFF,
1605 "got R %02X G %02X B %02X, expected R FF G FF B FF\n",
1606 GetRValue(color
), GetGValue(color
), GetBValue(color
));
1608 color
= getPixelColor_GDI(Backbuffer
, 5, 5);
1609 ok(GetRValue(color
) == 0xFF && GetGValue(color
) == 0 && GetBValue(color
) == 0,
1610 "got R %02X G %02X B %02X, expected R FF G 00 B 00\n",
1611 GetRValue(color
), GetGValue(color
), GetBValue(color
));
1613 hr
= IDirectDrawSurface_Flip(Primary
, NULL
, DDFLIP_WAIT
);
1614 todo_wine
ok(hr
== DD_OK
, "IDirectDrawSurface_Flip returned 0x%08x\n", hr
);
1618 color
= getPixelColor_GDI(Primary
, 5, 5);
1619 ok(GetRValue(color
) == 0xFF && GetGValue(color
) == 0 && GetBValue(color
) == 0,
1620 "got R %02X G %02X B %02X, expected R FF G 00 B 00\n",
1621 GetRValue(color
), GetGValue(color
), GetBValue(color
));
1623 color
= getPixelColor_GDI(Backbuffer
, 5, 5);
1624 ok((GetRValue(color
) == 0xFF && GetGValue(color
) == 0xFF && GetBValue(color
) == 0xFF) ||
1625 broken(GetRValue(color
) == 0xFF && GetGValue(color
) == 0 && GetBValue(color
) == 0), /* broken driver */
1626 "got R %02X G %02X B %02X, expected R FF G FF B FF\n",
1627 GetRValue(color
), GetGValue(color
), GetBValue(color
));
1635 IDirectDrawSurface_DeleteAttachedSurface(Primary
, 0, Backbuffer
);
1636 IDirectDrawSurface_Release(Backbuffer
);
1638 if (Primary
) IDirectDrawSurface_Release(Primary
);
1639 if (DirectDraw1
) IDirectDraw_Release(DirectDraw1
);
1640 if (window
) DestroyWindow(window
);
1647 if(!createObjects())
1649 skip("Cannot initialize DirectDraw and Direct3D, skipping\n");
1653 /* Check for the reliability of the returned data */
1654 hr
= IDirect3DDevice7_Clear(Direct3DDevice
, 0, NULL
, D3DCLEAR_TARGET
, 0xffff0000, 0.0, 0);
1657 skip("Clear failed, can't assure correctness of the test results, skipping\n");
1661 color
= getPixelColor(Direct3DDevice
, 1, 1);
1662 if(color
!=0x00ff0000)
1664 skip("Sanity check returned an incorrect color(%08x), can't assure the correctness of the tests, skipping\n", color
);
1668 hr
= IDirect3DDevice7_Clear(Direct3DDevice
, 0, NULL
, D3DCLEAR_TARGET
, 0xff00ddee, 0.0, 0);
1671 skip("Clear failed, can't assure correctness of the test results, skipping\n");
1675 color
= getPixelColor(Direct3DDevice
, 639, 479);
1676 if(color
!= 0x0000ddee)
1678 skip("Sanity check returned an incorrect color(%08x), can't assure the correctness of the tests, skipping\n", color
);
1682 /* Now run the tests */
1683 depth_clamp_test(Direct3DDevice
);
1684 clear_test(Direct3DDevice
);
1685 fog_test(Direct3DDevice
);
1686 offscreen_test(Direct3DDevice
);
1687 test_blend(Direct3DDevice
);
1688 rhw_zero_test(Direct3DDevice
);
1689 cubemap_test(Direct3DDevice
);
1691 releaseObjects(); /* release DX7 interfaces to test D3D1 */
1693 D3D3_ViewportClearTest();
1694 DX1_BackBufferFlipTest();