2 * Copyright (C) 2007 Stefan Dösinger(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
19 /* See comment in dlls/d3d9/tests/visual.c for general guidelines */
22 #include "wine/test.h"
27 IDirectDraw7
*DirectDraw
= NULL
;
28 IDirectDrawSurface7
*Surface
;
29 IDirect3D7
*Direct3D
= NULL
;
30 IDirect3DDevice7
*Direct3DDevice
= NULL
;
32 static HRESULT (WINAPI
*pDirectDrawCreateEx
)(LPGUID
,LPVOID
*,REFIID
,LPUNKNOWN
);
34 static BOOL
createObjects(void)
37 HMODULE hmod
= GetModuleHandleA("ddraw.dll");
42 if(!hmod
) return FALSE
;
43 pDirectDrawCreateEx
= (void*)GetProcAddress(hmod
, "DirectDrawCreateEx");
44 if(!pDirectDrawCreateEx
) return FALSE
;
46 hr
= pDirectDrawCreateEx(NULL
, (void **) &DirectDraw
, &IID_IDirectDraw7
, NULL
);
47 ok(hr
==DD_OK
|| hr
==DDERR_NODIRECTDRAWSUPPORT
, "DirectDrawCreateEx returned: %x\n", hr
);
48 if(!DirectDraw
) goto err
;
50 wc
.lpfnWndProc
= &DefWindowProc
;
51 wc
.lpszClassName
= "d3d7_test_wc";
53 window
= CreateWindow("d3d7_test_wc", "d3d7_test", WS_MAXIMIZE
| WS_VISIBLE
| WS_CAPTION
, 0, 0, 640, 480, 0, 0, 0, 0);
55 hr
= IDirectDraw7_SetCooperativeLevel(DirectDraw
, window
, DDSCL_EXCLUSIVE
| DDSCL_FULLSCREEN
);
56 ok(hr
== DD_OK
, "IDirectDraw7_SetCooperativeLevel failed with %08x\n", hr
);
57 if(FAILED(hr
)) goto err
;
58 hr
= IDirectDraw7_SetDisplayMode(DirectDraw
, 640, 480, 32, 0, 0);
60 /* 24 bit is fine too */
61 hr
= IDirectDraw7_SetDisplayMode(DirectDraw
, 640, 480, 24, 0, 0);
64 ok(hr
== DD_OK
, "IDirectDraw7_SetDisplayMode failed with %08x\n", hr
);
65 if(FAILED(hr
)) goto err
;
67 hr
= IDirectDraw7_QueryInterface(DirectDraw
, &IID_IDirect3D7
, (void**) &Direct3D
);
68 if (hr
== E_NOINTERFACE
) goto err
;
69 ok(hr
==DD_OK
, "QueryInterface returned: %08x\n", hr
);
71 /* DirectDraw Flipping behavior doesn't seem that well-defined. The reference rasterizer behaves differently
72 * than hardware implementations. Request single buffering, that seems to work everywhere
74 memset(&ddsd
, 0, sizeof(ddsd
));
75 ddsd
.dwSize
= sizeof(ddsd
);
76 ddsd
.dwFlags
= DDSD_CAPS
;
77 ddsd
.ddsCaps
.dwCaps
= DDSCAPS_PRIMARYSURFACE
| DDSCAPS_3DDEVICE
;
78 ddsd
.dwBackBufferCount
= 1;
79 hr
= IDirectDraw7_CreateSurface(DirectDraw
, &ddsd
, &Surface
, NULL
);
80 ok(hr
==DD_OK
, "CreateSurface returned: %08x\n", hr
);
81 if(!Surface
) goto err
;
83 hr
= IDirect3D7_CreateDevice(Direct3D
, &IID_IDirect3DTnLHalDevice
, Surface
, &Direct3DDevice
);
86 trace("Creating a TnLHal Device failed, trying HAL\n");
87 hr
= IDirect3D7_CreateDevice(Direct3D
, &IID_IDirect3DHALDevice
, Surface
, &Direct3DDevice
);
90 trace("Creating a HAL device failed, trying Ref\n");
91 hr
= IDirect3D7_CreateDevice(Direct3D
, &IID_IDirect3DRefDevice
, Surface
, &Direct3DDevice
);
94 ok(hr
== D3D_OK
, "IDirect3D7_CreateDevice failed with %08x\n", hr
);
95 if(!Direct3DDevice
) goto err
;
99 if(DirectDraw
) IDirectDraw7_Release(DirectDraw
);
100 if(Surface
) IDirectDrawSurface7_Release(Surface
);
101 if(Direct3D
) IDirect3D7_Release(Direct3D
);
102 if(Direct3DDevice
) IDirect3DDevice7_Release(Direct3DDevice
);
103 if(window
) DestroyWindow(window
);
107 static void releaseObjects(void)
109 IDirect3DDevice7_Release(Direct3DDevice
);
110 IDirect3D7_Release(Direct3D
);
111 IDirectDrawSurface7_Release(Surface
);
112 IDirectDraw7_Release(DirectDraw
);
113 DestroyWindow(window
);
116 static DWORD
getPixelColor(IDirect3DDevice7
*device
, UINT x
, UINT y
)
121 RECT rectToLock
= {x
, y
, x
+1, y
+1};
122 IDirectDrawSurface7
*surf
= NULL
;
124 /* Some implementations seem to dislike direct locking on the front buffer. Thus copy the front buffer
125 * to an offscreen surface and lock it instead of the front buffer
127 memset(&ddsd
, 0, sizeof(ddsd
));
128 ddsd
.dwSize
= sizeof(ddsd
);
129 U4(ddsd
).ddpfPixelFormat
.dwSize
= sizeof(U4(ddsd
).ddpfPixelFormat
);
130 ddsd
.dwFlags
= DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_CAPS
;
133 ddsd
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_SYSTEMMEMORY
;
134 hr
= IDirectDraw7_CreateSurface(DirectDraw
, &ddsd
, &surf
, NULL
);
135 ok(hr
== DD_OK
, "IDirectDraw7_CreateSurface failed with %08x\n", hr
);
138 trace("cannot create helper surface\n");
142 memset(&ddsd
, 0, sizeof(ddsd
));
143 ddsd
.dwSize
= sizeof(ddsd
);
144 U4(ddsd
).ddpfPixelFormat
.dwSize
= sizeof(U4(ddsd
).ddpfPixelFormat
);
146 hr
= IDirectDrawSurface_BltFast(surf
, 0, 0, Surface
, NULL
, 0);
147 ok(hr
== DD_OK
, "IDirectDrawSurface7_BltFast returned %08x\n", hr
);
150 trace("Cannot blit\n");
155 hr
= IDirectDrawSurface7_Lock(surf
, &rectToLock
, &ddsd
, DDLOCK_READONLY
| DDLOCK_WAIT
, NULL
);
158 trace("Can't lock the offscreen surface, hr=%08x\n", hr
);
163 /* Remove the X channel for now. DirectX and OpenGL have different ideas how to treat it apparently, and it isn't
164 * really important for these tests
166 ret
= ((DWORD
*) ddsd
.lpSurface
)[0] & 0x00ffffff;
167 hr
= IDirectDrawSurface7_Unlock(surf
, &rectToLock
);
170 trace("Can't unlock the offscreen surface, hr=%08x\n", hr
);
174 IDirectDrawSurface7_Release(surf
);
191 static void lighting_test(IDirect3DDevice7
*device
)
194 DWORD fvf
= D3DFVF_XYZ
| D3DFVF_DIFFUSE
;
195 DWORD nfvf
= D3DFVF_XYZ
| D3DFVF_DIFFUSE
| D3DFVF_NORMAL
;
198 float mat
[16] = { 1.0f
, 0.0f
, 0.0f
, 0.0f
,
199 0.0f
, 1.0f
, 0.0f
, 0.0f
,
200 0.0f
, 0.0f
, 1.0f
, 0.0f
,
201 0.0f
, 0.0f
, 0.0f
, 1.0f
};
203 struct vertex unlitquad
[] =
205 {-1.0f
, -1.0f
, 0.1f
, 0xffff0000},
206 {-1.0f
, 0.0f
, 0.1f
, 0xffff0000},
207 { 0.0f
, 0.0f
, 0.1f
, 0xffff0000},
208 { 0.0f
, -1.0f
, 0.1f
, 0xffff0000},
210 struct vertex litquad
[] =
212 {-1.0f
, 0.0f
, 0.1f
, 0xff00ff00},
213 {-1.0f
, 1.0f
, 0.1f
, 0xff00ff00},
214 { 0.0f
, 1.0f
, 0.1f
, 0xff00ff00},
215 { 0.0f
, 0.0f
, 0.1f
, 0xff00ff00},
217 struct nvertex unlitnquad
[] =
219 { 0.0f
, -1.0f
, 0.1f
, 1.0f
, 1.0f
, 1.0f
, 0xff0000ff},
220 { 0.0f
, 0.0f
, 0.1f
, 1.0f
, 1.0f
, 1.0f
, 0xff0000ff},
221 { 1.0f
, 0.0f
, 0.1f
, 1.0f
, 1.0f
, 1.0f
, 0xff0000ff},
222 { 1.0f
, -1.0f
, 0.1f
, 1.0f
, 1.0f
, 1.0f
, 0xff0000ff},
224 struct nvertex litnquad
[] =
226 { 0.0f
, 0.0f
, 0.1f
, 1.0f
, 1.0f
, 1.0f
, 0xffffff00},
227 { 0.0f
, 1.0f
, 0.1f
, 1.0f
, 1.0f
, 1.0f
, 0xffffff00},
228 { 1.0f
, 1.0f
, 0.1f
, 1.0f
, 1.0f
, 1.0f
, 0xffffff00},
229 { 1.0f
, 0.0f
, 0.1f
, 1.0f
, 1.0f
, 1.0f
, 0xffffff00},
231 WORD Indices
[] = {0, 1, 2, 2, 3, 0};
233 hr
= IDirect3DDevice7_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
, 0xffffffff, 0.0, 0);
234 ok(hr
== D3D_OK
, "IDirect3DDevice7_Clear failed with %08x\n", hr
);
236 /* Setup some states that may cause issues */
237 hr
= IDirect3DDevice7_SetTransform(device
, D3DTRANSFORMSTATE_WORLD
, (D3DMATRIX
*) mat
);
238 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetTransform returned %08x\n", hr
);
239 hr
= IDirect3DDevice7_SetTransform(device
, D3DTRANSFORMSTATE_VIEW
, (D3DMATRIX
*)mat
);
240 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetTransform returned %08x\n", hr
);
241 hr
= IDirect3DDevice7_SetTransform(device
, D3DTRANSFORMSTATE_PROJECTION
, (D3DMATRIX
*) mat
);
242 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetTransform returned %08x\n", hr
);
243 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_CLIPPING
, FALSE
);
244 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetRenderState returned %08x\n", hr
);
245 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_ZENABLE
, FALSE
);
246 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetRenderState returned %08x\n", hr
);
247 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_FOGENABLE
, FALSE
);
248 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetRenderState returned %08x\n", hr
);
249 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_STENCILENABLE
, FALSE
);
250 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetRenderState returned %08x\n", hr
);
251 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_ALPHATESTENABLE
, FALSE
);
252 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetRenderState returned %08x\n", hr
);
253 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_ALPHABLENDENABLE
, FALSE
);
254 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetRenderState returned %08x\n", hr
);
255 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_CULLMODE
, D3DCULL_NONE
);
256 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetRenderState failed with %08x\n", hr
);
258 hr
= IDirect3DDevice7_BeginScene(device
);
259 ok(hr
== D3D_OK
, "IDirect3DDevice7_BeginScene failed with %08x\n", hr
);
262 /* No lights are defined... That means, lit vertices should be entirely black */
263 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_LIGHTING
, FALSE
);
264 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetRenderState returned %08x\n", hr
);
265 hr
= IDirect3DDevice7_DrawIndexedPrimitive(device
, D3DPT_TRIANGLELIST
, fvf
, unlitquad
, 4 /* NumVerts */,
266 Indices
, 6 /* Indexcount */, 0 /* flags */);
267 ok(hr
== D3D_OK
, "IDirect3DDevice7_DrawIndexedPrimitiveUP failed with %08x\n", hr
);
269 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_LIGHTING
, TRUE
);
270 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetRenderState returned %08x\n", hr
);
271 hr
= IDirect3DDevice7_DrawIndexedPrimitive(device
, D3DPT_TRIANGLELIST
, fvf
, litquad
, 4 /* NumVerts */,
272 Indices
, 6 /* Indexcount */, 0 /* flags */);
273 ok(hr
== D3D_OK
, "IDirect3DDevice7_DrawIndexedPrimitiveUP failed with %08x\n", hr
);
275 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_LIGHTING
, FALSE
);
276 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetRenderState returned %08x\n", hr
);
277 hr
= IDirect3DDevice7_DrawIndexedPrimitive(device
, D3DPT_TRIANGLELIST
, nfvf
, unlitnquad
, 4 /* NumVerts */,
278 Indices
, 6 /* Indexcount */, 0 /* flags */);
279 ok(hr
== D3D_OK
, "IDirect3DDevice7_DrawIndexedPrimitiveUP failed with %08x\n", hr
);
281 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_LIGHTING
, TRUE
);
282 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetRenderState returned %08x\n", hr
);
283 hr
= IDirect3DDevice7_DrawIndexedPrimitive(device
, D3DPT_TRIANGLELIST
, nfvf
, litnquad
, 4 /* NumVerts */,
284 Indices
, 6 /* Indexcount */, 0 /* flags */);
285 ok(hr
== D3D_OK
, "IDirect3DDevice7_DrawIndexedPrimitiveUP failed with %08x\n", hr
);
287 IDirect3DDevice7_EndScene(device
);
288 ok(hr
== D3D_OK
, "IDirect3DDevice7_EndScene failed with %08x\n", hr
);
291 color
= getPixelColor(device
, 160, 360); /* lower left quad - unlit without normals */
292 ok(color
== 0x00ff0000, "Unlit quad without normals has color %08x\n", color
);
293 color
= getPixelColor(device
, 160, 120); /* upper left quad - lit without normals */
294 ok(color
== 0x00000000, "Lit quad without normals has color %08x\n", color
);
295 color
= getPixelColor(device
, 480, 360); /* lower left quad - unlit width normals */
296 ok(color
== 0x000000ff, "Unlit quad width normals has color %08x\n", color
);
297 color
= getPixelColor(device
, 480, 120); /* upper left quad - lit width normals */
298 ok(color
== 0x00000000, "Lit quad width normals has color %08x\n", color
);
300 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_LIGHTING
, FALSE
);
301 ok(hr
== D3D_OK
, "IDirect3DDevice7_SetRenderState returned %08x\n", hr
);
304 static void clear_test(IDirect3DDevice7
*device
)
306 /* Tests the correctness of clearing parameters */
312 hr
= IDirect3DDevice7_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
, 0xffffffff, 0.0, 0);
313 ok(hr
== D3D_OK
, "IDirect3DDevice7_Clear failed with %08x\n", hr
);
315 /* Positive x, negative y */
317 U2(rect
[0]).y1
= 480;
318 U3(rect
[0]).x2
= 320;
319 U4(rect
[0]).y2
= 240;
321 /* Positive x, positive y */
324 U3(rect
[1]).x2
= 320;
325 U4(rect
[1]).y2
= 240;
326 /* Clear 2 rectangles with one call. Shows that a positive value is returned, but the negative rectangle
327 * is ignored, the positive is still cleared afterwards
329 hr
= IDirect3DDevice7_Clear(device
, 2, rect
, D3DCLEAR_TARGET
, 0xffff0000, 0.0, 0);
330 ok(hr
== D3D_OK
, "IDirect3DDevice7_Clear failed with %08x\n", hr
);
332 /* negative x, negative y */
333 U1(rect_negneg
).x1
= 640;
334 U2(rect_negneg
).y1
= 240;
335 U3(rect_negneg
).x2
= 320;
336 U4(rect_negneg
).y2
= 0;
337 hr
= IDirect3DDevice7_Clear(device
, 1, &rect_negneg
, D3DCLEAR_TARGET
, 0xff00ff00, 0.0, 0);
338 ok(hr
== D3D_OK
, "IDirect3DDevice7_Clear failed with %08x\n", hr
);
340 color
= getPixelColor(device
, 160, 360); /* lower left quad */
341 ok(color
== 0x00ffffff, "Clear rectangle 3(pos, neg) has color %08x\n", color
);
342 color
= getPixelColor(device
, 160, 120); /* upper left quad */
343 ok(color
== 0x00ff0000, "Clear rectangle 1(pos, pos) has color %08x\n", color
);
344 color
= getPixelColor(device
, 480, 360); /* lower right quad */
345 ok(color
== 0x00ffffff, "Clear rectangle 4(NULL) has color %08x\n", color
);
346 color
= getPixelColor(device
, 480, 120); /* upper right quad */
347 ok(color
== 0x00ffffff, "Clear rectangle 4(neg, neg) has color %08x\n", color
);
362 static void fog_test(IDirect3DDevice7
*device
)
366 float start
= 0.0, end
= 1.0;
368 /* Gets full z based fog with linear fog, no fog with specular color */
369 struct sVertex unstransformed_1
[] = {
370 {-1, -1, 0.1f
, 0xFFFF0000, 0xFF000000 },
371 {-1, 0, 0.1f
, 0xFFFF0000, 0xFF000000 },
372 { 0, 0, 0.1f
, 0xFFFF0000, 0xFF000000 },
373 { 0, -1, 0.1f
, 0xFFFF0000, 0xFF000000 },
375 /* Ok, I am too lazy to deal with transform matrices */
376 struct sVertex unstransformed_2
[] = {
377 {-1, 0, 1.0f
, 0xFFFF0000, 0xFF000000 },
378 {-1, 1, 1.0f
, 0xFFFF0000, 0xFF000000 },
379 { 0, 1, 1.0f
, 0xFFFF0000, 0xFF000000 },
380 { 0, 0, 1.0f
, 0xFFFF0000, 0xFF000000 },
382 /* Untransformed ones. Give them a different diffuse color to make the test look
383 * nicer. It also makes making sure that they are drawn correctly easier.
385 struct sVertexT transformed_1
[] = {
386 {320, 0, 1.0f
, 1.0f
, 0xFFFFFF00, 0xFF000000 },
387 {640, 0, 1.0f
, 1.0f
, 0xFFFFFF00, 0xFF000000 },
388 {640, 240, 1.0f
, 1.0f
, 0xFFFFFF00, 0xFF000000 },
389 {320, 240, 1.0f
, 1.0f
, 0xFFFFFF00, 0xFF000000 },
391 struct sVertexT transformed_2
[] = {
392 {320, 240, 1.0f
, 1.0f
, 0xFFFFFF00, 0xFF000000 },
393 {640, 240, 1.0f
, 1.0f
, 0xFFFFFF00, 0xFF000000 },
394 {640, 480, 1.0f
, 1.0f
, 0xFFFFFF00, 0xFF000000 },
395 {320, 480, 1.0f
, 1.0f
, 0xFFFFFF00, 0xFF000000 },
397 WORD Indices
[] = {0, 1, 2, 2, 3, 0};
399 hr
= IDirect3DDevice7_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
, 0xffff00ff, 0.0, 0);
400 ok(hr
== D3D_OK
, "IDirect3DDevice7_Clear returned %08x\n", hr
);
402 /* Setup initial states: No lighting, fog on, fog color */
403 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_LIGHTING
, FALSE
);
404 ok(hr
== D3D_OK
, "Turning off lighting returned %08x\n", hr
);
405 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_FOGENABLE
, TRUE
);
406 ok(hr
== D3D_OK
, "Turning on fog calculations returned %08x\n", hr
);
407 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_FOGCOLOR
, 0xFF00FF00 /* A nice green */);
408 ok(hr
== D3D_OK
, "Turning on fog calculations returned %08x\n", hr
);
410 /* First test: Both table fog and vertex fog off */
411 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_FOGTABLEMODE
, D3DFOG_NONE
);
412 ok(hr
== D3D_OK
, "Turning off table fog returned %08x\n", hr
);
413 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_FOGVERTEXMODE
, D3DFOG_NONE
);
414 ok(hr
== D3D_OK
, "Turning off table fog returned %08x\n", hr
);
416 /* Start = 0, end = 1. Should be default, but set them */
417 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_FOGSTART
, *((DWORD
*) &start
));
418 ok(hr
== D3D_OK
, "Setting fog start returned %08x\n", hr
);
419 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_FOGEND
, *((DWORD
*) &end
));
420 ok(hr
== D3D_OK
, "Setting fog start returned %08x\n", hr
);
422 if(IDirect3DDevice7_BeginScene(device
) == D3D_OK
)
424 /* Untransformed, vertex fog = NONE, table fog = NONE: Read the fog weighting from the specular color */
425 hr
= IDirect3DDevice7_DrawIndexedPrimitive(device
, D3DPT_TRIANGLELIST
, D3DFVF_XYZ
| D3DFVF_DIFFUSE
| D3DFVF_SPECULAR
,
426 unstransformed_1
, 4, Indices
, 6, 0);
427 ok(hr
== D3D_OK
, "DrawIndexedPrimitive returned %08x\n", hr
);
429 /* That makes it use the Z value */
430 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_FOGVERTEXMODE
, D3DFOG_LINEAR
);
431 ok(hr
== D3D_OK
, "Turning off table fog returned %08x\n", hr
);
432 /* Untransformed, vertex fog != none (or table fog != none):
433 * Use the Z value as input into the equation
435 hr
= IDirect3DDevice7_DrawIndexedPrimitive(device
, D3DPT_TRIANGLELIST
, D3DFVF_XYZ
| D3DFVF_DIFFUSE
| D3DFVF_SPECULAR
,
436 unstransformed_2
, 4, Indices
, 6, 0);
437 ok(hr
== D3D_OK
, "DrawIndexedPrimitive returned %08x\n", hr
);
439 /* transformed verts */
440 ok( hr
== D3D_OK
, "SetFVF returned %08x\n", hr
);
441 /* Transformed, vertex fog != NONE, pixel fog == NONE: Use specular color alpha component */
442 hr
= IDirect3DDevice7_DrawIndexedPrimitive(device
, D3DPT_TRIANGLELIST
, D3DFVF_XYZRHW
| D3DFVF_DIFFUSE
| D3DFVF_SPECULAR
,
443 transformed_1
, 4, Indices
, 6, 0);
444 ok(hr
== D3D_OK
, "DrawIndexedPrimitive returned %08x\n", hr
);
446 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_FOGTABLEMODE
, D3DFOG_LINEAR
);
447 ok( hr
== D3D_OK
, "Setting fog table mode to D3DFOG_LINEAR returned %08x\n", hr
);
448 /* Transformed, table fog != none, vertex anything: Use Z value as input to the fog
451 hr
= IDirect3DDevice7_DrawIndexedPrimitive(device
, D3DPT_TRIANGLELIST
, D3DFVF_XYZRHW
| D3DFVF_DIFFUSE
| D3DFVF_SPECULAR
,
452 transformed_2
, 4, Indices
, 6, 0);
453 ok(hr
== D3D_OK
, "DrawIndexedPrimitive returned %08x\n", hr
);
455 hr
= IDirect3DDevice7_EndScene(device
);
456 ok(hr
== D3D_OK
, "EndScene returned %08x\n", hr
);
460 ok(FALSE
, "BeginScene failed\n");
463 color
= getPixelColor(device
, 160, 360);
464 ok(color
== 0x00FF0000, "Untransformed vertex with no table or vertex fog has color %08x\n", color
);
465 color
= getPixelColor(device
, 160, 120);
466 ok(color
== 0x0000FF00, "Untransformed vertex with linear vertex fog has color %08x\n", color
);
467 color
= getPixelColor(device
, 480, 120);
468 ok(color
== 0x00FFFF00, "Transformed vertex with linear vertex fog has color %08x\n", color
);
469 color
= getPixelColor(device
, 480, 360);
470 ok(color
== 0x0000FF00, "Transformed vertex with linear table fog has color %08x\n", color
);
472 /* Turn off the fog master switch to avoid confusing other tests */
473 hr
= IDirect3DDevice7_SetRenderState(device
, D3DRENDERSTATE_FOGENABLE
, FALSE
);
474 ok(hr
== D3D_OK
, "Turning off fog calculations returned %08x\n", hr
);
483 skip("Cannot initialize DirectDraw and Direct3D, skipping\n");
487 /* Check for the reliability of the returned data */
488 hr
= IDirect3DDevice7_Clear(Direct3DDevice
, 0, NULL
, D3DCLEAR_TARGET
, 0xffff0000, 0.0, 0);
491 trace("Clear failed, can't assure correctness of the test results, skipping\n");
495 color
= getPixelColor(Direct3DDevice
, 1, 1);
496 if(color
!=0x00ff0000)
498 trace("Sanity check returned an incorrect color(%08x), can't assure the correctness of the tests, skipping\n", color
);
502 hr
= IDirect3DDevice7_Clear(Direct3DDevice
, 0, NULL
, D3DCLEAR_TARGET
, 0xff00ddee, 0.0, 0);
505 trace("Clear failed, can't assure correctness of the test results, skipping\n");
509 color
= getPixelColor(Direct3DDevice
, 639, 479);
510 if(color
!= 0x0000ddee)
512 trace("Sanity check returned an incorrect color(%08x), can't assure the correctness of the tests, skipping\n", color
);
516 /* Now run the tests */
517 lighting_test(Direct3DDevice
);
518 clear_test(Direct3DDevice
);
519 fog_test(Direct3DDevice
);