ReactOS  0.4.15-dev-1203-g0e5a4d5
core.c
Go to the documentation of this file.
1 /*
2  * Tests for the D3DX9 core interfaces
3  *
4  * Copyright 2009 Tony Wasserka
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20 
21 #define COBJMACROS
22 #include "wine/test.h"
23 #include <dxerr9.h>
24 #include "d3dx9core.h"
25 
26 static inline int get_ref(IUnknown *obj)
27 {
28  IUnknown_AddRef(obj);
29  return IUnknown_Release(obj);
30 }
31 
32 #define check_ref(obj, exp) _check_ref(__LINE__, obj, exp)
33 static inline void _check_ref(unsigned int line, IUnknown *obj, int exp)
34 {
35  int ref = get_ref(obj);
36  ok_(__FILE__, line)(exp == ref, "Invalid refcount. Expected %d, got %d\n", exp, ref);
37 }
38 
39 #define check_release(obj, exp) _check_release(__LINE__, obj, exp)
40 static inline void _check_release(unsigned int line, IUnknown *obj, int exp)
41 {
42  int ref = IUnknown_Release(obj);
43  ok_(__FILE__, line)(ref == exp, "Invalid refcount. Expected %d, got %d\n", exp, ref);
44 }
45 
46 #define admitted_error 0.0001f
47 static inline void check_mat(D3DXMATRIX got, D3DXMATRIX exp)
48 {
49  int i, j, equal=1;
50  for (i=0; i<4; i++)
51  for (j=0; j<4; j++)
52  if (fabs(U(exp).m[i][j]-U(got).m[i][j]) > admitted_error)
53  equal=0;
54 
55  ok(equal, "Got matrix\n\t(%f,%f,%f,%f\n\t %f,%f,%f,%f\n\t %f,%f,%f,%f\n\t %f,%f,%f,%f)\n"
56  "Expected matrix=\n\t(%f,%f,%f,%f\n\t %f,%f,%f,%f\n\t %f,%f,%f,%f\n\t %f,%f,%f,%f)\n",
57  U(got).m[0][0],U(got).m[0][1],U(got).m[0][2],U(got).m[0][3],
58  U(got).m[1][0],U(got).m[1][1],U(got).m[1][2],U(got).m[1][3],
59  U(got).m[2][0],U(got).m[2][1],U(got).m[2][2],U(got).m[2][3],
60  U(got).m[3][0],U(got).m[3][1],U(got).m[3][2],U(got).m[3][3],
61  U(exp).m[0][0],U(exp).m[0][1],U(exp).m[0][2],U(exp).m[0][3],
62  U(exp).m[1][0],U(exp).m[1][1],U(exp).m[1][2],U(exp).m[1][3],
63  U(exp).m[2][0],U(exp).m[2][1],U(exp).m[2][2],U(exp).m[2][3],
64  U(exp).m[3][0],U(exp).m[3][1],U(exp).m[3][2],U(exp).m[3][3]);
65 }
66 
67 static void test_ID3DXBuffer(void)
68 {
70  HRESULT hr;
71  ULONG count;
72  DWORD size;
73 
74  hr = D3DXCreateBuffer(10, NULL);
75  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateBuffer failed, got %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
76 
77  hr = D3DXCreateBuffer(0, &buffer);
78  ok(hr == D3D_OK, "D3DXCreateBuffer failed, got %#x, expected %#x\n", hr, D3D_OK);
79 
81  ok(!size, "GetBufferSize failed, got %u, expected %u\n", size, 0);
82 
84  ok(!count, "ID3DXBuffer has %u references left\n", count);
85 
86  hr = D3DXCreateBuffer(3, &buffer);
87  ok(hr == D3D_OK, "D3DXCreateBuffer failed, got %#x, expected %#x\n", hr, D3D_OK);
88 
90  ok(size == 3, "GetBufferSize failed, got %u, expected %u\n", size, 3);
91 
93  ok(!count, "ID3DXBuffer has %u references left\n", count);
94 }
95 
96 static void test_ID3DXSprite(IDirect3DDevice9 *device)
97 {
98  ID3DXSprite *sprite;
99  IDirect3D9 *d3d;
100  IDirect3DDevice9 *cmpdev;
101  IDirect3DTexture9 *tex1, *tex2;
102  D3DXMATRIX mat, cmpmat;
103  D3DVIEWPORT9 vp;
104  RECT rect;
105  D3DXVECTOR3 pos, center;
106  HRESULT hr;
107 
110  IDirect3D9_Release(d3d);
111  ok (hr == D3D_OK, "D3DFMT_A8R8G8B8 not supported\n");
112  if (FAILED(hr)) return;
113 
115  ok (hr == D3D_OK, "Failed to create first texture (error code: %#x)\n", hr);
116  if (FAILED(hr)) return;
117 
119  ok (hr == D3D_OK, "Failed to create second texture (error code: %#x)\n", hr);
120  if (FAILED(hr)) {
122  return;
123  }
124 
125  /* Test D3DXCreateSprite */
127  ok (hr == D3DERR_INVALIDCALL, "D3DXCreateSprite returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
128 
130  ok (hr == D3DERR_INVALIDCALL, "D3DXCreateSprite returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
131 
133  ok (hr == D3D_OK, "D3DXCreateSprite returned %#x, expected %#x\n", hr, D3D_OK);
134 
135 
136  /* Test ID3DXSprite_GetDevice */
138  ok (hr == D3DERR_INVALIDCALL, "GetDevice returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
139 
140  hr = ID3DXSprite_GetDevice(sprite, &cmpdev); /* cmpdev == NULL */
141  ok (hr == D3D_OK, "GetDevice returned %#x, expected %#x\n", hr, D3D_OK);
142 
143  hr = ID3DXSprite_GetDevice(sprite, &cmpdev); /* cmpdev != NULL */
144  ok (hr == D3D_OK, "GetDevice returned %#x, expected %#x\n", hr, D3D_OK);
145 
148 
149 
150  /* Test ID3DXSprite_GetTransform */
152  ok (hr == D3DERR_INVALIDCALL, "GetTransform returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
154  ok (hr == D3D_OK, "GetTransform returned %#x, expected %#x\n", hr, D3D_OK);
155  if(SUCCEEDED(hr)) {
157  D3DXMatrixIdentity(&identity);
159  }
160 
161  /* Test ID3DXSprite_SetTransform */
162  /* Set a transform and test if it gets returned correctly */
163  U(mat).m[0][0]=2.1f; U(mat).m[0][1]=6.5f; U(mat).m[0][2]=-9.6f; U(mat).m[0][3]=1.7f;
164  U(mat).m[1][0]=4.2f; U(mat).m[1][1]=-2.5f; U(mat).m[1][2]=2.1f; U(mat).m[1][3]=5.5f;
165  U(mat).m[2][0]=-2.6f; U(mat).m[2][1]=0.3f; U(mat).m[2][2]=8.6f; U(mat).m[2][3]=8.4f;
166  U(mat).m[3][0]=6.7f; U(mat).m[3][1]=-5.1f; U(mat).m[3][2]=6.1f; U(mat).m[3][3]=2.2f;
167 
169  ok (hr == D3DERR_INVALIDCALL, "SetTransform returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
170 
172  ok (hr == D3D_OK, "SetTransform returned %#x, expected %#x\n", hr, D3D_OK);
173  if(SUCCEEDED(hr)) {
175  if(SUCCEEDED(hr)) check_mat(cmpmat, mat);
176  else skip("GetTransform returned %#x\n", hr);
177  }
178 
179  /* Test ID3DXSprite_SetWorldViewLH/RH */
180  todo_wine {
182  ok (hr == D3D_OK, "SetWorldViewLH returned %#x, expected %#x\n", hr, D3D_OK);
184  ok (hr == D3D_OK, "SetWorldViewLH returned %#x, expected %#x\n", hr, D3D_OK);
186  ok (hr == D3D_OK, "SetWorldViewLH returned %#x, expected %#x\n", hr, D3D_OK);
188  ok (hr == D3D_OK, "SetWorldViewLH returned %#x, expected %#x\n", hr, D3D_OK);
189 
191  ok (hr == D3D_OK, "SetWorldViewRH returned %#x, expected %#x\n", hr, D3D_OK);
193  ok (hr == D3D_OK, "SetWorldViewRH returned %#x, expected %#x\n", hr, D3D_OK);
195  ok (hr == D3D_OK, "SetWorldViewRH returned %#x, expected %#x\n", hr, D3D_OK);
197  ok (hr == D3D_OK, "SetWorldViewRH returned %#x, expected %#x\n", hr, D3D_OK);
198  }
200 
201  /* Test ID3DXSprite_Begin*/
203  ok (hr == D3D_OK, "Begin returned %#x, expected %#x\n", hr, D3D_OK);
204 
206  D3DXMatrixIdentity(&cmpmat);
207  check_mat(mat, cmpmat);
208 
210  check_mat(mat, cmpmat);
211 
214  D3DXMatrixOrthoOffCenterLH(&cmpmat, vp.X+0.5f, (float)vp.Width+vp.X+0.5f, (float)vp.Height+vp.Y+0.5f, vp.Y+0.5f, vp.MinZ, vp.MaxZ);
215  check_mat(mat, cmpmat);
216 
217  /* Test ID3DXSprite_Flush and ID3DXSprite_End */
219  ok (hr == D3D_OK, "Flush returned %#x, expected %#x\n", hr, D3D_OK);
220 
222  ok (hr == D3D_OK, "End returned %#x, expected %#x\n", hr, D3D_OK);
223 
224  hr = ID3DXSprite_Flush(sprite); /* May not be called before next Begin */
225  ok (hr == D3DERR_INVALIDCALL, "Flush returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
227  ok (hr == D3DERR_INVALIDCALL, "End returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
228 
229  /* Test ID3DXSprite_Draw */
231  ok (hr == D3D_OK, "Begin returned %#x, expected %#x\n", hr, D3D_OK);
232 
233  if(FAILED(hr)) skip("Couldn't ID3DXSprite_Begin, can't test ID3DXSprite_Draw\n");
234  else { /* Feed the sprite batch */
235  int texref1, texref2;
236 
237  SetRect(&rect, 53, 12, 142, 165);
238  pos.x = 2.2f; pos.y = 4.5f; pos.z = 5.1f;
239  center.x = 11.3f; center.y = 3.4f; center.z = 1.2f;
240 
241  texref1 = get_ref((IUnknown*)tex1);
242  texref2 = get_ref((IUnknown*)tex2);
243 
244  hr = ID3DXSprite_Draw(sprite, NULL, &rect, &center, &pos, D3DCOLOR_XRGB(255, 255, 255));
245  ok (hr == D3DERR_INVALIDCALL, "Draw returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
246 
247  hr = ID3DXSprite_Draw(sprite, tex1, &rect, &center, &pos, D3DCOLOR_XRGB(255, 255, 255));
248  ok (hr == D3D_OK, "Draw returned %#x, expected %#x\n", hr, D3D_OK);
249  hr = ID3DXSprite_Draw(sprite, tex2, &rect, &center, &pos, D3DCOLOR_XRGB( 3, 45, 66));
250  ok (hr == D3D_OK, "Draw returned %#x, expected %#x\n", hr, D3D_OK);
251  hr = ID3DXSprite_Draw(sprite, tex1, NULL, &center, &pos, D3DCOLOR_XRGB(255, 255, 255));
252  ok (hr == D3D_OK, "Draw returned %#x, expected %#x\n", hr, D3D_OK);
253  hr = ID3DXSprite_Draw(sprite, tex1, &rect, NULL, &pos, D3DCOLOR_XRGB(255, 255, 255));
254  ok (hr == D3D_OK, "Draw returned %#x, expected %#x\n", hr, D3D_OK);
255  hr = ID3DXSprite_Draw(sprite, tex1, &rect, &center, NULL, D3DCOLOR_XRGB(255, 255, 255));
256  ok (hr == D3D_OK, "Draw returned %#x, expected %#x\n", hr, D3D_OK);
257  hr = ID3DXSprite_Draw(sprite, tex1, NULL, NULL, NULL, 0);
258  ok (hr == D3D_OK, "Draw returned %#x, expected %#x\n", hr, D3D_OK);
259 
260  check_ref((IUnknown*)tex1, texref1+5); check_ref((IUnknown*)tex2, texref2+1);
262  ok (hr == D3D_OK, "Flush returned %#x, expected %#x\n", hr, D3D_OK);
263  hr = ID3DXSprite_Flush(sprite); /* Flushing twice should work */
264  ok (hr == D3D_OK, "Flush returned %#x, expected %#x\n", hr, D3D_OK);
265  check_ref((IUnknown*)tex1, texref1); check_ref((IUnknown*)tex2, texref2);
266 
268  ok (hr == D3D_OK, "End returned %#x, expected %#x\n", hr, D3D_OK);
269  }
270 
271  /* Test ID3DXSprite_OnLostDevice and ID3DXSprite_OnResetDevice */
272  /* Both can be called twice */
274  ok (hr == D3D_OK, "OnLostDevice returned %#x, expected %#x\n", hr, D3D_OK);
276  ok (hr == D3D_OK, "OnLostDevice returned %#x, expected %#x\n", hr, D3D_OK);
278  ok (hr == D3D_OK, "OnResetDevice returned %#x, expected %#x\n", hr, D3D_OK);
280  ok (hr == D3D_OK, "OnResetDevice returned %#x, expected %#x\n", hr, D3D_OK);
281 
282  /* Make sure everything works like before */
284  ok (hr == D3D_OK, "Begin returned %#x, expected %#x\n", hr, D3D_OK);
285  hr = ID3DXSprite_Draw(sprite, tex2, &rect, &center, &pos, D3DCOLOR_XRGB(255, 255, 255));
286  ok (hr == D3D_OK, "Draw returned %#x, expected %#x\n", hr, D3D_OK);
288  ok (hr == D3D_OK, "Flush returned %#x, expected %#x\n", hr, D3D_OK);
290  ok (hr == D3D_OK, "End returned %#x, expected %#x\n", hr, D3D_OK);
291 
292  /* OnResetDevice makes the interface "forget" the Begin call */
294  ok (hr == D3D_OK, "Begin returned %#x, expected %#x\n", hr, D3D_OK);
296  ok (hr == D3D_OK, "OnResetDevice returned %#x, expected %#x\n", hr, D3D_OK);
298  ok (hr == D3DERR_INVALIDCALL, "End returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
299 
302  check_release((IUnknown*)tex2, 0);
303  check_release((IUnknown*)tex1, 0);
304 }
305 
306 static void test_ID3DXFont(IDirect3DDevice9 *device)
307 {
308  static const WCHAR testW[] = {'t','e','s','t',0};
309  static const char testA[] = "test";
310  static const struct
311  {
312  int font_height;
313  unsigned int expected_size;
314  unsigned int expected_levels;
315  }
316  tests[] =
317  {
318  { 6, 128, 4 },
319  { 8, 128, 4 },
320  { 10, 256, 5 },
321  { 12, 256, 5 },
322  { 72, 256, 8 },
323  };
324  const unsigned int size = ARRAY_SIZE(testW);
326  ID3DXSprite *sprite;
327  int ref, i, height;
328  ID3DXFont *font;
329  HRESULT hr;
330  RECT rect;
331 
332  /* D3DXCreateFont */
333  ref = get_ref((IUnknown*)device);
335  ok(hr == D3D_OK, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3D_OK);
336  check_ref((IUnknown*)device, ref + 1);
339 
341  ok(hr == D3D_OK, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3D_OK);
343 
345  ok(hr == D3D_OK, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3D_OK);
347 
349  ok(hr == D3D_OK, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3D_OK);
351 
353  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
354 
356  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
357 
359  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
360 
361 
362  /* D3DXCreateFontIndirect */
363  desc.Height = 12;
364  desc.Width = 0;
365  desc.Weight = FW_DONTCARE;
366  desc.MipLevels = 0;
367  desc.Italic = FALSE;
368  desc.CharSet = DEFAULT_CHARSET;
369  desc.OutputPrecision = OUT_DEFAULT_PRECIS;
370  desc.Quality = DEFAULT_QUALITY;
371  desc.PitchAndFamily = DEFAULT_PITCH;
372  strcpy(desc.FaceName, "Arial");
374  ok(hr == D3D_OK, "D3DXCreateFontIndirect returned %#x, expected %#x\n", hr, D3D_OK);
376 
378  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateFontIndirect returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
379 
381  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateFontIndirect returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
382 
384  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateFontIndirect returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
385 
386 
387  /* ID3DXFont_GetDevice */
389  if(SUCCEEDED(hr)) {
390  IDirect3DDevice9 *bufdev;
391 
393  ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_GetDevice returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
394 
395  ref = get_ref((IUnknown*)device);
396  hr = ID3DXFont_GetDevice(font, &bufdev);
397  ok(hr == D3D_OK, "ID3DXFont_GetDevice returned %#x, expected %#x\n", hr, D3D_OK);
398  check_release((IUnknown*)bufdev, ref);
399 
401  } else skip("Failed to create a ID3DXFont object\n");
402 
403 
404  /* ID3DXFont_GetDesc */
406  if(SUCCEEDED(hr)) {
408  ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_GetDevice returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
409 
411  ok(hr == D3D_OK, "ID3DXFont_GetDevice returned %#x, expected %#x\n", hr, D3D_OK);
412 
413  ok(desc.Height == 12, "ID3DXFont_GetDesc returned font height %d, expected %d\n", desc.Height, 12);
414  ok(desc.Width == 8, "ID3DXFont_GetDesc returned font width %d, expected %d\n", desc.Width, 8);
415  ok(desc.Weight == FW_BOLD, "ID3DXFont_GetDesc returned font weight %d, expected %d\n", desc.Weight, FW_BOLD);
416  ok(desc.MipLevels == 2, "ID3DXFont_GetDesc returned font miplevels %d, expected %d\n", desc.MipLevels, 2);
417  ok(desc.Italic == TRUE, "ID3DXFont_GetDesc says Italic was %d, but Italic should be %d\n", desc.Italic, TRUE);
418  ok(desc.CharSet == ANSI_CHARSET, "ID3DXFont_GetDesc returned font charset %d, expected %d\n", desc.CharSet, ANSI_CHARSET);
419  ok(desc.OutputPrecision == OUT_RASTER_PRECIS, "ID3DXFont_GetDesc returned an output precision of %d, expected %d\n", desc.OutputPrecision, OUT_RASTER_PRECIS);
420  ok(desc.Quality == ANTIALIASED_QUALITY, "ID3DXFont_GetDesc returned font quality %d, expected %d\n", desc.Quality, ANTIALIASED_QUALITY);
421  ok(desc.PitchAndFamily == VARIABLE_PITCH, "ID3DXFont_GetDesc returned pitch and family %d, expected %d\n", desc.PitchAndFamily, VARIABLE_PITCH);
422  ok(strcmp(desc.FaceName, "Arial") == 0, "ID3DXFont_GetDesc returned facename \"%s\", expected \"%s\"\n", desc.FaceName, "Arial");
423 
425  } else skip("Failed to create a ID3DXFont object\n");
426 
427 
428  /* ID3DXFont_GetDC + ID3DXFont_GetTextMetrics */
430  if(SUCCEEDED(hr)) {
431  HDC hdc;
432 
434  ok(hdc != NULL, "ID3DXFont_GetDC returned an invalid handle\n");
435  if(hdc) {
436  TEXTMETRICA metrics, expmetrics;
437  BOOL ret;
438 
440  ok(ret, "ID3DXFont_GetTextMetricsA failed\n");
441  ret = GetTextMetricsA(hdc, &expmetrics);
442  ok(ret, "GetTextMetricsA failed\n");
443 
444  ok(metrics.tmHeight == expmetrics.tmHeight, "Returned height %d, expected %d\n", metrics.tmHeight, expmetrics.tmHeight);
445  ok(metrics.tmAscent == expmetrics.tmAscent, "Returned ascent %d, expected %d\n", metrics.tmAscent, expmetrics.tmAscent);
446  ok(metrics.tmDescent == expmetrics.tmDescent, "Returned descent %d, expected %d\n", metrics.tmDescent, expmetrics.tmDescent);
447  ok(metrics.tmInternalLeading == expmetrics.tmInternalLeading, "Returned internal leading %d, expected %d\n", metrics.tmInternalLeading, expmetrics.tmInternalLeading);
448  ok(metrics.tmExternalLeading == expmetrics.tmExternalLeading, "Returned external leading %d, expected %d\n", metrics.tmExternalLeading, expmetrics.tmExternalLeading);
449  ok(metrics.tmAveCharWidth == expmetrics.tmAveCharWidth, "Returned average char width %d, expected %d\n", metrics.tmAveCharWidth, expmetrics.tmAveCharWidth);
450  ok(metrics.tmMaxCharWidth == expmetrics.tmMaxCharWidth, "Returned maximum char width %d, expected %d\n", metrics.tmMaxCharWidth, expmetrics.tmMaxCharWidth);
451  ok(metrics.tmWeight == expmetrics.tmWeight, "Returned weight %d, expected %d\n", metrics.tmWeight, expmetrics.tmWeight);
452  ok(metrics.tmOverhang == expmetrics.tmOverhang, "Returned overhang %d, expected %d\n", metrics.tmOverhang, expmetrics.tmOverhang);
453  ok(metrics.tmDigitizedAspectX == expmetrics.tmDigitizedAspectX, "Returned digitized x aspect %d, expected %d\n", metrics.tmDigitizedAspectX, expmetrics.tmDigitizedAspectX);
454  ok(metrics.tmDigitizedAspectY == expmetrics.tmDigitizedAspectY, "Returned digitized y aspect %d, expected %d\n", metrics.tmDigitizedAspectY, expmetrics.tmDigitizedAspectY);
455  ok(metrics.tmFirstChar == expmetrics.tmFirstChar, "Returned first char %d, expected %d\n", metrics.tmFirstChar, expmetrics.tmFirstChar);
456  ok(metrics.tmLastChar == expmetrics.tmLastChar, "Returned last char %d, expected %d\n", metrics.tmLastChar, expmetrics.tmLastChar);
457  ok(metrics.tmDefaultChar == expmetrics.tmDefaultChar, "Returned default char %d, expected %d\n", metrics.tmDefaultChar, expmetrics.tmDefaultChar);
458  ok(metrics.tmBreakChar == expmetrics.tmBreakChar, "Returned break char %d, expected %d\n", metrics.tmBreakChar, expmetrics.tmBreakChar);
459  ok(metrics.tmItalic == expmetrics.tmItalic, "Returned italic %d, expected %d\n", metrics.tmItalic, expmetrics.tmItalic);
460  ok(metrics.tmUnderlined == expmetrics.tmUnderlined, "Returned underlined %d, expected %d\n", metrics.tmUnderlined, expmetrics.tmUnderlined);
461  ok(metrics.tmStruckOut == expmetrics.tmStruckOut, "Returned struck out %d, expected %d\n", metrics.tmStruckOut, expmetrics.tmStruckOut);
462  ok(metrics.tmPitchAndFamily == expmetrics.tmPitchAndFamily, "Returned pitch and family %d, expected %d\n", metrics.tmPitchAndFamily, expmetrics.tmPitchAndFamily);
463  ok(metrics.tmCharSet == expmetrics.tmCharSet, "Returned charset %d, expected %d\n", metrics.tmCharSet, expmetrics.tmCharSet);
464  }
466  } else skip("Failed to create a ID3DXFont object\n");
467 
468 
469  /* ID3DXFont_PreloadText */
471  if(SUCCEEDED(hr)) {
472  todo_wine {
474  ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_PreloadTextA returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
476  ok(hr == D3D_OK, "ID3DXFont_PreloadTextA returned %#x, expected %#x\n", hr, D3D_OK);
478  ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_PreloadTextA returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
479  hr = ID3DXFont_PreloadTextA(font, "test", -1);
480  ok(hr == D3D_OK, "ID3DXFont_PreloadTextA returned %#x, expected %#x\n", hr, D3D_OK);
481 
483  ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_PreloadTextW returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
485  ok(hr == D3D_OK, "ID3DXFont_PreloadTextW returned %#x, expected %#x\n", hr, D3D_OK);
487  ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_PreloadTextW returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
489  ok(hr == D3D_OK, "ID3DXFont_PreloadTextW returned %#x, expected %#x\n", hr, D3D_OK);
490  }
491 
493  } else skip("Failed to create a ID3DXFont object\n");
494 
495 
496  /* ID3DXFont_GetGlyphData, ID3DXFont_PreloadGlyphs, ID3DXFont_PreloadCharacters */
498  if(SUCCEEDED(hr)) {
499  char c;
500  HDC hdc;
501  DWORD ret;
502  HRESULT hr;
503  RECT blackbox;
504  POINT cellinc;
505  IDirect3DTexture9 *texture;
506 
508 
509  todo_wine {
510  hr = ID3DXFont_GetGlyphData(font, 0, NULL, &blackbox, &cellinc);
511  ok(hr == D3D_OK, "ID3DXFont_GetGlyphData returned %#x, expected %#x\n", hr, D3D_OK);
512  hr = ID3DXFont_GetGlyphData(font, 0, &texture, NULL, &cellinc);
514  ok(hr == D3D_OK, "ID3DXFont_GetGlyphData returned %#x, expected %#x\n", hr, D3D_OK);
515  hr = ID3DXFont_GetGlyphData(font, 0, &texture, &blackbox, NULL);
517  ok(hr == D3D_OK, "ID3DXFont_GetGlyphData returned %#x, expected %#x\n", hr, D3D_OK);
518  }
519  hr = ID3DXFont_PreloadCharacters(font, 'b', 'a');
520  ok(hr == D3D_OK, "ID3DXFont_PreloadCharacters returned %#x, expected %#x\n", hr, D3D_OK);
522  todo_wine ok(hr == D3D_OK, "ID3DXFont_PreloadGlyphs returned %#x, expected %#x\n", hr, D3D_OK);
523 
524  hr = ID3DXFont_PreloadCharacters(font, 'a', 'a');
525  ok(hr == D3D_OK, "ID3DXFont_PreloadCharacters returned %#x, expected %#x\n", hr, D3D_OK);
526 
527  for(c = 'b'; c <= 'z'; c++) {
528  WORD glyph;
529 
530  ret = GetGlyphIndicesA(hdc, &c, 1, &glyph, 0);
531  ok(ret != GDI_ERROR, "GetGlyphIndicesA failed\n");
532 
533  hr = ID3DXFont_GetGlyphData(font, glyph, &texture, &blackbox, &cellinc);
534  todo_wine ok(hr == D3D_OK, "ID3DXFont_GetGlyphData returned %#x, expected %#x\n", hr, D3D_OK);
535  if(SUCCEEDED(hr)) {
536  DWORD levels;
538 
540  ok(levels == 5, "Got levels %u, expected %u\n", levels, 5);
542  ok(hr == D3D_OK, "IDirect3DTexture9_GetLevelDesc failed\n");
543  ok(desc.Format == D3DFMT_A8R8G8B8, "Got format %#x, expected %#x\n", desc.Format, D3DFMT_A8R8G8B8);
544  ok(desc.Usage == 0, "Got usage %#x, expected %#x\n", desc.Usage, 0);
545  ok(desc.Width == 256, "Got width %u, expected %u\n", desc.Width, 256);
546  ok(desc.Height == 256, "Got height %u, expected %u\n", desc.Height, 256);
547  ok(desc.Pool == D3DPOOL_MANAGED, "Got pool %u, expected %u\n", desc.Pool, D3DPOOL_MANAGED);
548 
550  }
551  }
552 
553  hr = ID3DXFont_PreloadCharacters(font, 'a', 'z');
554  ok(hr == D3D_OK, "ID3DXFont_PreloadCharacters returned %#x, expected %#x\n", hr, D3D_OK);
555 
557  } else skip("Failed to create a ID3DXFont object\n");
558 
559  for (i = 0; i < ARRAY_SIZE(tests); ++i)
560  {
561  HDC hdc;
562  DWORD ret;
563  HRESULT hr;
564  WORD glyph;
565  char c = 'a';
566  IDirect3DTexture9 *texture;
567 
570  if(FAILED(hr)) {
571  skip("Failed to create a ID3DXFont object\n");
572  continue;
573  }
574 
576 
577  ret = GetGlyphIndicesA(hdc, &c, 1, &glyph, 0);
578  ok(ret != GDI_ERROR, "GetGlyphIndicesA failed\n");
579 
581  todo_wine ok(hr == D3D_OK, "ID3DXFont_GetGlyphData returned %#x, expected %#x\n", hr, D3D_OK);
582  if(SUCCEEDED(hr)) {
583  DWORD levels;
585 
587  ok(levels == tests[i].expected_levels, "Got levels %u, expected %u\n",
588  levels, tests[i].expected_levels);
590  ok(hr == D3D_OK, "IDirect3DTexture9_GetLevelDesc failed\n");
591  ok(desc.Format == D3DFMT_A8R8G8B8, "Got format %#x, expected %#x\n", desc.Format, D3DFMT_A8R8G8B8);
592  ok(desc.Usage == 0, "Got usage %#x, expected %#x\n", desc.Usage, 0);
593  ok(desc.Width == tests[i].expected_size, "Got width %u, expected %u\n",
594  desc.Width, tests[i].expected_size);
595  ok(desc.Height == tests[i].expected_size, "Got height %u, expected %u\n",
596  desc.Height, tests[i].expected_size);
597  ok(desc.Pool == D3DPOOL_MANAGED, "Got pool %u, expected %u\n", desc.Pool, D3DPOOL_MANAGED);
598 
600  }
601 
602  /* ID3DXFontImpl_DrawText */
604  SetRect(&rect, 0, 0, 640, 480);
605 
606  IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff000000, 1.0f, 0);
607 
610  ok (hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
611 
612  todo_wine
613  {
614  height = ID3DXFont_DrawTextW(font, sprite, testW, -1, &rect, DT_TOP, 0xffffffff);
615  ok(height == tests[i].font_height, "Got unexpected height %u.\n", height);
616  height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, DT_TOP, 0xffffffff);
617  ok(height == tests[i].font_height, "Got unexpected height %u.\n", height);
619  ok(height == tests[i].font_height, "Got unexpected height %u.\n", height);
621  0xffffffff);
622  ok(height == tests[i].font_height, "Got unexpected height %u.\n", height);
623  }
624 
625  SetRectEmpty(&rect);
627  DT_LEFT | DT_CALCRECT, 0xffffffff);
628  todo_wine ok(height == tests[i].font_height, "Got unexpected height %u.\n", height);
629  ok(!rect.left, "Got unexpected rect left %d.\n", rect.left);
630  ok(!rect.top, "Got unexpected rect top %d.\n", rect.top);
631  todo_wine ok(rect.right, "Got unexpected rect right %d.\n", rect.right);
632  todo_wine ok(rect.bottom == tests[i].font_height, "Got unexpected rect bottom %d.\n", rect.bottom);
633 
635  ok (hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
638 
640  }
641 
642  /* ID3DXFont_DrawTextA, ID3DXFont_DrawTextW */
644  if (SUCCEEDED(hr)) {
645  RECT rect;
646  int height;
647 
648  SetRect(&rect, 10, 10, 200, 200);
649 
650  height = ID3DXFont_DrawTextA(font, NULL, testA, -2, &rect, 0, 0xFF00FF);
651  ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
652 
653  height = ID3DXFont_DrawTextA(font, NULL, testA, -1, &rect, 0, 0xFF00FF);
654  ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
655 
656  height = ID3DXFont_DrawTextA(font, NULL, testA, 0, &rect, 0, 0xFF00FF);
657  ok(height == 0, "DrawTextA returned %d, expected 0.\n", height);
658 
659  height = ID3DXFont_DrawTextA(font, NULL, testA, 1, &rect, 0, 0xFF00FF);
660  ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
661 
662  height = ID3DXFont_DrawTextA(font, NULL, testA, 2, &rect, 0, 0xFF00FF);
663  ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
664 
665  height = ID3DXFont_DrawTextA(font, NULL, testA, -1, NULL, 0, 0xFF00FF);
666  ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
667 
669  ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
670 
671  height = ID3DXFont_DrawTextA(font, NULL, NULL, -1, NULL, 0, 0xFF00FF);
672  ok(height == 0, "DrawTextA returned %d, expected 0.\n", height);
673 
674 if (0) { /* Causes a lockup on windows 7. */
675  height = ID3DXFont_DrawTextW(font, NULL, testW, -2, &rect, 0, 0xFF00FF);
676  ok(height == 12, "DrawTextW returned %d, expected 12.\n", height);
677 }
678 
679  height = ID3DXFont_DrawTextW(font, NULL, testW, -1, &rect, 0, 0xFF00FF);
680  ok(height == 12, "DrawTextW returned %d, expected 12.\n", height);
681 
682  height = ID3DXFont_DrawTextW(font, NULL, testW, 0, &rect, 0, 0xFF00FF);
683  ok(height == 0, "DrawTextW returned %d, expected 0.\n", height);
684 
685  height = ID3DXFont_DrawTextW(font, NULL, testW, 1, &rect, 0, 0xFF00FF);
686  ok(height == 12, "DrawTextW returned %d, expected 12.\n", height);
687 
688  height = ID3DXFont_DrawTextW(font, NULL, testW, 2, &rect, 0, 0xFF00FF);
689  ok(height == 12, "DrawTextW returned %d, expected 12.\n", height);
690 
691  height = ID3DXFont_DrawTextW(font, NULL, testW, -1, NULL, 0, 0xFF00FF);
692  ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
693 
695  ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
696 
697  height = ID3DXFont_DrawTextW(font, NULL, NULL, -1, NULL, 0, 0xFF00FF);
698  ok(height == 0, "DrawTextA returned %d, expected 0.\n", height);
699 
701  }
702 }
703 
704 static void test_D3DXCreateRenderToSurface(IDirect3DDevice9 *device)
705 {
706  int i;
707  HRESULT hr;
708  ULONG ref_count;
710  ID3DXRenderToSurface *render = (void *)0xdeadbeef;
711  static const D3DXRTS_DESC tests[] =
712  {
713  { 0, 256, D3DFMT_A8R8G8B8, FALSE, D3DFMT_UNKNOWN },
714  { 256, 0, D3DFMT_A8R8G8B8, FALSE, D3DFMT_UNKNOWN },
715  { 256, 0, D3DFMT_A8R8G8B8, FALSE, D3DFMT_D24S8 },
716  { 256, 256, D3DFMT_UNKNOWN, FALSE, D3DFMT_R8G8B8 },
717  { 0, 0, D3DFMT_UNKNOWN, FALSE, D3DFMT_UNKNOWN },
718  { -1, -1, MAKEFOURCC('B','A','D','F'), TRUE, MAKEFOURCC('B','A','D','F') }
719  };
720 
722  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateRenderToSurface returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
723  ok(render == (void *)0xdeadbeef, "Got %p, expected %p\n", render, (void *)0xdeadbeef);
724 
726  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateRenderToSurface returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
727 
728  for (i = 0; i < ARRAY_SIZE(tests); i++)
729  {
730  hr = D3DXCreateRenderToSurface(device, tests[i].Width, tests[i].Height, tests[i].Format, tests[i].DepthStencil,
731  tests[i].DepthStencilFormat, &render);
732  ok(hr == D3D_OK, "%d: D3DXCreateRenderToSurface returned %#x, expected %#x\n", i, hr, D3D_OK);
733  if (SUCCEEDED(hr))
734  {
736  ok(hr == D3D_OK, "%d: GetDesc failed %#x\n", i, hr);
737  if (SUCCEEDED(hr))
738  {
739  ok(desc.Width == tests[i].Width, "%d: Got width %u, expected %u\n", i, desc.Width, tests[i].Width);
740  ok(desc.Height == tests[i].Height, "%d: Got height %u, expected %u\n", i, desc.Height, tests[i].Height);
741  ok(desc.Format == tests[i].Format, "%d: Got format %#x, expected %#x\n", i, desc.Format, tests[i].Format);
742  ok(desc.DepthStencil == tests[i].DepthStencil, "%d: Got depth stencil %d, expected %d\n",
743  i, desc.DepthStencil, tests[i].DepthStencil);
744  ok(desc.DepthStencilFormat == tests[i].DepthStencilFormat, "%d: Got depth stencil format %#x, expected %#x\n",
745  i, desc.DepthStencilFormat, tests[i].DepthStencilFormat);
746  }
748  }
749  }
750 
751  /* check device ref count */
752  ref_count = get_ref((IUnknown *)device);
754  check_ref((IUnknown *)device, ref_count + 1);
756 }
757 
758 /* runs a set of tests for the ID3DXRenderToSurface interface created with given parameters */
760  BOOL depth_stencil, D3DFORMAT depth_stencil_format, BOOL render_target)
761 {
762  HRESULT hr;
763  D3DFORMAT fmt;
764  HRESULT expected_value;
765  IDirect3DSurface9 *surface;
766  ID3DXRenderToSurface *render;
767  D3DVIEWPORT9 viewport = { 0, 0, width, height, 0.0, 1.0 };
768 
769  hr = D3DXCreateRenderToSurface(device, width, height, format, depth_stencil, depth_stencil_format, &render);
770  if (FAILED(hr))
771  {
772  skip("Failed to create ID3DXRenderToSurface\n");
773  return;
774  }
775 
776  if (render_target)
778  else
780  if (FAILED(hr))
781  {
782  skip("Failed to create surface\n");
784  return;
785  }
786 
787  /* viewport */
788  hr = ID3DXRenderToSurface_BeginScene(render, surface, &viewport);
789  ok(hr == D3D_OK, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3D_OK);
790  check_ref((IUnknown *)surface, 2);
792 
793  /* invalid viewport */
794  viewport.Width = 2 * width;
795  hr = ID3DXRenderToSurface_BeginScene(render, surface, &viewport);
796  ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
797 
798  viewport.X = width / 2;
799  viewport.Width = width;
800  hr = ID3DXRenderToSurface_BeginScene(render, surface, &viewport);
801  ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
802 
803  viewport.X = width;
804  viewport.Width = width;
805  hr = ID3DXRenderToSurface_BeginScene(render, surface, &viewport);
806  ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
807 
808  /* rendering to a part of a surface is only allowed for render target surfaces */
809  expected_value = render_target ? D3D_OK : D3DERR_INVALIDCALL;
810 
811  viewport.X = 0;
812  viewport.Width = width / 2;
813  hr = ID3DXRenderToSurface_BeginScene(render, surface, &viewport);
814  ok(hr == expected_value, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, expected_value);
816 
817  viewport.X = width / 2;
818  viewport.Width = width - width / 2;
819  hr = ID3DXRenderToSurface_BeginScene(render, surface, &viewport);
820  ok(hr == expected_value, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, expected_value);
822 
823  check_release((IUnknown *)surface, 0);
824 
825  /* surfaces with different sizes */
827  if (FAILED(hr))
828  {
829  skip("Failed to create surface\n");
831  return;
832  }
834  ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
835  check_release((IUnknown *)surface, 0);
836 
838  if (FAILED(hr))
839  {
840  skip("Failed to create surface\n");
842  return;
843  }
845  ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
846  viewport.X = 0;
847  viewport.Y = 0;
848  viewport.Width = width;
849  viewport.Height = height;
850  hr = ID3DXRenderToSurface_BeginScene(render, surface, &viewport);
851  ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
852  check_release((IUnknown *)surface, 0);
853 
854  /* surfaces with different formats */
855  for (fmt = D3DFMT_A8R8G8B8; fmt <= D3DFMT_X8R8G8B8; fmt++)
856  {
858 
860  if (FAILED(hr))
861  {
862  skip("Failed to create surface\n");
863  continue;
864  }
865 
867  ok(hr == expected_result, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, expected_result);
868 
870  check_release((IUnknown *)surface, 0);
871  }
872 
874 }
875 
876 struct device_state
877 {
878  IDirect3DSurface9 *render_target;
879  IDirect3DSurface9 *depth_stencil;
881 };
882 
884 {
885  if (state->render_target) IDirect3DSurface9_Release(state->render_target);
886  if (state->depth_stencil) IDirect3DSurface9_Release(state->depth_stencil);
887  memset(state, 0, sizeof(*state));
888 }
889 
890 static HRESULT retrieve_device_state(IDirect3DDevice9 *device, struct device_state *state)
891 {
892  HRESULT hr;
893 
894  memset(state, 0, sizeof(*state));
895 
896  hr = IDirect3DDevice9_GetRenderTarget(device, 0, &state->render_target);
897  if (FAILED(hr)) goto cleanup;
898 
900  if (hr == D3DERR_NOTFOUND)
901  state->depth_stencil = NULL;
902  else if (FAILED(hr))
903  goto cleanup;
904 
906  if (SUCCEEDED(hr)) return hr;
907 
908 cleanup:
910  return hr;
911 }
912 
913 static HRESULT apply_device_state(IDirect3DDevice9 *device, struct device_state *state)
914 {
915  HRESULT hr;
917 
918  hr = IDirect3DDevice9_SetRenderTarget(device, 0, state->render_target);
919  if (FAILED(hr)) status = hr;
920 
922  if (FAILED(hr)) status = hr;
923 
925  if (FAILED(hr)) status = hr;
926 
927  return status;
928 }
929 
930 static void compare_device_state(struct device_state *state1, struct device_state *state2, BOOL equal)
931 {
932  BOOL cmp;
933  const char *message = equal ? "differs" : "is the same";
934 
935  cmp = state1->render_target == state2->render_target;
936  ok(equal ? cmp : !cmp, "Render target %s %p, %p\n", message, state1->render_target, state2->render_target);
937 
938  cmp = state1->depth_stencil == state2->depth_stencil;
939  ok(equal ? cmp : !cmp, "Depth stencil surface %s %p, %p\n", message, state1->depth_stencil, state2->depth_stencil);
940 
941  cmp = state1->viewport.X == state2->viewport.X && state1->viewport.Y == state2->viewport.Y
942  && state1->viewport.Width == state2->viewport.Width && state1->viewport.Height == state2->viewport.Height;
943  ok(equal ? cmp : !cmp, "Viewport %s (%u, %u, %u, %u), (%u, %u, %u, %u)\n", message,
944  state1->viewport.X, state1->viewport.Y, state1->viewport.Width, state1->viewport.Height,
945  state2->viewport.X, state2->viewport.Y, state2->viewport.Width, state2->viewport.Height);
946 }
947 
948 static void test_ID3DXRenderToSurface_device_state(IDirect3DDevice9 *device)
949 {
950  HRESULT hr;
951  IDirect3DSurface9 *surface = NULL;
952  ID3DXRenderToSurface *render = NULL;
953  struct device_state pre_state;
954  struct device_state current_state;
955  IDirect3DSurface9 *depth_stencil_surface;
956 
957  /* make sure there is a depth stencil surface present */
958  hr = IDirect3DDevice9_GetDepthStencilSurface(device, &depth_stencil_surface);
959  if (SUCCEEDED(hr))
960  {
961  IDirect3DSurface9_Release(depth_stencil_surface);
962  depth_stencil_surface = NULL;
963  }
964  else if (hr == D3DERR_NOTFOUND)
965  {
967  D3DMULTISAMPLE_NONE, 0, TRUE, &depth_stencil_surface, NULL);
968  if (SUCCEEDED(hr)) IDirect3DDevice9_SetDepthStencilSurface(device, depth_stencil_surface);
969  }
970 
971  if (FAILED(hr))
972  {
973  skip("Failed to create depth stencil surface\n");
974  return;
975  }
976 
978  FALSE, &surface, NULL);
979  if (FAILED(hr))
980  {
981  skip("Failed to create render target\n");
982  goto cleanup;
983  }
984 
985  hr = retrieve_device_state(device, &pre_state);
986  ok(SUCCEEDED(hr), "Failed to retrieve device state\n");
987 
989  ok(hr == D3D_OK, "D3DXCreateRenderToSurface returned %#x, expected %#x\n", hr, D3D_OK);
990  if (SUCCEEDED(hr))
991  {
993  ok(hr == D3D_OK, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3D_OK);
994 
995  hr = retrieve_device_state(device, &current_state);
996  ok(SUCCEEDED(hr), "Failed to retrieve device state\n");
997  compare_device_state(&current_state, &pre_state, FALSE);
998  release_device_state(&current_state);
999 
1001  ok(hr == D3D_OK, "ID3DXRenderToSurface::EndScene returned %#x, expected %#x\n", hr, D3D_OK);
1002 
1003  hr = retrieve_device_state(device, &current_state);
1004  ok(SUCCEEDED(hr), "Failed to retrieve device state\n");
1005  compare_device_state(&current_state, &pre_state, TRUE);
1006  release_device_state(&current_state);
1007 
1008  check_release((IUnknown *)render, 0);
1009  }
1010 
1012  if (SUCCEEDED(hr))
1013  {
1015  ok(hr == D3D_OK, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3D_OK);
1016 
1017  hr = retrieve_device_state(device, &current_state);
1018  ok(SUCCEEDED(hr), "Failed to retrieve device state\n");
1019  compare_device_state(&current_state, &pre_state, FALSE);
1020  release_device_state(&current_state);
1021 
1023  ok(hr == D3D_OK, "ID3DXRenderToSurface::EndScene returned %#x, expected %#x\n", hr, D3D_OK);
1024 
1025  hr = retrieve_device_state(device, &current_state);
1026  ok(SUCCEEDED(hr), "Failed to retrieve device state\n");
1027  compare_device_state(&current_state, &pre_state, TRUE);
1028  release_device_state(&current_state);
1029 
1031  ok(hr == D3D_OK, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3D_OK);
1032 
1033  hr = retrieve_device_state(device, &current_state);
1034  ok(SUCCEEDED(hr), "Failed to retrieve device state\n");
1035  compare_device_state(&current_state, &pre_state, FALSE);
1036  release_device_state(&current_state);
1037 
1038  check_release((IUnknown *)render, 0);
1039 
1040  /* if EndScene isn't called, the device state isn't restored */
1041  hr = retrieve_device_state(device, &current_state);
1042  ok(SUCCEEDED(hr), "Failed to retrieve device state\n");
1043  compare_device_state(&current_state, &pre_state, FALSE);
1044  release_device_state(&current_state);
1045 
1046  hr = apply_device_state(device, &pre_state);
1047  ok(SUCCEEDED(hr), "Failed to restore previous device state\n");
1048 
1050  }
1051 
1052  release_device_state(&pre_state);
1053 
1054 cleanup:
1055  if (depth_stencil_surface)
1056  {
1058  IDirect3DSurface9_Release(depth_stencil_surface);
1059  }
1060 
1061  if (surface) check_release((IUnknown *)surface, 0);
1062 }
1063 
1064 static void test_ID3DXRenderToSurface(IDirect3DDevice9 *device)
1065 {
1066  int i;
1067  HRESULT hr;
1068  ULONG ref_count;
1069  IDirect3DDevice9 *out_device;
1070  ID3DXRenderToSurface *render;
1071  IDirect3DSurface9 *surface;
1072  D3DVIEWPORT9 viewport = { 0, 0, 256, 256, 0.0, 1.0 };
1073  D3DXRTS_DESC tests[] = {
1074  { 256, 256, D3DFMT_A8R8G8B8, FALSE, D3DFMT_UNKNOWN },
1075  { 256, 256, D3DFMT_A8R8G8B8, TRUE, D3DFMT_D24S8 },
1076  { 256, 256, D3DFMT_A8R8G8B8, TRUE, D3DFMT_D24X8 },
1077  { 512, 512, D3DFMT_X8R8G8B8, FALSE, D3DFMT_X8R8G8B8 },
1078  { 1024, 1024, D3DFMT_X8R8G8B8, TRUE, D3DFMT_D24S8 }
1079  };
1080 
1082  ok(hr == D3D_OK, "D3DXCreateRenderToSurface returned %#x, expected %#x\n", hr, D3D_OK);
1083  if (FAILED(hr)) return;
1084 
1086  if (SUCCEEDED(hr))
1087  {
1088  ID3DXRenderToSurface *render_surface;
1089 
1090  /* GetDevice */
1091  hr = ID3DXRenderToSurface_GetDevice(render, NULL /* device */);
1092  ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToSurface::GetDevice returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
1093 
1094  ref_count = get_ref((IUnknown *)device);
1095  hr = ID3DXRenderToSurface_GetDevice(render, &out_device);
1096  ok(hr == D3D_OK, "ID3DXRenderToSurface::GetDevice returned %#x, expected %#x\n", hr, D3D_OK);
1097  check_release((IUnknown *)out_device, ref_count);
1098 
1099  /* BeginScene and EndScene */
1101  ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToSurface::EndScene returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
1102 
1104  ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
1105 
1106  ref_count = get_ref((IUnknown *)surface);
1108  ok(hr == D3D_OK, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3D_OK);
1109  if (SUCCEEDED(hr))
1110  {
1111  check_ref((IUnknown *)surface, ref_count + 1);
1112 
1114  ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
1115 
1117  ok(hr == D3D_OK, "ID3DXRenderToSurface::EndScene returned %#x, expected %#x\n", hr, D3D_OK);
1118 
1119  check_ref((IUnknown *)surface, ref_count);
1120  }
1121 
1122  /* error handling is deferred to BeginScene */
1123  hr = D3DXCreateRenderToSurface(device, 256, 256, D3DFMT_A8R8G8B8, TRUE, D3DFMT_UNKNOWN, &render_surface);
1124  ok(hr == D3D_OK, "D3DXCreateRenderToSurface returned %#x, expected %#x\n", hr, D3D_OK);
1125  hr = ID3DXRenderToSurface_BeginScene(render_surface, surface, NULL);
1126  ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToSurface::BeginScene returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
1127  check_release((IUnknown *)render_surface, 0);
1128 
1129  check_release((IUnknown *)surface, 0);
1130  }
1131  else skip("Failed to create surface\n");
1132 
1133  check_release((IUnknown *)render, 0);
1134 
1135  for (i = 0; i < ARRAY_SIZE(tests); i++)
1136  {
1137  check_ID3DXRenderToSurface(device, tests[i].Width, tests[i].Height, tests[i].Format, tests[i].DepthStencil, tests[i].DepthStencilFormat, TRUE);
1138  check_ID3DXRenderToSurface(device, tests[i].Width, tests[i].Height, tests[i].Format, tests[i].DepthStencil, tests[i].DepthStencilFormat, FALSE);
1139  }
1140 
1142 }
1143 
1144 static void test_D3DXCreateRenderToEnvMap(IDirect3DDevice9 *device)
1145 {
1146  int i;
1147  HRESULT hr;
1148  ULONG ref_count;
1150  ID3DXRenderToEnvMap *render;
1151  static const struct {
1152  D3DXRTE_DESC parameters;
1153  D3DXRTE_DESC expected_values;
1154  } tests[] = {
1156  { { 256, 0, D3DFMT_A8R8G8B8, FALSE, D3DFMT_UNKNOWN }, { 256, 9, D3DFMT_A8R8G8B8, FALSE, D3DFMT_UNKNOWN } },
1157  { { 256, 4, D3DFMT_A8R8G8B8, FALSE, D3DFMT_D24S8 }, { 256, 4, D3DFMT_A8R8G8B8, FALSE, D3DFMT_D24S8 } },
1158  { { 256, 256, D3DFMT_UNKNOWN, FALSE, D3DFMT_R8G8B8 }, { 256, 9, D3DFMT_A8R8G8B8, FALSE, D3DFMT_R8G8B8 } },
1159  { { -1, -1, D3DFMT_A8R8G8B8, TRUE, D3DFMT_DXT1 }, { 256, 9, D3DFMT_A8R8G8B8, TRUE, D3DFMT_DXT1 } },
1160  { { 256, 1, D3DFMT_X8R8G8B8, TRUE, D3DFMT_UNKNOWN }, { 256, 1, D3DFMT_X8R8G8B8, TRUE, D3DFMT_UNKNOWN } }
1161  };
1162 
1163  for (i = 0; i < ARRAY_SIZE(tests); i++)
1164  {
1165  const D3DXRTE_DESC *parameters = &tests[i].parameters;
1166  const D3DXRTE_DESC *expected = &tests[i].expected_values;
1167  hr = D3DXCreateRenderToEnvMap(device, parameters->Size, parameters->MipLevels, parameters->Format,
1168  parameters->DepthStencil, parameters->DepthStencilFormat, &render);
1169  ok(hr == D3D_OK, "%d: D3DXCreateRenderToEnvMap returned %#x, expected %#x\n", i, hr, D3D_OK);
1170  if (SUCCEEDED(hr))
1171  {
1173  ok(hr == D3D_OK, "%d: GetDesc failed %#x\n", i, hr);
1174  if (SUCCEEDED(hr))
1175  {
1176  ok(desc.Size == expected->Size, "%d: Got size %u, expected %u\n", i, desc.Size, expected->Size);
1177  ok(desc.MipLevels == expected->MipLevels, "%d: Got miplevels %u, expected %u\n", i, desc.MipLevels, expected->MipLevels);
1178  ok(desc.Format == expected->Format, "%d: Got format %#x, expected %#x\n", i, desc.Format, expected->Format);
1179  ok(desc.DepthStencil == expected->DepthStencil, "%d: Got depth stencil %d, expected %d\n",
1180  i, expected->DepthStencil, expected->DepthStencil);
1181  ok(desc.DepthStencilFormat == expected->DepthStencilFormat, "%d: Got depth stencil format %#x, expected %#x\n",
1182  i, expected->DepthStencilFormat, expected->DepthStencilFormat);
1183  }
1184  check_release((IUnknown *)render, 0);
1185  }
1186  }
1187 
1188  /* check device ref count */
1189  ref_count = get_ref((IUnknown *)device);
1191  check_ref((IUnknown *)device, ref_count + 1);
1193 }
1194 
1195 static void test_ID3DXRenderToEnvMap_cube_map(IDirect3DDevice9 *device)
1196 {
1197  HRESULT hr;
1198  IDirect3DCubeTexture9 *cube_texture = NULL;
1199  ID3DXRenderToEnvMap *render = NULL;
1200  struct device_state pre_state;
1201  struct device_state current_state;
1202 
1204  &cube_texture, NULL);
1205  if (FAILED(hr))
1206  {
1207  skip("Failed to create cube texture\n");
1208  return;
1209  }
1210 
1211  hr = retrieve_device_state(device, &pre_state);
1212  ok(SUCCEEDED(hr), "Failed to retrieve device state\n");
1213 
1215  ok(hr == D3D_OK, "D3DCreateRenderToEnvMap returned %#x, expected %#x\n", hr, D3D_OK);
1216  if (SUCCEEDED(hr))
1217  {
1218  DWORD face;
1219 
1221  ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToEnvMap::End returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
1222 
1223  hr = ID3DXRenderToEnvMap_BeginCube(render, cube_texture);
1224  ok(hr == D3D_OK, "ID3DXRenderToEnvMap::BeginCube returned %#x, expected %#x\n", hr, D3D_OK);
1225 
1226  hr = retrieve_device_state(device, &current_state);
1227  ok(SUCCEEDED(hr), "Failed to retrieve device state\n");
1228  compare_device_state(&current_state, &pre_state, TRUE);
1229  release_device_state(&current_state);
1230 
1232  {
1234  ok(hr == D3D_OK, "ID3DXRenderToEnvMap::Face returned %#x, expected %#x\n", hr, D3D_OK);
1235 
1236  hr = retrieve_device_state(device, &current_state);
1237  ok(SUCCEEDED(hr), "Failed to retrieve device state\n");
1238  compare_device_state(&current_state, &pre_state, FALSE);
1239  release_device_state(&current_state);
1240  }
1241 
1243  ok(hr == D3D_OK, "ID3DXRenderToEnvMap::End returned %#x, expected %#x\n", hr, D3D_OK);
1244 
1245  hr = retrieve_device_state(device, &current_state);
1246  ok(SUCCEEDED(hr), "Failed to retrieve device state\n");
1247  compare_device_state(&current_state, &pre_state, TRUE);
1248  release_device_state(&current_state);
1249 
1250  check_release((IUnknown *)render, 0);
1251  }
1252 
1253  release_device_state(&pre_state);
1254 
1255  check_release((IUnknown *)cube_texture, 0);
1256 }
1257 
1258 static void test_ID3DXRenderToEnvMap(IDirect3DDevice9 *device)
1259 {
1260  HRESULT hr;
1261  ID3DXRenderToEnvMap *render;
1262  IDirect3DSurface9 *depth_stencil_surface;
1263 
1265  if (SUCCEEDED(hr))
1266  {
1267  ULONG ref_count;
1268  IDirect3DDevice9 *out_device;
1269 
1271  ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToEnvMap::GetDesc returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
1272 
1274  ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToEnvMap::GetDevice returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
1275 
1276  ref_count = get_ref((IUnknown *)device);
1277  hr = ID3DXRenderToEnvMap_GetDevice(render, &out_device);
1278  ok(hr == D3D_OK, "ID3DXRenderToEnvMap::GetDevice returned %#x, expected %#x\n", hr, D3D_OK);
1279  ok(out_device == device, "ID3DXRenderToEnvMap::GetDevice returned different device\n");
1280  check_release((IUnknown *)device, ref_count);
1281 
1283  ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToEnvMap::End returned %#x, expected %#x\n", hr, D3D_OK);
1284 
1286  ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToEnvMap::BeginCube returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
1287 
1289  todo_wine ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToEnvMap::BeginHemisphere returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
1290 
1292  todo_wine ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToEnvMap::BeginParabolic returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
1293 
1295  todo_wine ok(hr == D3DERR_INVALIDCALL, "ID3DXRenderToEnvMap::BeginSphere returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
1296 
1297  check_release((IUnknown *)render, 0);
1298  } else skip("Failed to create ID3DXRenderToEnvMap\n");
1299 
1300  /* make sure there is a depth stencil surface present */
1301  hr = IDirect3DDevice9_GetDepthStencilSurface(device, &depth_stencil_surface);
1302  if (SUCCEEDED(hr))
1303  {
1304  IDirect3DSurface9_Release(depth_stencil_surface);
1305  depth_stencil_surface = NULL;
1306  }
1307  else if (hr == D3DERR_NOTFOUND)
1308  {
1310  D3DMULTISAMPLE_NONE, 0, TRUE, &depth_stencil_surface, NULL);
1311  if (SUCCEEDED(hr)) IDirect3DDevice9_SetDepthStencilSurface(device, depth_stencil_surface);
1312  }
1313 
1314  if (FAILED(hr))
1315  {
1316  skip("Failed to create depth stencil surface\n");
1317  return;
1318  }
1319 
1321 
1322  if (depth_stencil_surface)
1323  {
1325  IDirect3DSurface9_Release(depth_stencil_surface);
1326  }
1327 }
1328 
1330 {
1331  HWND wnd;
1332  IDirect3D9 *d3d;
1333  IDirect3DDevice9 *device;
1334  D3DPRESENT_PARAMETERS d3dpp;
1335  HRESULT hr;
1336 
1337  if (!(wnd = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0,
1338  640, 480, NULL, NULL, NULL, NULL)))
1339  {
1340  skip("Couldn't create application window\n");
1341  return;
1342  }
1343  if (!(d3d = Direct3DCreate9(D3D_SDK_VERSION)))
1344  {
1345  skip("Couldn't create IDirect3D9 object\n");
1346  DestroyWindow(wnd);
1347  return;
1348  }
1349 
1350  ZeroMemory(&d3dpp, sizeof(d3dpp));
1351  d3dpp.Windowed = TRUE;
1354  if(FAILED(hr)) {
1355  skip("Failed to create IDirect3DDevice9 object %#x\n", hr);
1356  IDirect3D9_Release(d3d);
1357  DestroyWindow(wnd);
1358  return;
1359  }
1360 
1361  test_ID3DXBuffer();
1368 
1370  check_release((IUnknown*)d3d, 0);
1371  if (wnd) DestroyWindow(wnd);
1372 }
#define IDirect3D9_CreateDevice(p, a, b, c, d, e, f)
Definition: d3d9.h:235
#define D3DADAPTER_DEFAULT
Definition: d3d8.h:57
#define D3DUSAGE_DYNAMIC
Definition: d3d8types.h:99
#define IDirect3DSurface9_Release(p)
Definition: d3d9.h:622
D3DVIEWPORT9 viewport
Definition: render.c:32
#define IDirect3D9_CheckDeviceFormat(p, a, b, c, d, e, f)
Definition: d3d9.h:229
GLint GLint GLsizei width
Definition: gl.h:1546
#define ANTIALIASED_QUALITY
Definition: wingdi.h:439
Definition: tftpd.h:59
#define ID3DXRenderToSurface_GetDevice(p, a)
Definition: d3dx9core.h:392
#define IDirect3DDevice9_Clear(p, a, b, c, d, e, f)
Definition: d3d9.h:1550
#define D3DCREATE_SOFTWARE_VERTEXPROCESSING
Definition: d3d8.h:44
HRESULT WINAPI D3DXCreateRenderToSurface(IDirect3DDevice9 *device, UINT width, UINT height, D3DFORMAT format, BOOL depth_stencil, D3DFORMAT depth_stencil_format, ID3DXRenderToSurface **out)
Definition: render.c:374
#define VARIABLE_PITCH
Definition: wingdi.h:444
#define ID3DXRenderToEnvMap_End(p, a)
Definition: d3dx9core.h:337
static void test_D3DXCreateRenderToSurface(IDirect3DDevice9 *device)
Definition: core.c:704
#define DEFAULT_QUALITY
Definition: wingdi.h:435
HRESULT hr
Definition: shlfolder.c:183
GLsizei levels
Definition: glext.h:7884
GLsizei GLenum const GLvoid GLuint GLsizei GLfloat * metrics
Definition: glext.h:11745
#define ID3DXSprite_GetTransform(p, a)
Definition: d3dx9core.h:445
Definition: mk_font.cpp:20
DWORD WINAPI GetGlyphIndicesA(_In_ HDC hdc, _In_reads_(c) LPCSTR lpstr, _In_ int c, _Out_writes_(c) LPWORD pgi, _In_ DWORD fl)
#define TRUE
Definition: types.h:120
static struct test_info tests[]
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define ID3DXSprite_Draw(p, a, b, c, d, e)
Definition: d3dx9core.h:450
#define U(x)
Definition: wordpad.c:45
BOOL DepthStencil
Definition: d3dx9core.h:295
#define IDirect3DTexture9_Release(p)
Definition: d3d9.h:1014
HRESULT WINAPI D3DXCreateBuffer(DWORD size, ID3DXBuffer **buffer)
Definition: core.c:129
static HDC
Definition: imagelist.c:92
#define IDirect3DDevice9_SetViewport(p, a)
Definition: d3d9.h:1554
#define D3DX_FILTER_NONE
Definition: d3dx9tex.h:27
const char * fmt
Definition: wsprintf.c:30
#define equal(x, y)
Definition: reader.cc:56
#define ID3DXSprite_GetDevice(p, a)
Definition: d3dx9core.h:444
#define ID3DXRenderToSurface_EndScene(p, a)
Definition: d3dx9core.h:395
#define ID3DXFont_GetDescA(p, a)
Definition: d3dx9core.h:169
#define D3DERR_INVALIDCALL
#define ID3DXRenderToSurface_Release(p)
Definition: d3dx9core.h:390
UINT MipLevels
Definition: d3dx9core.h:293
static void test_ID3DXBuffer(void)
Definition: core.c:67
#define ID3DXRenderToEnvMap_GetDevice(p, a)
Definition: d3dx9core.h:330
#define ID3DXRenderToEnvMap_Release(p)
Definition: d3dx9core.h:328
#define ZeroMemory
Definition: winbase.h:1648
GLuint buffer
Definition: glext.h:5915
static const MAT2 mat
Definition: font.c:66
#define IDirect3DDevice9_CreateRenderTarget(p, a, b, c, d, e, f, g, h)
Definition: d3d9.h:1535
#define IDirect3DTexture9_GetLevelCount(p)
Definition: d3d9.h:1027
#define D3DERR_NOTFOUND
Definition: d3d8.h:80
#define DT_RIGHT
Definition: winuser.h:538
#define cmp(status, error)
Definition: error.c:114
static void release_device_state(struct device_state *state)
Definition: core.c:883
LONG tmAveCharWidth
Definition: wingdi.h:2365
#define DEFAULT_CHARSET
Definition: wingdi.h:383
BYTE tmLastChar
Definition: wingdi.h:2372
LONG tmWeight
Definition: wingdi.h:2367
BOOL WINAPI DestroyWindow(_In_ HWND)
#define IDirect3DDevice9_SetDepthStencilSurface(p, a)
Definition: d3d9.h:1546
Definition: send.c:48
#define IDirect3DDevice9_GetDepthStencilSurface(p, a)
Definition: d3d9.h:1547
& rect
Definition: startmenu.cpp:1413
IDirect3D9 *WINAPI Direct3DCreate9(UINT SDKVersion)
Definition: d3d9.c:57
#define ID3DXRenderToEnvMap_BeginSphere(p, a)
Definition: d3dx9core.h:333
const GLfloat * m
Definition: glext.h:10848
static int get_ref(IUnknown *obj)
Definition: core.c:26
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
LONG tmDigitizedAspectY
Definition: wingdi.h:2370
#define IDirect3DDevice9_CreateDepthStencilSurface(p, a, b, c, d, e, f, g, h)
Definition: d3d9.h:1536
#define IDirect3DTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:1032
#define IDirect3DDevice9_SetRenderTarget(p, a, b)
Definition: d3d9.h:1544
BYTE tmPitchAndFamily
Definition: wingdi.h:2378
#define IDirect3DDevice9_CreateOffscreenPlainSurface(p, a, b, c, d, e, f)
Definition: d3d9.h:1543
BYTE tmUnderlined
Definition: wingdi.h:2376
#define IDirect3D9_Release(p)
Definition: d3d9.h:220
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
BYTE tmCharSet
Definition: wingdi.h:2379
BYTE tmFirstChar
Definition: wingdi.h:2371
#define FALSE
Definition: types.h:117
#define DT_LEFT
Definition: winuser.h:534
#define ID3DXRenderToEnvMap_BeginParabolic(p, a, b)
Definition: d3dx9core.h:335
#define DT_CALCRECT
Definition: winuser.h:526
static const CHAR testA[]
Definition: run.c:171
unsigned int BOOL
Definition: ntddk_ex.h:94
static void test_D3DXCreateRenderToEnvMap(IDirect3DDevice9 *device)
Definition: core.c:1144
Definition: devices.h:37
static void compare_device_state(struct device_state *state1, struct device_state *state2, BOOL equal)
Definition: core.c:930
D3DFORMAT Format
Definition: d3dx9core.h:294
static const WCHAR desc[]
Definition: protectdata.c:36
GLenum GLint ref
Definition: glext.h:6028
#define ID3DXFont_GetDC(p)
Definition: d3dx9core.h:173
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4290
#define ID3DXFont_GetTextMetricsA(p, a)
Definition: d3dx9core.h:171
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1508
smooth NULL
Definition: ftsmooth.c:416
#define check_ref(obj, exp)
Definition: core.c:32
static void test_ID3DXRenderToEnvMap(IDirect3DDevice9 *device)
Definition: core.c:1258
Definition: parser.c:48
struct ID3DXBuffer ID3DXBuffer
Definition: d3dx8core.h:51
HRESULT WINAPI D3DXCreateFontIndirectA(IDirect3DDevice9 *device, const D3DXFONT_DESCA *desc, ID3DXFont **font)
Definition: font.c:477
#define ID3DXSprite_SetWorldViewLH(p, a, b)
Definition: d3dx9core.h:448
enum _D3DFORMAT D3DFORMAT
BOOL WINAPI GetTextMetricsA(_In_ HDC, _Out_ LPTEXTMETRICA)
Definition: text.c:200
START_TEST(core)
Definition: core.c:1329
static void check_ID3DXRenderToSurface(IDirect3DDevice9 *device, UINT width, UINT height, D3DFORMAT format, BOOL depth_stencil, D3DFORMAT depth_stencil_format, BOOL render_target)
Definition: core.c:759
#define IDirect3DDevice9_GetRenderTarget(p, a, b)
Definition: d3d9.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define ID3DXRenderToEnvMap_BeginHemisphere(p, a, b)
Definition: d3dx9core.h:334
#define IDirect3DDevice9_GetDirect3D(p, a)
Definition: d3d9.h:1513
#define IDirect3DDevice9_EndScene(p)
Definition: d3d9.h:1549
#define IDirect3DDevice9_GetViewport(p, a)
Definition: d3d9.h:1555
GLfloat f
Definition: glext.h:7540
BYTE tmDefaultChar
Definition: wingdi.h:2373
#define ID3DXBuffer_GetBufferSize(p)
Definition: d3dx9core.h:86
GLsizeiptr size
Definition: glext.h:5919
#define ID3DXFont_PreloadGlyphs(p, a, b)
Definition: d3dx9core.h:176
#define DEFAULT_PITCH
Definition: wingdi.h:442
#define D3D_SDK_VERSION
Definition: d3d8.h:56
#define ID3DXSprite_Flush(p)
Definition: d3dx9core.h:451
LONG tmHeight
Definition: wingdi.h:2360
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLuint texture
Definition: glext.h:6295
LONG HRESULT
Definition: typedefs.h:79
#define ID3DXFont_PreloadCharacters(p, a, b)
Definition: d3dx9core.h:175
#define admitted_error
Definition: core.c:46
#define D3DUSAGE_RENDERTARGET
Definition: d3d8types.h:91
static HRESULT retrieve_device_state(IDirect3DDevice9 *device, struct device_state *state)
Definition: core.c:890
static void render(void)
Definition: ssstars.c:272
static void check_mat(D3DXMATRIX got, D3DXMATRIX exp)
Definition: core.c:47
static const struct d3drm_matrix identity
Definition: frame.c:26
LONG tmInternalLeading
Definition: wingdi.h:2363
const GLubyte * c
Definition: glext.h:8905
#define ID3DXSprite_End(p)
Definition: d3dx9core.h:452
unsigned short WORD
Definition: ntddk_ex.h:93
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:414
IDirect3DSurface9 * depth_stencil
Definition: render.c:31
unsigned long DWORD
Definition: ntddk_ex.h:95
WORD face[3]
Definition: mesh.c:4747
struct ID3DXFont ID3DXFont
Definition: d3dx8core.h:53
D3DXMATRIX *WINAPI D3DXMatrixOrthoOffCenterLH(D3DXMATRIX *pout, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf)
Definition: math.c:439
#define ID3DXRenderToSurface_BeginScene(p, a, b)
Definition: d3dx9core.h:394
LONG tmExternalLeading
Definition: wingdi.h:2364
#define D3DCOLOR_XRGB(r, g, b)
Definition: d3d8types.h:44
LONG tmDescent
Definition: wingdi.h:2362
int ret
static void _check_ref(unsigned int line, IUnknown *obj, int exp)
Definition: core.c:33
#define ID3DXSprite_Release(p)
Definition: d3dx9core.h:442
#define todo_wine
Definition: test.h:162
static void test_ID3DXRenderToSurface_device_state(IDirect3DDevice9 *device)
Definition: core.c:948
HDC hdc
Definition: main.c:9
IDirect3DSurface9 * render_target
Definition: core.c:878
#define ID3DXSprite_Begin(p, a)
Definition: d3dx9core.h:449
static int state
Definition: maze.c:121
static int font_height(HFONT hFont)
Definition: combo.c:612
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
static void test_ID3DXRenderToSurface(IDirect3DDevice9 *device)
Definition: core.c:1064
#define ID3DXFont_PreloadTextA(p, a, b)
Definition: d3dx9core.h:177
#define IDirect3DDevice9_GetTransform(p, a, b)
Definition: d3d9.h:1552
#define ID3DXFont_DrawTextW(p, a, b, c, d, e, f)
Definition: d3dx9core.h:180
HRESULT WINAPI D3DXCreateRenderToEnvMap(IDirect3DDevice9 *device, UINT size, UINT mip_levels, D3DFORMAT format, BOOL depth_stencil, D3DFORMAT depth_stencil_format, ID3DXRenderToEnvMap **out)
Definition: render.c:747
#define ID3DXFont_PreloadTextW(p, a, b)
Definition: d3dx9core.h:178
static HRESULT apply_device_state(IDirect3DDevice9 *device, struct device_state *state)
Definition: core.c:913
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define ID3DXRenderToSurface_GetDesc(p, a)
Definition: d3dx9core.h:393
_Check_return_ _CRT_JIT_INTRINSIC double __cdecl fabs(_In_ double x)
Definition: sprite.c:37
#define DT_NOCLIP
Definition: winuser.h:536
LONG tmAscent
Definition: wingdi.h:2361
LONG tmMaxCharWidth
Definition: wingdi.h:2366
#define FW_DONTCARE
Definition: wingdi.h:367
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
#define D3D_OK
Definition: d3d.h:106
#define FW_BOLD
Definition: wingdi.h:377
#define ID3DXRenderToEnvMap_GetDesc(p, a)
Definition: d3dx9core.h:331
#define ID3DXFont_Release(p)
Definition: d3dx9core.h:166
#define IDirect3DDevice9_CreateTexture(p, a, b, c, d, e, f, g, h)
Definition: d3d9.h:1530
BYTE tmStruckOut
Definition: wingdi.h:2377
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ID3DXBuffer_Release(p)
Definition: d3dx9core.h:83
#define ok(value,...)
Definition: atltest.h:57
BYTE tmItalic
Definition: wingdi.h:2375
D3DFORMAT DepthStencilFormat
Definition: d3dx9core.h:296
LONG tmOverhang
Definition: wingdi.h:2368
#define DT_TOP
Definition: winuser.h:542
#define D3DTS_WORLD
Definition: d3d8types.h:85
unsigned int UINT
Definition: ndis.h:50
DWORD exp
Definition: msg.c:16033
#define ID3DXRenderToEnvMap_Face(p, a, b)
Definition: d3dx9core.h:336
#define ID3DXSprite_SetTransform(p, a)
Definition: d3dx9core.h:446
#define skip(...)
Definition: atltest.h:64
LONG tmDigitizedAspectX
Definition: wingdi.h:2369
const char * expected_result
Definition: mimeole.c:1468
#define ID3DXSprite_OnLostDevice(p)
Definition: d3dx9core.h:453
HRESULT WINAPI D3DXCreateSprite(struct IDirect3DDevice9 *device, struct ID3DXSprite **sprite)
Definition: sprite.c:557
static void test_ID3DXRenderToEnvMap_cube_map(IDirect3DDevice9 *device)
Definition: core.c:1195
#define OUT_RASTER_PRECIS
Definition: wingdi.h:420
#define ID3DXRenderToEnvMap_BeginCube(p, a)
Definition: d3dx9core.h:332
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define c
Definition: ke_i.h:80
static void test_ID3DXFont(IDirect3DDevice9 *device)
Definition: core.c:306
unsigned int ULONG
Definition: retypes.h:1
#define D3DX_FILTER_POINT
Definition: d3dx9tex.h:28
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
BYTE tmBreakChar
Definition: wingdi.h:2374
char * cleanup(char *str)
Definition: wpickclick.c:99
#define ID3DXFont_DrawTextA(p, a, b, c, d, e, f)
Definition: d3dx9core.h:179
HRESULT WINAPI D3DXCreateFontA(struct IDirect3DDevice9 *device, INT height, UINT width, UINT weight, UINT miplevels, BOOL italic, DWORD charset, DWORD precision, DWORD quality, DWORD pitchandfamily, const char *facename, struct ID3DXFont **font)
Definition: font.c:429
#define ANSI_CHARSET
Definition: wingdi.h:382
#define ID3DXSprite_SetWorldViewRH(p, a, b)
Definition: d3dx9core.h:447
#define GDI_ERROR
Definition: wingdi.h:1308
#define check_release(obj, exp)
Definition: core.c:39
#define ID3DXFont_GetGlyphData(p, a, b, c, d)
Definition: d3dx9core.h:174
#define memset(x, y, z)
Definition: compat.h:39
#define MAKEFOURCC(ch0, ch1, ch2, ch3)
Definition: dmdls.h:24
static SERVICE_STATUS status
Definition: service.c:31
#define ID3DXSprite_OnResetDevice(p)
Definition: d3dx9core.h:454
#define IDirect3DDevice9_CreateCubeTexture(p, a, b, c, d, e, f, g)
Definition: d3d9.h:1532
static void _check_release(unsigned int line, IUnknown *obj, int exp)
Definition: core.c:40
Definition: dsound.c:943
#define IDirect3DDevice9_BeginScene(p)
Definition: d3d9.h:1548
#define ID3DXFont_GetDevice(p, a)
Definition: d3dx9core.h:168
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
static const WCHAR testW[]
Definition: jsregexp.c:44
static void test_ID3DXSprite(IDirect3DDevice9 *device)
Definition: core.c:96
BOOL expected
Definition: store.c:2063
#define D3DXSPRITE_ALPHABLEND
Definition: d3dx9core.h:37
#define SUCCEEDED(hr)
Definition: intsafe.h:49
#define ok_(x1, x2)
Definition: atltest.h:61
D3DSWAPEFFECT SwapEffect
Definition: d3d8types.h:1128
#define D3DCLEAR_TARGET
Definition: d3d8types.h:30
Definition: ps.c:97