~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/ddraw/tests/visual.c

Version: ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /*
  2  * Copyright (C) 2007 Stefan Dösinger(for CodeWeavers)
  3  * Copyright (C) 2008 Alexander Dorofeyev
  4  *
  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.
  9  *
 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.
 14  *
 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
 18  */
 19 
 20 /* See comment in dlls/d3d9/tests/visual.c for general guidelines */
 21 
 22 #include <assert.h>
 23 #include "wine/test.h"
 24 #include "ddraw.h"
 25 #include "d3d.h"
 26 
 27 HWND window;
 28 IDirectDraw7        *DirectDraw = NULL;
 29 IDirectDrawSurface7 *Surface;
 30 IDirect3D7          *Direct3D = NULL;
 31 IDirect3DDevice7    *Direct3DDevice = NULL;
 32 
 33 IDirectDraw *DirectDraw1 = NULL;
 34 IDirectDrawSurface *Surface1 = NULL;
 35 IDirect3D *Direct3D1 = NULL;
 36 IDirect3DDevice *Direct3DDevice1 = NULL;
 37 IDirect3DExecuteBuffer *ExecuteBuffer = NULL;
 38 IDirect3DViewport *Viewport = NULL;
 39 
 40 static HRESULT (WINAPI *pDirectDrawCreateEx)(LPGUID,LPVOID*,REFIID,LPUNKNOWN);
 41 
 42 static BOOL createObjects(void)
 43 {
 44     HRESULT hr;
 45     HMODULE hmod = GetModuleHandleA("ddraw.dll");
 46     WNDCLASS wc = {0};
 47     DDSURFACEDESC2 ddsd;
 48 
 49 
 50     if(!hmod) return FALSE;
 51     pDirectDrawCreateEx = (void*)GetProcAddress(hmod, "DirectDrawCreateEx");
 52     if(!pDirectDrawCreateEx) return FALSE;
 53 
 54     hr = pDirectDrawCreateEx(NULL, (void **) &DirectDraw, &IID_IDirectDraw7, NULL);
 55     ok(hr==DD_OK || hr==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %x\n", hr);
 56     if(!DirectDraw) goto err;
 57 
 58     wc.lpfnWndProc = DefWindowProc;
 59     wc.lpszClassName = "d3d7_test_wc";
 60     RegisterClass(&wc);
 61     window = CreateWindow("d3d7_test_wc", "d3d7_test", WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION , 0, 0, 640, 480, 0, 0, 0, 0);
 62 
 63     hr = IDirectDraw7_SetCooperativeLevel(DirectDraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
 64     ok(hr == DD_OK, "IDirectDraw7_SetCooperativeLevel failed with %08x\n", hr);
 65     if(FAILED(hr)) goto err;
 66     hr = IDirectDraw7_SetDisplayMode(DirectDraw, 640, 480, 32, 0, 0);
 67     if(FAILED(hr)) {
 68         /* 24 bit is fine too */
 69         hr = IDirectDraw7_SetDisplayMode(DirectDraw, 640, 480, 24, 0, 0);
 70 
 71     }
 72     ok(hr == DD_OK || hr == DDERR_UNSUPPORTED, "IDirectDraw7_SetDisplayMode failed with %08x\n", hr);
 73     if(FAILED(hr)) {
 74         /* use trace, the caller calls skip() */
 75         trace("SetDisplayMode failed\n");
 76         goto err;
 77     }
 78 
 79     hr = IDirectDraw7_QueryInterface(DirectDraw, &IID_IDirect3D7, (void**) &Direct3D);
 80     if (hr == E_NOINTERFACE) goto err;
 81     ok(hr==DD_OK, "QueryInterface returned: %08x\n", hr);
 82 
 83     /* DirectDraw Flipping behavior doesn't seem that well-defined. The reference rasterizer behaves differently
 84      * than hardware implementations. Request single buffering, that seems to work everywhere
 85      */
 86     memset(&ddsd, 0, sizeof(ddsd));
 87     ddsd.dwSize = sizeof(ddsd);
 88     ddsd.dwFlags = DDSD_CAPS;
 89     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE;
 90     ddsd.dwBackBufferCount = 1;
 91     hr = IDirectDraw7_CreateSurface(DirectDraw, &ddsd, &Surface, NULL);
 92     ok(hr==DD_OK, "CreateSurface returned: %08x\n", hr);
 93     if(!Surface) goto err;
 94 
 95     hr = IDirect3D7_CreateDevice(Direct3D, &IID_IDirect3DTnLHalDevice, Surface, &Direct3DDevice);
 96     if(FAILED(hr))
 97     {
 98         trace("Creating a TnLHal Device failed, trying HAL\n");
 99         hr = IDirect3D7_CreateDevice(Direct3D, &IID_IDirect3DHALDevice, Surface, &Direct3DDevice);
100         if(FAILED(hr))
101         {
102             trace("Creating a HAL device failed, trying Ref\n");
103             hr = IDirect3D7_CreateDevice(Direct3D, &IID_IDirect3DRefDevice, Surface, &Direct3DDevice);
104         }
105     }
106     if(!Direct3DDevice) goto err;
107     return TRUE;
108 
109     err:
110     if(DirectDraw) IDirectDraw7_Release(DirectDraw);
111     if(Surface) IDirectDrawSurface7_Release(Surface);
112     if(Direct3D) IDirect3D7_Release(Direct3D);
113     if(Direct3DDevice) IDirect3DDevice7_Release(Direct3DDevice);
114     if(window) DestroyWindow(window);
115     return FALSE;
116 }
117 
118 static void releaseObjects(void)
119 {
120     IDirect3DDevice7_Release(Direct3DDevice);
121     IDirect3D7_Release(Direct3D);
122     IDirectDrawSurface7_Release(Surface);
123     IDirectDraw7_Release(DirectDraw);
124     DestroyWindow(window);
125 }
126 
127 static DWORD getPixelColor(IDirect3DDevice7 *device, UINT x, UINT y)
128 {
129     DWORD ret;
130     HRESULT hr;
131     DDSURFACEDESC2 ddsd;
132     RECT rectToLock = {x, y, x+1, y+1};
133     IDirectDrawSurface7 *surf = NULL;
134 
135     /* Some implementations seem to dislike direct locking on the front buffer. Thus copy the front buffer
136      * to an offscreen surface and lock it instead of the front buffer
137      */
138     memset(&ddsd, 0, sizeof(ddsd));
139     ddsd.dwSize = sizeof(ddsd);
140     U4(ddsd).ddpfPixelFormat.dwSize = sizeof(U4(ddsd).ddpfPixelFormat);
141     ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS;
142     ddsd.dwWidth = 640;
143     ddsd.dwHeight = 480;
144     ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
145     hr = IDirectDraw7_CreateSurface(DirectDraw, &ddsd, &surf, NULL);
146     ok(hr == DD_OK, "IDirectDraw7_CreateSurface failed with %08x\n", hr);
147     if(!surf)
148     {
149         trace("cannot create helper surface\n");
150         return 0xdeadbeef;
151     }
152 
153     memset(&ddsd, 0, sizeof(ddsd));
154     ddsd.dwSize = sizeof(ddsd);
155     U4(ddsd).ddpfPixelFormat.dwSize = sizeof(U4(ddsd).ddpfPixelFormat);
156 
157     hr = IDirectDrawSurface_BltFast(surf, 0, 0, Surface, NULL, 0);
158     ok(hr == DD_OK, "IDirectDrawSurface7_BltFast returned %08x\n", hr);
159     if(FAILED(hr))
160     {
161         trace("Cannot blit\n");
162         ret = 0xdeadbee;
163         goto out;
164     }
165 
166     hr = IDirectDrawSurface7_Lock(surf, &rectToLock, &ddsd, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
167     if(FAILED(hr))
168     {
169         trace("Can't lock the offscreen surface, hr=%08x\n", hr);
170         ret = 0xdeadbeec;
171         goto out;
172     }
173 
174     /* Remove the X channel for now. DirectX and OpenGL have different ideas how to treat it apparently, and it isn't
175      * really important for these tests
176      */
177     ret = ((DWORD *) ddsd.lpSurface)[0] & 0x00ffffff;
178     hr = IDirectDrawSurface7_Unlock(surf, NULL);
179     if(FAILED(hr))
180     {
181         trace("Can't unlock the offscreen surface, hr=%08x\n", hr);
182     }
183 
184 out:
185     IDirectDrawSurface7_Release(surf);
186     return ret;
187 }
188 
189 struct vertex
190 {
191     float x, y, z;
192     DWORD diffuse;
193 };
194 
195 struct nvertex
196 {
197     float x, y, z;
198     float nx, ny, nz;
199     DWORD diffuse;
200 };
201 
202 static void lighting_test(IDirect3DDevice7 *device)
203 {
204     HRESULT hr;
205     DWORD fvf = D3DFVF_XYZ | D3DFVF_DIFFUSE;
206     DWORD nfvf = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_NORMAL;
207     DWORD color;
208 
209     float mat[16] = { 1.0f, 0.0f, 0.0f, 0.0f,
210                       0.0f, 1.0f, 0.0f, 0.0f,
211                       0.0f, 0.0f, 1.0f, 0.0f,
212                       0.0f, 0.0f, 0.0f, 1.0f };
213 
214     struct vertex unlitquad[] =
215     {
216         {-1.0f, -1.0f,   0.1f,                          0xffff0000},
217         {-1.0f,  0.0f,   0.1f,                          0xffff0000},
218         { 0.0f,  0.0f,   0.1f,                          0xffff0000},
219         { 0.0f, -1.0f,   0.1f,                          0xffff0000},
220     };
221     struct vertex litquad[] =
222     {
223         {-1.0f,  0.0f,   0.1f,                          0xff00ff00},
224         {-1.0f,  1.0f,   0.1f,                          0xff00ff00},
225         { 0.0f,  1.0f,   0.1f,                          0xff00ff00},
226         { 0.0f,  0.0f,   0.1f,                          0xff00ff00},
227     };
228     struct nvertex unlitnquad[] =
229     {
230         { 0.0f, -1.0f,   0.1f,  1.0f,   1.0f,   1.0f,   0xff0000ff},
231         { 0.0f,  0.0f,   0.1f,  1.0f,   1.0f,   1.0f,   0xff0000ff},
232         { 1.0f,  0.0f,   0.1f,  1.0f,   1.0f,   1.0f,   0xff0000ff},
233         { 1.0f, -1.0f,   0.1f,  1.0f,   1.0f,   1.0f,   0xff0000ff},
234     };
235     struct nvertex litnquad[] =
236     {
237         { 0.0f,  0.0f,   0.1f,  1.0f,   1.0f,   1.0f,   0xffffff00},
238         { 0.0f,  1.0f,   0.1f,  1.0f,   1.0f,   1.0f,   0xffffff00},
239         { 1.0f,  1.0f,   0.1f,  1.0f,   1.0f,   1.0f,   0xffffff00},
240         { 1.0f,  0.0f,   0.1f,  1.0f,   1.0f,   1.0f,   0xffffff00},
241     };
242     WORD Indices[] = {0, 1, 2, 2, 3, 0};
243 
244     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0);
245     ok(hr == D3D_OK, "IDirect3DDevice7_Clear failed with %08x\n", hr);
246 
247     /* Setup some states that may cause issues */
248     hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_WORLD, (D3DMATRIX *) mat);
249     ok(hr == D3D_OK, "IDirect3DDevice7_SetTransform returned %08x\n", hr);
250     hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_VIEW, (D3DMATRIX *)mat);
251     ok(hr == D3D_OK, "IDirect3DDevice7_SetTransform returned %08x\n", hr);
252     hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, (D3DMATRIX *) mat);
253     ok(hr == D3D_OK, "IDirect3DDevice7_SetTransform returned %08x\n", hr);
254     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CLIPPING, FALSE);
255     ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState returned %08x\n", hr);
256     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, FALSE);
257     ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState returned %08x\n", hr);
258     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, FALSE);
259     ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState returned %08x\n", hr);
260     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_STENCILENABLE, FALSE);
261     ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState returned %08x\n", hr);
262     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ALPHATESTENABLE, FALSE);
263     ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState returned %08x\n", hr);
264     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, FALSE);
265     ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState returned %08x\n", hr);
266     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
267     ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed with %08x\n", hr);
268 
269     hr = IDirect3DDevice7_BeginScene(device);
270     ok(hr == D3D_OK, "IDirect3DDevice7_BeginScene failed with %08x\n", hr);
271     if(hr == D3D_OK)
272     {
273         /* No lights are defined... That means, lit vertices should be entirely black */
274         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
275         ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState returned %08x\n", hr);
276         hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, fvf, unlitquad, 4 /* NumVerts */,
277                                                     Indices, 6 /* Indexcount */, 0 /* flags */);
278         ok(hr == D3D_OK, "IDirect3DDevice7_DrawIndexedPrimitiveUP failed with %08x\n", hr);
279 
280         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, TRUE);
281         ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState returned %08x\n", hr);
282         hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, fvf, litquad, 4 /* NumVerts */,
283                                                     Indices, 6 /* Indexcount */, 0 /* flags */);
284         ok(hr == D3D_OK, "IDirect3DDevice7_DrawIndexedPrimitiveUP failed with %08x\n", hr);
285 
286         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
287         ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState returned %08x\n", hr);
288         hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, nfvf, unlitnquad, 4 /* NumVerts */,
289                                                     Indices, 6 /* Indexcount */, 0 /* flags */);
290         ok(hr == D3D_OK, "IDirect3DDevice7_DrawIndexedPrimitiveUP failed with %08x\n", hr);
291 
292         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, TRUE);
293         ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState returned %08x\n", hr);
294         hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, nfvf, litnquad, 4 /* NumVerts */,
295                                                     Indices, 6 /* Indexcount */, 0 /* flags */);
296         ok(hr == D3D_OK, "IDirect3DDevice7_DrawIndexedPrimitiveUP failed with %08x\n", hr);
297 
298         IDirect3DDevice7_EndScene(device);
299         ok(hr == D3D_OK, "IDirect3DDevice7_EndScene failed with %08x\n", hr);
300     }
301 
302     color = getPixelColor(device, 160, 360); /* lower left quad - unlit without normals */
303     ok(color == 0x00ff0000, "Unlit quad without normals has color %08x\n", color);
304     color = getPixelColor(device, 160, 120); /* upper left quad - lit without normals */
305     ok(color == 0x00000000, "Lit quad without normals has color %08x\n", color);
306     color = getPixelColor(device, 480, 360); /* lower left quad - unlit width normals */
307     ok(color == 0x000000ff, "Unlit quad width normals has color %08x\n", color);
308     color = getPixelColor(device, 480, 120); /* upper left quad - lit width normals */
309     ok(color == 0x00000000, "Lit quad width normals has color %08x\n", color);
310 
311     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
312     ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState returned %08x\n", hr);
313 }
314 
315 static void clear_test(IDirect3DDevice7 *device)
316 {
317     /* Tests the correctness of clearing parameters */
318     HRESULT hr;
319     D3DRECT rect[2];
320     D3DRECT rect_negneg;
321     DWORD color;
322 
323     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0);
324     ok(hr == D3D_OK, "IDirect3DDevice7_Clear failed with %08x\n", hr);
325 
326     /* Positive x, negative y */
327     U1(rect[0]).x1 = 0;
328     U2(rect[0]).y1 = 480;
329     U3(rect[0]).x2 = 320;
330     U4(rect[0]).y2 = 240;
331 
332     /* Positive x, positive y */
333     U1(rect[1]).x1 = 0;
334     U2(rect[1]).y1 = 0;
335     U3(rect[1]).x2 = 320;
336     U4(rect[1]).y2 = 240;
337     /* Clear 2 rectangles with one call. Shows that a positive value is returned, but the negative rectangle
338      * is ignored, the positive is still cleared afterwards
339      */
340     hr = IDirect3DDevice7_Clear(device, 2, rect, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0);
341     ok(hr == D3D_OK, "IDirect3DDevice7_Clear failed with %08x\n", hr);
342 
343     /* negative x, negative y */
344     U1(rect_negneg).x1 = 640;
345     U2(rect_negneg).y1 = 240;
346     U3(rect_negneg).x2 = 320;
347     U4(rect_negneg).y2 = 0;
348     hr = IDirect3DDevice7_Clear(device, 1, &rect_negneg, D3DCLEAR_TARGET, 0xff00ff00, 0.0, 0);
349     ok(hr == D3D_OK, "IDirect3DDevice7_Clear failed with %08x\n", hr);
350 
351     color = getPixelColor(device, 160, 360); /* lower left quad */
352     ok(color == 0x00ffffff, "Clear rectangle 3(pos, neg) has color %08x\n", color);
353     color = getPixelColor(device, 160, 120); /* upper left quad */
354     ok(color == 0x00ff0000, "Clear rectangle 1(pos, pos) has color %08x\n", color);
355     color = getPixelColor(device, 480, 360); /* lower right quad  */
356     ok(color == 0x00ffffff, "Clear rectangle 4(NULL) has color %08x\n", color);
357     color = getPixelColor(device, 480, 120); /* upper right quad */
358     ok(color == 0x00ffffff, "Clear rectangle 4(neg, neg) has color %08x\n", color);
359 }
360 
361 struct sVertex {
362     float x, y, z;
363     DWORD diffuse;
364     DWORD specular;
365 };
366 
367 struct sVertexT {
368     float x, y, z, rhw;
369     DWORD diffuse;
370     DWORD specular;
371 };
372 
373 static void fog_test(IDirect3DDevice7 *device)
374 {
375     HRESULT hr;
376     DWORD color;
377     float start = 0.0, end = 1.0;
378     D3DDEVICEDESC7 caps;
379 
380     /* Gets full z based fog with linear fog, no fog with specular color */
381     struct sVertex unstransformed_1[] = {
382         {-1,    -1,   0.1f,         0xFFFF0000,     0xFF000000  },
383         {-1,     0,   0.1f,         0xFFFF0000,     0xFF000000  },
384         { 0,     0,   0.1f,         0xFFFF0000,     0xFF000000  },
385         { 0,    -1,   0.1f,         0xFFFF0000,     0xFF000000  },
386     };
387     /* Ok, I am too lazy to deal with transform matrices */
388     struct sVertex unstransformed_2[] = {
389         {-1,     0,   1.0f,         0xFFFF0000,     0xFF000000  },
390         {-1,     1,   1.0f,         0xFFFF0000,     0xFF000000  },
391         { 0,     1,   1.0f,         0xFFFF0000,     0xFF000000  },
392         { 0,     0,   1.0f,         0xFFFF0000,     0xFF000000  },
393     };
394     /* Untransformed ones. Give them a different diffuse color to make the test look
395      * nicer. It also makes making sure that they are drawn correctly easier.
396      */
397     struct sVertexT transformed_1[] = {
398         {320,    0,   1.0f, 1.0f,   0xFFFFFF00,     0xFF000000  },
399         {640,    0,   1.0f, 1.0f,   0xFFFFFF00,     0xFF000000  },
400         {640,  240,   1.0f, 1.0f,   0xFFFFFF00,     0xFF000000  },
401         {320,  240,   1.0f, 1.0f,   0xFFFFFF00,     0xFF000000  },
402     };
403     struct sVertexT transformed_2[] = {
404         {320,  240,   1.0f, 1.0f,   0xFFFFFF00,     0xFF000000  },
405         {640,  240,   1.0f, 1.0f,   0xFFFFFF00,     0xFF000000  },
406         {640,  480,   1.0f, 1.0f,   0xFFFFFF00,     0xFF000000  },
407         {320,  480,   1.0f, 1.0f,   0xFFFFFF00,     0xFF000000  },
408     };
409     WORD Indices[] = {0, 1, 2, 2, 3, 0};
410 
411     memset(&caps, 0, sizeof(caps));
412     hr = IDirect3DDevice7_GetCaps(device, &caps);
413     ok(hr == D3D_OK, "IDirect3DDevice7_GetCaps returned %08x\n", hr);
414     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff00ff, 0.0, 0);
415     ok(hr == D3D_OK, "IDirect3DDevice7_Clear returned %08x\n", hr);
416 
417     /* Setup initial states: No lighting, fog on, fog color */
418     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
419     ok(hr == D3D_OK, "Turning off lighting returned %08x\n", hr);
420     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, TRUE);
421     ok(hr == D3D_OK, "Turning on fog calculations returned %08x\n", hr);
422     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGCOLOR, 0xFF00FF00 /* A nice green */);
423     ok(hr == D3D_OK, "Turning on fog calculations returned %08x\n", hr);
424 
425     /* First test: Both table fog and vertex fog off */
426     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGTABLEMODE, D3DFOG_NONE);
427     ok(hr == D3D_OK, "Turning off table fog returned %08x\n", hr);
428     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGVERTEXMODE, D3DFOG_NONE);
429     ok(hr == D3D_OK, "Turning off table fog returned %08x\n", hr);
430 
431     /* Start = 0, end = 1. Should be default, but set them */
432     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGSTART, *((DWORD *) &start));
433     ok(hr == D3D_OK, "Setting fog start returned %08x\n", hr);
434     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGEND, *((DWORD *) &end));
435     ok(hr == D3D_OK, "Setting fog start returned %08x\n", hr);
436 
437     if(IDirect3DDevice7_BeginScene(device) == D3D_OK)
438     {
439         /* Untransformed, vertex fog = NONE, table fog = NONE: Read the fog weighting from the specular color */
440         hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR,
441                                                    unstransformed_1, 4, Indices, 6, 0);
442         ok(hr == D3D_OK, "DrawIndexedPrimitive returned %08x\n", hr);
443 
444         /* That makes it use the Z value */
445         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGVERTEXMODE, D3DFOG_LINEAR);
446         ok(hr == D3D_OK, "Turning off table fog returned %08x\n", hr);
447         /* Untransformed, vertex fog != none (or table fog != none):
448          * Use the Z value as input into the equation
449          */
450         hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR,
451                                                    unstransformed_2, 4, Indices, 6, 0);
452         ok(hr == D3D_OK, "DrawIndexedPrimitive returned %08x\n", hr);
453 
454         /* transformed verts */
455         ok( hr == D3D_OK, "SetFVF returned %08x\n", hr);
456         /* Transformed, vertex fog != NONE, pixel fog == NONE: Use specular color alpha component */
457         hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR,
458                                                    transformed_1, 4, Indices, 6, 0);
459         ok(hr == D3D_OK, "DrawIndexedPrimitive returned %08x\n", hr);
460 
461         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGTABLEMODE, D3DFOG_LINEAR);
462         ok( hr == D3D_OK, "Setting fog table mode to D3DFOG_LINEAR returned %08x\n", hr);
463         /* Transformed, table fog != none, vertex anything: Use Z value as input to the fog
464          * equation
465          */
466         hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR,
467                                                    transformed_2, 4, Indices, 6, 0);
468         ok(hr == D3D_OK, "DrawIndexedPrimitive returned %08x\n", hr);
469 
470         hr = IDirect3DDevice7_EndScene(device);
471         ok(hr == D3D_OK, "EndScene returned %08x\n", hr);
472     }
473     else
474     {
475         ok(FALSE, "BeginScene failed\n");
476     }
477 
478     color = getPixelColor(device, 160, 360);
479     ok(color == 0x00FF0000, "Untransformed vertex with no table or vertex fog has color %08x\n", color);
480     color = getPixelColor(device, 160, 120);
481     ok(color == 0x0000FF00, "Untransformed vertex with linear vertex fog has color %08x\n", color);
482     color = getPixelColor(device, 480, 120);
483     ok(color == 0x00FFFF00, "Transformed vertex with linear vertex fog has color %08x\n", color);
484     if(caps.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_FOGTABLE)
485     {
486         color = getPixelColor(device, 480, 360);
487         ok(color == 0x0000FF00, "Transformed vertex with linear table fog has color %08x\n", color);
488     }
489     else
490     {
491         /* Without fog table support the vertex fog is still applied, even though table fog is turned on.
492          * The settings above result in no fogging with vertex fog
493          */
494         color = getPixelColor(device, 480, 120);
495         ok(color == 0x00FFFF00, "Transformed vertex with linear vertex fog has color %08x\n", color);
496         trace("Info: Table fog not supported by this device\n");
497     }
498 
499     /* Turn off the fog master switch to avoid confusing other tests */
500     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, FALSE);
501     ok(hr == D3D_OK, "Turning off fog calculations returned %08x\n", hr);
502 }
503 
504 static void offscreen_test(IDirect3DDevice7 *device)
505 {
506     HRESULT hr;
507     IDirectDrawSurface7 *backbuffer = NULL, *offscreen = NULL;
508     DWORD color;
509     DDSURFACEDESC2 ddsd;
510 
511     static const float quad[][5] = {
512         {-0.5f, -0.5f, 0.1f, 0.0f, 0.0f},
513         {-0.5f,  0.5f, 0.1f, 0.0f, 1.0f},
514         { 0.5f, -0.5f, 0.1f, 1.0f, 0.0f},
515         { 0.5f,  0.5f, 0.1f, 1.0f, 1.0f},
516     };
517 
518     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0);
519     ok(hr == D3D_OK, "Clear failed, hr = %08x\n", hr);
520 
521     memset(&ddsd, 0, sizeof(ddsd));
522     ddsd.dwSize = sizeof(ddsd);
523     U4(ddsd).ddpfPixelFormat.dwSize = sizeof(U4(ddsd).ddpfPixelFormat);
524     ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS;
525     ddsd.dwWidth = 128;
526     ddsd.dwHeight = 128;
527     ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_3DDEVICE;
528     hr = IDirectDraw7_CreateSurface(DirectDraw, &ddsd, &offscreen, NULL);
529     ok(hr == D3D_OK, "Creating the offscreen render target failed, hr = %08x\n", hr);
530     if(!offscreen) {
531         goto out;
532     }
533 
534     hr = IDirect3DDevice7_GetRenderTarget(device, &backbuffer);
535     ok(hr == D3D_OK, "Can't get back buffer, hr = %08x\n", hr);
536     if(!backbuffer) {
537         goto out;
538     }
539 
540     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
541     ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08x\n", hr);
542     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
543     ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08x\n", hr);
544     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_MINFILTER, D3DFILTER_NEAREST);
545     ok(SUCCEEDED(hr), "SetTextureStageState D3DSAMP_MINFILTER failed (0x%08x)\n", hr);
546     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_MAGFILTER, D3DFILTER_NEAREST);
547     ok(SUCCEEDED(hr), "SetTextureStageState D3DSAMP_MAGFILTER failed (0x%08x)\n", hr);
548     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
549     ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState returned hr = %08x\n", hr);
550 
551     if(IDirect3DDevice7_BeginScene(device) == D3D_OK) {
552         hr = IDirect3DDevice7_SetRenderTarget(device, offscreen, 0);
553         ok(hr == D3D_OK, "SetRenderTarget failed, hr = %08x\n", hr);
554         hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff00ff, 0.0, 0);
555         ok(hr == D3D_OK, "Clear failed, hr = %08x\n", hr);
556 
557         /* Draw without textures - Should result in a white quad */
558         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_TEX1, quad, 4, 0);
559         ok(hr == D3D_OK, "DrawPrimitive failed, hr = %08x\n", hr);
560 
561         hr = IDirect3DDevice7_SetRenderTarget(device, backbuffer, 0);
562         ok(hr == D3D_OK, "SetRenderTarget failed, hr = %08x\n", hr);
563         hr = IDirect3DDevice7_SetTexture(device, 0, offscreen);
564         ok(hr == D3D_OK, "SetTexture failed, %08x\n", hr);
565 
566         /* This time with the texture */
567         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_TEX1, quad, 4, 0);
568         ok(hr == D3D_OK, "DrawPrimitive failed, hr = %08x\n", hr);
569 
570         IDirect3DDevice7_EndScene(device);
571     }
572 
573     /* Center quad - should be white */
574     color = getPixelColor(device, 320, 240);
575     ok(color == 0x00ffffff, "Offscreen failed: Got color 0x%08x, expected 0x00ffffff.\n", color);
576     /* Some quad in the cleared part of the texture */
577     color = getPixelColor(device, 170, 240);
578     ok(color == 0x00ff00ff, "Offscreen failed: Got color 0x%08x, expected 0x00ff00ff.\n", color);
579     /* Part of the originally cleared back buffer */
580     color = getPixelColor(device, 10, 10);
581     ok(color == 0x00ff0000, "Offscreen failed: Got color 0x%08x, expected 0x00ff0000.\n", color);
582     if(0) {
583         /* Lower left corner of the screen, where back buffer offscreen rendering draws the offscreen texture.
584          * It should be red, but the offscreen texture may leave some junk there. Not tested yet. Depending on
585          * the offscreen rendering mode this test would succeed or fail
586          */
587         color = getPixelColor(device, 10, 470);
588         ok(color == 0x00ff0000, "Offscreen failed: Got color 0x%08x, expected 0x00ff0000.\n", color);
589     }
590 
591 out:
592     hr = IDirect3DDevice7_SetTexture(device, 0, NULL);
593 
594     /* restore things */
595     if(backbuffer) {
596         hr = IDirect3DDevice7_SetRenderTarget(device, backbuffer, 0);
597         IDirectDrawSurface7_Release(backbuffer);
598     }
599     if(offscreen) {
600         IDirectDrawSurface7_Release(offscreen);
601     }
602 }
603 
604 static void alpha_test(IDirect3DDevice7 *device)
605 {
606     HRESULT hr;
607     IDirectDrawSurface7 *backbuffer = NULL, *offscreen = NULL;
608     DWORD color, red, green, blue;
609     DDSURFACEDESC2 ddsd;
610 
611     struct vertex quad1[] =
612     {
613         {-1.0f, -1.0f,   0.1f,                          0x4000ff00},
614         {-1.0f,  0.0f,   0.1f,                          0x4000ff00},
615         { 1.0f, -1.0f,   0.1f,                          0x4000ff00},
616         { 1.0f,  0.0f,   0.1f,                          0x4000ff00},
617     };
618     struct vertex quad2[] =
619     {
620         {-1.0f,  0.0f,   0.1f,                          0xc00000ff},
621         {-1.0f,  1.0f,   0.1f,                          0xc00000ff},
622         { 1.0f,  0.0f,   0.1f,                          0xc00000ff},
623         { 1.0f,  1.0f,   0.1f,                          0xc00000ff},
624     };
625     static const float composite_quad[][5] = {
626         { 0.0f, -1.0f, 0.1f, 0.0f, 1.0f},
627         { 0.0f,  1.0f, 0.1f, 0.0f, 0.0f},
628         { 1.0f, -1.0f, 0.1f, 1.0f, 1.0f},
629         { 1.0f,  1.0f, 0.1f, 1.0f, 0.0f},
630     };
631 
632     /* Clear the render target with alpha = 0.5 */
633     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x80ff0000, 0.0, 0);
634     ok(hr == D3D_OK, "Clear failed, hr = %08x\n", hr);
635 
636     memset(&ddsd, 0, sizeof(ddsd));
637     ddsd.dwSize = sizeof(ddsd);
638     ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT;
639     ddsd.dwWidth = 128;
640     ddsd.dwHeight = 128;
641     ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_3DDEVICE;
642     U4(ddsd).ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
643     U1(U4(ddsd).ddpfPixelFormat).dwRGBBitCount      = 32;
644     U2(U4(ddsd).ddpfPixelFormat).dwRBitMask         = 0x00ff0000;
645     U3(U4(ddsd).ddpfPixelFormat).dwGBitMask         = 0x0000ff00;
646     U4(U4(ddsd).ddpfPixelFormat).dwBBitMask         = 0x000000ff;
647     U5(U4(ddsd).ddpfPixelFormat).dwRGBAlphaBitMask  = 0xff000000;
648     hr = IDirectDraw7_CreateSurface(DirectDraw, &ddsd, &offscreen, NULL);
649     ok(hr == D3D_OK, "Creating the offscreen render target failed, hr = %08x\n", hr);
650     if(!offscreen) {
651         goto out;
652     }
653     hr = IDirect3DDevice7_GetRenderTarget(device, &backbuffer);
654     ok(hr == D3D_OK, "Can't get back buffer, hr = %08x\n", hr);
655     if(!backbuffer) {
656         goto out;
657     }
658 
659     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
660     ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08x\n", hr);
661     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
662     ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08x\n", hr);
663     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_MINFILTER, D3DFILTER_NEAREST);
664     ok(SUCCEEDED(hr), "SetTextureStageState D3DSAMP_MINFILTER failed (0x%08x)\n", hr);
665     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_MAGFILTER, D3DFILTER_NEAREST);
666     ok(SUCCEEDED(hr), "SetTextureStageState D3DSAMP_MAGFILTER failed (0x%08x)\n", hr);
667 
668     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
669     ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr);
670     if(IDirect3DDevice7_BeginScene(device) == D3D_OK) {
671 
672         /* Draw two quads, one with src alpha blending, one with dest alpha blending. The
673          * SRCALPHA / INVSRCALPHA blend doesn't give any surprises. Colors are blended based on
674          * the input alpha
675          *
676          * The DESTALPHA / INVDESTALPHA do not "work" on the regular buffer because there is no alpha.
677          * They give essentially ZERO and ONE blend factors
678          */
679         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
680         ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr);
681         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
682         ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr);
683         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE, quad1, 4, 0);
684         ok(hr == D3D_OK, "DrawPrimitive failed, hr = %08x\n", hr);
685 
686         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_SRCBLEND, D3DBLEND_DESTALPHA);
687         ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr);
688         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVDESTALPHA);
689         ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr);
690         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE, quad2, 4, 0);
691         ok(hr == D3D_OK, "DrawPrimitive failed, hr = %08x\n", hr);
692 
693         /* Switch to the offscreen buffer, and redo the testing. SRCALPHA and DESTALPHA. The offscreen buffer
694          * has a alpha channel on its own. Clear the offscreen buffer with alpha = 0.5 again, then draw the
695          * quads again. The SRCALPHA/INVSRCALPHA doesn't give any surprises, but the DESTALPHA/INVDESTALPHA
696          * blending works as supposed now - blend factor is 0.5 in both cases, not 0.75 as from the input
697          * vertices
698          */
699         hr = IDirect3DDevice7_SetRenderTarget(device, offscreen, 0);
700         ok(hr == D3D_OK, "Can't get back buffer, hr = %08x\n", hr);
701         hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x80ff0000, 0.0, 0);
702         ok(hr == D3D_OK, "Clear failed, hr = %08x\n", hr);
703 
704         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
705         ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr);
706         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
707         ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr);
708         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE, quad1, 4, 0);
709         ok(hr == D3D_OK, "DrawPrimitive failed, hr = %08x\n", hr);
710 
711         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_SRCBLEND, D3DBLEND_DESTALPHA);