2 * Tests for the D3DX9 core interfaces
4 * Copyright 2009 Tony Wasserka
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.
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.
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
22 #include "wine/test.h"
24 #include "d3dx9core.h"
26 static inline int get_ref(IUnknown
*obj
)
29 return IUnknown_Release(obj
);
32 static inline void check_ref(IUnknown
*obj
, int exp
)
34 int ref
= get_ref(obj
);
35 ok (exp
== ref
, "Invalid refcount. Expected %d, got %d\n", exp
, ref
);
38 static inline void check_release(IUnknown
*obj
, int exp
)
40 int ref
= IUnknown_Release(obj
);
41 ok (ref
== exp
, "Invalid refcount. Expected %d, got %d\n", exp
, ref
);
44 #define admitted_error 0.0001f
45 static inline void check_mat(D3DXMATRIX got
, D3DXMATRIX exp
)
50 if (fabs(U(exp
).m
[i
][j
]-U(got
).m
[i
][j
]) > admitted_error
)
53 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"
54 "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",
55 U(got
).m
[0][0],U(got
).m
[0][1],U(got
).m
[0][2],U(got
).m
[0][3],
56 U(got
).m
[1][0],U(got
).m
[1][1],U(got
).m
[1][2],U(got
).m
[1][3],
57 U(got
).m
[2][0],U(got
).m
[2][1],U(got
).m
[2][2],U(got
).m
[2][3],
58 U(got
).m
[3][0],U(got
).m
[3][1],U(got
).m
[3][2],U(got
).m
[3][3],
59 U(exp
).m
[0][0],U(exp
).m
[0][1],U(exp
).m
[0][2],U(exp
).m
[0][3],
60 U(exp
).m
[1][0],U(exp
).m
[1][1],U(exp
).m
[1][2],U(exp
).m
[1][3],
61 U(exp
).m
[2][0],U(exp
).m
[2][1],U(exp
).m
[2][2],U(exp
).m
[2][3],
62 U(exp
).m
[3][0],U(exp
).m
[3][1],U(exp
).m
[3][2],U(exp
).m
[3][3]);
65 static void test_ID3DXSprite(IDirect3DDevice9
*device
)
69 IDirect3DDevice9
*cmpdev
;
70 IDirect3DTexture9
*tex1
, *tex2
;
71 D3DXMATRIX mat
, cmpmat
;
74 D3DXVECTOR3 pos
, center
;
77 IDirect3DDevice9_GetDirect3D(device
, &d3d
);
78 hr
= IDirect3D9_CheckDeviceFormat(d3d
, D3DADAPTER_DEFAULT
, D3DDEVTYPE_HAL
, D3DFMT_X8R8G8B8
, D3DUSAGE_DYNAMIC
, D3DRTYPE_TEXTURE
, D3DFMT_A8R8G8B8
);
79 IDirect3D9_Release(d3d
);
80 ok (hr
== D3D_OK
, "D3DFMT_A8R8G8B8 not supported\n");
81 if (FAILED(hr
)) return;
83 hr
= IDirect3DDevice9_CreateTexture(device
, 64, 64, 1, 0, D3DFMT_A8R8G8B8
, D3DPOOL_DEFAULT
, &tex1
, NULL
);
84 ok (hr
== D3D_OK
, "Failed to create first texture (error code: %#x)\n", hr
);
85 if (FAILED(hr
)) return;
87 hr
= IDirect3DDevice9_CreateTexture(device
, 32, 32, 1, 0, D3DFMT_A8R8G8B8
, D3DPOOL_DEFAULT
, &tex2
, NULL
);
88 ok (hr
== D3D_OK
, "Failed to create second texture (error code: %#x)\n", hr
);
90 IDirect3DTexture9_Release(tex1
);
94 /* Test D3DXCreateSprite */
95 hr
= D3DXCreateSprite(device
, NULL
);
96 ok (hr
== D3DERR_INVALIDCALL
, "D3DXCreateSprite returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
98 hr
= D3DXCreateSprite(NULL
, &sprite
);
99 ok (hr
== D3DERR_INVALIDCALL
, "D3DXCreateSprite returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
101 hr
= D3DXCreateSprite(device
, &sprite
);
102 ok (hr
== D3D_OK
, "D3DXCreateSprite returned %#x, expected %#x\n", hr
, D3D_OK
);
105 /* Test ID3DXSprite_GetDevice */
106 hr
= ID3DXSprite_GetDevice(sprite
, NULL
);
107 ok (hr
== D3DERR_INVALIDCALL
, "GetDevice returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
109 hr
= ID3DXSprite_GetDevice(sprite
, &cmpdev
); /* cmpdev == NULL */
110 ok (hr
== D3D_OK
, "GetDevice returned %#x, expected %#x\n", hr
, D3D_OK
);
112 hr
= ID3DXSprite_GetDevice(sprite
, &cmpdev
); /* cmpdev != NULL */
113 ok (hr
== D3D_OK
, "GetDevice returned %#x, expected %#x\n", hr
, D3D_OK
);
115 IDirect3DDevice9_Release(device
);
116 IDirect3DDevice9_Release(device
);
119 /* Test ID3DXSprite_GetTransform */
120 hr
= ID3DXSprite_GetTransform(sprite
, NULL
);
121 ok (hr
== D3DERR_INVALIDCALL
, "GetTransform returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
122 hr
= ID3DXSprite_GetTransform(sprite
, &mat
);
123 ok (hr
== D3D_OK
, "GetTransform returned %#x, expected %#x\n", hr
, D3D_OK
);
126 D3DXMatrixIdentity(&identity
);
127 check_mat(mat
, identity
);
130 /* Test ID3DXSprite_SetTransform */
131 /* Set a transform and test if it gets returned correctly */
132 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
;
133 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
;
134 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
;
135 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
;
137 hr
= ID3DXSprite_SetTransform(sprite
, NULL
);
138 ok (hr
== D3DERR_INVALIDCALL
, "SetTransform returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
140 hr
= ID3DXSprite_SetTransform(sprite
, &mat
);
141 ok (hr
== D3D_OK
, "SetTransform returned %#x, expected %#x\n", hr
, D3D_OK
);
143 hr
=ID3DXSprite_GetTransform(sprite
, &cmpmat
);
144 if(SUCCEEDED(hr
)) check_mat(cmpmat
, mat
);
145 else skip("GetTransform returned %#x\n", hr
);
148 /* Test ID3DXSprite_SetWorldViewLH/RH */
150 hr
= ID3DXSprite_SetWorldViewLH(sprite
, &mat
, &mat
);
151 ok (hr
== D3D_OK
, "SetWorldViewLH returned %#x, expected %#x\n", hr
, D3D_OK
);
152 hr
= ID3DXSprite_SetWorldViewLH(sprite
, NULL
, &mat
);
153 ok (hr
== D3D_OK
, "SetWorldViewLH returned %#x, expected %#x\n", hr
, D3D_OK
);
154 hr
= ID3DXSprite_SetWorldViewLH(sprite
, &mat
, NULL
);
155 ok (hr
== D3D_OK
, "SetWorldViewLH returned %#x, expected %#x\n", hr
, D3D_OK
);
156 hr
= ID3DXSprite_SetWorldViewLH(sprite
, NULL
, NULL
);
157 ok (hr
== D3D_OK
, "SetWorldViewLH returned %#x, expected %#x\n", hr
, D3D_OK
);
159 hr
= ID3DXSprite_SetWorldViewRH(sprite
, &mat
, &mat
);
160 ok (hr
== D3D_OK
, "SetWorldViewRH returned %#x, expected %#x\n", hr
, D3D_OK
);
161 hr
= ID3DXSprite_SetWorldViewRH(sprite
, NULL
, &mat
);
162 ok (hr
== D3D_OK
, "SetWorldViewRH returned %#x, expected %#x\n", hr
, D3D_OK
);
163 hr
= ID3DXSprite_SetWorldViewRH(sprite
, &mat
, NULL
);
164 ok (hr
== D3D_OK
, "SetWorldViewRH returned %#x, expected %#x\n", hr
, D3D_OK
);
165 hr
= ID3DXSprite_SetWorldViewRH(sprite
, NULL
, NULL
);
166 ok (hr
== D3D_OK
, "SetWorldViewRH returned %#x, expected %#x\n", hr
, D3D_OK
);
168 IDirect3DDevice9_BeginScene(device
);
170 /* Test ID3DXSprite_Begin*/
171 hr
= ID3DXSprite_Begin(sprite
, 0);
172 ok (hr
== D3D_OK
, "Begin returned %#x, expected %#x\n", hr
, D3D_OK
);
174 IDirect3DDevice9_GetTransform(device
, D3DTS_WORLD
, &mat
);
175 D3DXMatrixIdentity(&cmpmat
);
176 check_mat(mat
, cmpmat
);
178 IDirect3DDevice9_GetTransform(device
, D3DTS_VIEW
, &mat
);
179 check_mat(mat
, cmpmat
);
181 IDirect3DDevice9_GetTransform(device
, D3DTS_PROJECTION
, &mat
);
182 IDirect3DDevice9_GetViewport(device
, &vp
);
183 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
);
184 check_mat(mat
, cmpmat
);
186 /* Test ID3DXSprite_Flush and ID3DXSprite_End */
187 hr
= ID3DXSprite_Flush(sprite
);
188 ok (hr
== D3D_OK
, "Flush returned %#x, expected %#x\n", hr
, D3D_OK
);
190 hr
= ID3DXSprite_End(sprite
);
191 ok (hr
== D3D_OK
, "End returned %#x, expected %#x\n", hr
, D3D_OK
);
193 hr
= ID3DXSprite_Flush(sprite
); /* May not be called before next Begin */
194 ok (hr
== D3DERR_INVALIDCALL
, "Flush returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
195 hr
= ID3DXSprite_End(sprite
);
196 ok (hr
== D3DERR_INVALIDCALL
, "End returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
198 /* Test ID3DXSprite_Draw */
199 hr
= ID3DXSprite_Begin(sprite
, 0);
200 ok (hr
== D3D_OK
, "Begin returned %#x, expected %#x\n", hr
, D3D_OK
);
202 if(FAILED(hr
)) skip("Couldn't ID3DXSprite_Begin, can't test ID3DXSprite_Draw\n");
203 else { /* Feed the sprite batch */
204 int texref1
, texref2
;
206 SetRect(&rect
, 53, 12, 142, 165);
207 pos
.x
= 2.2f
; pos
.y
= 4.5f
; pos
.z
= 5.1f
;
208 center
.x
= 11.3f
; center
.y
= 3.4f
; center
.z
= 1.2f
;
210 texref1
= get_ref((IUnknown
*)tex1
);
211 texref2
= get_ref((IUnknown
*)tex2
);
213 hr
= ID3DXSprite_Draw(sprite
, NULL
, &rect
, ¢er
, &pos
, D3DCOLOR_XRGB(255, 255, 255));
214 ok (hr
== D3DERR_INVALIDCALL
, "Draw returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
216 hr
= ID3DXSprite_Draw(sprite
, tex1
, &rect
, ¢er
, &pos
, D3DCOLOR_XRGB(255, 255, 255));
217 ok (hr
== D3D_OK
, "Draw returned %#x, expected %#x\n", hr
, D3D_OK
);
218 hr
= ID3DXSprite_Draw(sprite
, tex2
, &rect
, ¢er
, &pos
, D3DCOLOR_XRGB( 3, 45, 66));
219 ok (hr
== D3D_OK
, "Draw returned %#x, expected %#x\n", hr
, D3D_OK
);
220 hr
= ID3DXSprite_Draw(sprite
, tex1
, NULL
, ¢er
, &pos
, D3DCOLOR_XRGB(255, 255, 255));
221 ok (hr
== D3D_OK
, "Draw returned %#x, expected %#x\n", hr
, D3D_OK
);
222 hr
= ID3DXSprite_Draw(sprite
, tex1
, &rect
, NULL
, &pos
, D3DCOLOR_XRGB(255, 255, 255));
223 ok (hr
== D3D_OK
, "Draw returned %#x, expected %#x\n", hr
, D3D_OK
);
224 hr
= ID3DXSprite_Draw(sprite
, tex1
, &rect
, ¢er
, NULL
, D3DCOLOR_XRGB(255, 255, 255));
225 ok (hr
== D3D_OK
, "Draw returned %#x, expected %#x\n", hr
, D3D_OK
);
226 hr
= ID3DXSprite_Draw(sprite
, tex1
, NULL
, NULL
, NULL
, 0);
227 ok (hr
== D3D_OK
, "Draw returned %#x, expected %#x\n", hr
, D3D_OK
);
229 check_ref((IUnknown
*)tex1
, texref1
+5); check_ref((IUnknown
*)tex2
, texref2
+1);
230 hr
= ID3DXSprite_Flush(sprite
);
231 ok (hr
== D3D_OK
, "Flush returned %#x, expected %#x\n", hr
, D3D_OK
);
232 hr
= ID3DXSprite_Flush(sprite
); /* Flushing twice should work */
233 ok (hr
== D3D_OK
, "Flush returned %#x, expected %#x\n", hr
, D3D_OK
);
234 check_ref((IUnknown
*)tex1
, texref1
); check_ref((IUnknown
*)tex2
, texref2
);
236 hr
= ID3DXSprite_End(sprite
);
237 ok (hr
== D3D_OK
, "End returned %#x, expected %#x\n", hr
, D3D_OK
);
240 /* Test ID3DXSprite_OnLostDevice and ID3DXSprite_OnResetDevice */
241 /* Both can be called twice */
242 hr
= ID3DXSprite_OnLostDevice(sprite
);
243 ok (hr
== D3D_OK
, "OnLostDevice returned %#x, expected %#x\n", hr
, D3D_OK
);
244 hr
= ID3DXSprite_OnLostDevice(sprite
);
245 ok (hr
== D3D_OK
, "OnLostDevice returned %#x, expected %#x\n", hr
, D3D_OK
);
246 hr
= ID3DXSprite_OnResetDevice(sprite
);
247 ok (hr
== D3D_OK
, "OnResetDevice returned %#x, expected %#x\n", hr
, D3D_OK
);
248 hr
= ID3DXSprite_OnResetDevice(sprite
);
249 ok (hr
== D3D_OK
, "OnResetDevice returned %#x, expected %#x\n", hr
, D3D_OK
);
251 /* Make sure everything works like before */
252 hr
= ID3DXSprite_Begin(sprite
, 0);
253 ok (hr
== D3D_OK
, "Begin returned %#x, expected %#x\n", hr
, D3D_OK
);
254 hr
= ID3DXSprite_Draw(sprite
, tex2
, &rect
, ¢er
, &pos
, D3DCOLOR_XRGB(255, 255, 255));
255 ok (hr
== D3D_OK
, "Draw returned %#x, expected %#x\n", hr
, D3D_OK
);
256 hr
= ID3DXSprite_Flush(sprite
);
257 ok (hr
== D3D_OK
, "Flush returned %#x, expected %#x\n", hr
, D3D_OK
);
258 hr
= ID3DXSprite_End(sprite
);
259 ok (hr
== D3D_OK
, "End returned %#x, expected %#x\n", hr
, D3D_OK
);
261 /* OnResetDevice makes the interface "forget" the Begin call */
262 hr
= ID3DXSprite_Begin(sprite
, 0);
263 ok (hr
== D3D_OK
, "Begin returned %#x, expected %#x\n", hr
, D3D_OK
);
264 hr
= ID3DXSprite_OnResetDevice(sprite
);
265 ok (hr
== D3D_OK
, "OnResetDevice returned %#x, expected %#x\n", hr
, D3D_OK
);
266 hr
= ID3DXSprite_End(sprite
);
267 ok (hr
== D3DERR_INVALIDCALL
, "End returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
269 IDirect3DDevice9_EndScene(device
);
270 check_release((IUnknown
*)sprite
, 0);
271 check_release((IUnknown
*)tex2
, 0);
272 check_release((IUnknown
*)tex1
, 0);
275 static void test_ID3DXFont(IDirect3DDevice9
*device
)
284 ref
= get_ref((IUnknown
*)device
);
285 hr
= D3DXCreateFontA(device
, 12, 0, FW_DONTCARE
, 0, FALSE
, DEFAULT_CHARSET
, OUT_DEFAULT_PRECIS
, DEFAULT_QUALITY
, DEFAULT_PITCH
, "Arial", &font
);
286 ok(hr
== D3D_OK
, "D3DXCreateFont returned %#x, expected %#x\n", hr
, D3D_OK
);
287 check_ref((IUnknown
*)device
, ref
+ 1);
288 check_release((IUnknown
*)font
, 0);
289 check_ref((IUnknown
*)device
, ref
);
291 hr
= D3DXCreateFontA(device
, 0, 0, FW_DONTCARE
, 0, FALSE
, DEFAULT_CHARSET
, OUT_DEFAULT_PRECIS
, DEFAULT_QUALITY
, DEFAULT_PITCH
, "Arial", &font
);
292 ok(hr
== D3D_OK
, "D3DXCreateFont returned %#x, expected %#x\n", hr
, D3D_OK
);
293 ID3DXFont_Release(font
);
295 hr
= D3DXCreateFontA(device
, 12, 0, FW_DONTCARE
, 0, FALSE
, DEFAULT_CHARSET
, OUT_DEFAULT_PRECIS
, DEFAULT_QUALITY
, DEFAULT_PITCH
, NULL
, &font
);
296 ok(hr
== D3D_OK
, "D3DXCreateFont returned %#x, expected %#x\n", hr
, D3D_OK
);
297 ID3DXFont_Release(font
);
299 hr
= D3DXCreateFontA(device
, 12, 0, FW_DONTCARE
, 0, FALSE
, DEFAULT_CHARSET
, OUT_DEFAULT_PRECIS
, DEFAULT_QUALITY
, DEFAULT_PITCH
, "", &font
);
300 ok(hr
== D3D_OK
, "D3DXCreateFont returned %#x, expected %#x\n", hr
, D3D_OK
);
301 ID3DXFont_Release(font
);
303 hr
= D3DXCreateFontA(NULL
, 12, 0, FW_DONTCARE
, 0, FALSE
, DEFAULT_CHARSET
, OUT_DEFAULT_PRECIS
, DEFAULT_QUALITY
, DEFAULT_PITCH
, "Arial", &font
);
304 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateFont returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
306 hr
= D3DXCreateFontA(device
, 12, 0, FW_DONTCARE
, 0, FALSE
, DEFAULT_CHARSET
, OUT_DEFAULT_PRECIS
, DEFAULT_QUALITY
, DEFAULT_PITCH
, "Arial", NULL
);
307 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateFont returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
309 hr
= D3DXCreateFontA(NULL
, 12, 0, FW_DONTCARE
, 0, FALSE
, DEFAULT_CHARSET
, OUT_DEFAULT_PRECIS
, DEFAULT_QUALITY
, DEFAULT_PITCH
, "Arial", NULL
);
310 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateFont returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
313 /* D3DXCreateFontIndirect */
316 desc
.Weight
= FW_DONTCARE
;
319 desc
.CharSet
= DEFAULT_CHARSET
;
320 desc
.OutputPrecision
= OUT_DEFAULT_PRECIS
;
321 desc
.Quality
= DEFAULT_QUALITY
;
322 desc
.PitchAndFamily
= DEFAULT_PITCH
;
323 strcpy(desc
.FaceName
, "Arial");
324 hr
= D3DXCreateFontIndirectA(device
, &desc
, &font
);
325 ok(hr
== D3D_OK
, "D3DXCreateFontIndirect returned %#x, expected %#x\n", hr
, D3D_OK
);
326 ID3DXFont_Release(font
);
328 hr
= D3DXCreateFontIndirectA(NULL
, &desc
, &font
);
329 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateFontIndirect returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
331 hr
= D3DXCreateFontIndirectA(device
, NULL
, &font
);
332 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateFontIndirect returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
334 hr
= D3DXCreateFontIndirectA(device
, &desc
, NULL
);
335 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateFontIndirect returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
338 /* ID3DXFont_GetDevice */
339 hr
= D3DXCreateFontA(device
, 12, 0, FW_DONTCARE
, 0, FALSE
, DEFAULT_CHARSET
, OUT_DEFAULT_PRECIS
, DEFAULT_QUALITY
, DEFAULT_PITCH
, "Arial", &font
);
341 IDirect3DDevice9
*bufdev
;
343 hr
= ID3DXFont_GetDevice(font
, NULL
);
344 ok(hr
== D3DERR_INVALIDCALL
, "ID3DXFont_GetDevice returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
346 ref
= get_ref((IUnknown
*)device
);
347 hr
= ID3DXFont_GetDevice(font
, &bufdev
);
348 ok(hr
== D3D_OK
, "ID3DXFont_GetDevice returned %#x, expected %#x\n", hr
, D3D_OK
);
349 check_release((IUnknown
*)bufdev
, ref
);
351 ID3DXFont_Release(font
);
352 } else skip("Failed to create a ID3DXFont object\n");
355 /* ID3DXFont_GetDesc */
356 hr
= D3DXCreateFontA(device
, 12, 8, FW_BOLD
, 2, TRUE
, ANSI_CHARSET
, OUT_RASTER_PRECIS
, ANTIALIASED_QUALITY
, VARIABLE_PITCH
, "Arial", &font
);
358 hr
= ID3DXFont_GetDescA(font
, NULL
);
359 ok(hr
== D3DERR_INVALIDCALL
, "ID3DXFont_GetDevice returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
361 hr
= ID3DXFont_GetDescA(font
, &desc
);
362 ok(hr
== D3D_OK
, "ID3DXFont_GetDevice returned %#x, expected %#x\n", hr
, D3D_OK
);
364 ok(desc
.Height
== 12, "ID3DXFont_GetDesc returned font height %d, expected %d\n", desc
.Height
, 12);
365 ok(desc
.Width
== 8, "ID3DXFont_GetDesc returned font width %d, expected %d\n", desc
.Width
, 8);
366 ok(desc
.Weight
== FW_BOLD
, "ID3DXFont_GetDesc returned font weight %d, expected %d\n", desc
.Weight
, FW_BOLD
);
367 ok(desc
.MipLevels
== 2, "ID3DXFont_GetDesc returned font miplevels %d, expected %d\n", desc
.MipLevels
, 2);
368 ok(desc
.Italic
== TRUE
, "ID3DXFont_GetDesc says Italic was %d, but Italic should be %d\n", desc
.Italic
, TRUE
);
369 ok(desc
.CharSet
== ANSI_CHARSET
, "ID3DXFont_GetDesc returned font charset %d, expected %d\n", desc
.CharSet
, ANSI_CHARSET
);
370 ok(desc
.OutputPrecision
== OUT_RASTER_PRECIS
, "ID3DXFont_GetDesc returned an output precision of %d, expected %d\n", desc
.OutputPrecision
, OUT_RASTER_PRECIS
);
371 ok(desc
.Quality
== ANTIALIASED_QUALITY
, "ID3DXFont_GetDesc returned font quality %d, expected %d\n", desc
.Quality
, ANTIALIASED_QUALITY
);
372 ok(desc
.PitchAndFamily
== VARIABLE_PITCH
, "ID3DXFont_GetDesc returned pitch and family %d, expected %d\n", desc
.PitchAndFamily
, VARIABLE_PITCH
);
373 ok(strcmp(desc
.FaceName
, "Arial") == 0, "ID3DXFont_GetDesc returned facename \"%s\", expected \"%s\"\n", desc
.FaceName
, "Arial");
375 ID3DXFont_Release(font
);
376 } else skip("Failed to create a ID3DXFont object\n");
379 /* ID3DXFont_GetDC + ID3DXFont_GetTextMetrics */
380 hr
= D3DXCreateFontA(device
, 12, 0, FW_DONTCARE
, 0, FALSE
, DEFAULT_CHARSET
, OUT_DEFAULT_PRECIS
, DEFAULT_QUALITY
, DEFAULT_PITCH
, "Arial", &font
);
384 hdc
= ID3DXFont_GetDC(font
);
385 ok(hdc
!= NULL
, "ID3DXFont_GetDC returned an invalid handle\n");
387 TEXTMETRICA metrics
, expmetrics
;
390 ret
= ID3DXFont_GetTextMetricsA(font
, &metrics
);
391 ok(ret
, "ID3DXFont_GetTextMetricsA failed\n");
392 ret
= GetTextMetricsA(hdc
, &expmetrics
);
393 ok(ret
, "GetTextMetricsA failed\n");
395 ok(metrics
.tmHeight
== expmetrics
.tmHeight
, "Returned height %d, expected %d\n", metrics
.tmHeight
, expmetrics
.tmHeight
);
396 ok(metrics
.tmAscent
== expmetrics
.tmAscent
, "Returned ascent %d, expected %d\n", metrics
.tmAscent
, expmetrics
.tmAscent
);
397 ok(metrics
.tmDescent
== expmetrics
.tmDescent
, "Returned descent %d, expected %d\n", metrics
.tmDescent
, expmetrics
.tmDescent
);
398 ok(metrics
.tmInternalLeading
== expmetrics
.tmInternalLeading
, "Returned internal leading %d, expected %d\n", metrics
.tmInternalLeading
, expmetrics
.tmInternalLeading
);
399 ok(metrics
.tmExternalLeading
== expmetrics
.tmExternalLeading
, "Returned external leading %d, expected %d\n", metrics
.tmExternalLeading
, expmetrics
.tmExternalLeading
);
400 ok(metrics
.tmAveCharWidth
== expmetrics
.tmAveCharWidth
, "Returned average char width %d, expected %d\n", metrics
.tmAveCharWidth
, expmetrics
.tmAveCharWidth
);
401 ok(metrics
.tmMaxCharWidth
== expmetrics
.tmMaxCharWidth
, "Returned maximum char width %d, expected %d\n", metrics
.tmMaxCharWidth
, expmetrics
.tmMaxCharWidth
);
402 ok(metrics
.tmWeight
== expmetrics
.tmWeight
, "Returned weight %d, expected %d\n", metrics
.tmWeight
, expmetrics
.tmWeight
);
403 ok(metrics
.tmOverhang
== expmetrics
.tmOverhang
, "Returned overhang %d, expected %d\n", metrics
.tmOverhang
, expmetrics
.tmOverhang
);
404 ok(metrics
.tmDigitizedAspectX
== expmetrics
.tmDigitizedAspectX
, "Returned digitized x aspect %d, expected %d\n", metrics
.tmDigitizedAspectX
, expmetrics
.tmDigitizedAspectX
);
405 ok(metrics
.tmDigitizedAspectY
== expmetrics
.tmDigitizedAspectY
, "Returned digitized y aspect %d, expected %d\n", metrics
.tmDigitizedAspectY
, expmetrics
.tmDigitizedAspectY
);
406 ok(metrics
.tmFirstChar
== expmetrics
.tmFirstChar
, "Returned first char %d, expected %d\n", metrics
.tmFirstChar
, expmetrics
.tmFirstChar
);
407 ok(metrics
.tmLastChar
== expmetrics
.tmLastChar
, "Returned last char %d, expected %d\n", metrics
.tmLastChar
, expmetrics
.tmLastChar
);
408 ok(metrics
.tmDefaultChar
== expmetrics
.tmDefaultChar
, "Returned default char %d, expected %d\n", metrics
.tmDefaultChar
, expmetrics
.tmDefaultChar
);
409 ok(metrics
.tmBreakChar
== expmetrics
.tmBreakChar
, "Returned break char %d, expected %d\n", metrics
.tmBreakChar
, expmetrics
.tmBreakChar
);
410 ok(metrics
.tmItalic
== expmetrics
.tmItalic
, "Returned italic %d, expected %d\n", metrics
.tmItalic
, expmetrics
.tmItalic
);
411 ok(metrics
.tmUnderlined
== expmetrics
.tmUnderlined
, "Returned underlined %d, expected %d\n", metrics
.tmUnderlined
, expmetrics
.tmUnderlined
);
412 ok(metrics
.tmStruckOut
== expmetrics
.tmStruckOut
, "Returned struck out %d, expected %d\n", metrics
.tmStruckOut
, expmetrics
.tmStruckOut
);
413 ok(metrics
.tmPitchAndFamily
== expmetrics
.tmPitchAndFamily
, "Returned pitch and family %d, expected %d\n", metrics
.tmPitchAndFamily
, expmetrics
.tmPitchAndFamily
);
414 ok(metrics
.tmCharSet
== expmetrics
.tmCharSet
, "Returned charset %d, expected %d\n", metrics
.tmCharSet
, expmetrics
.tmCharSet
);
416 ID3DXFont_Release(font
);
417 } else skip("Failed to create a ID3DXFont object\n");
424 IDirect3DDevice9
*device
;
425 D3DPRESENT_PARAMETERS d3dpp
;
428 wnd
= CreateWindow("static", "d3dx9_test", 0, 0, 0, 0, 0, NULL
, NULL
, NULL
, NULL
);
429 d3d
= Direct3DCreate9(D3D_SDK_VERSION
);
431 skip("Couldn't create application window\n");
435 skip("Couldn't create IDirect3D9 object\n");
440 ZeroMemory(&d3dpp
, sizeof(d3dpp
));
441 d3dpp
.Windowed
= TRUE
;
442 d3dpp
.SwapEffect
= D3DSWAPEFFECT_DISCARD
;
443 hr
= IDirect3D9_CreateDevice(d3d
, D3DADAPTER_DEFAULT
, D3DDEVTYPE_HAL
, wnd
, D3DCREATE_MIXED_VERTEXPROCESSING
, &d3dpp
, &device
);
445 skip("Failed to create IDirect3DDevice9 object %#x\n", hr
);
446 IDirect3D9_Release(d3d
);
451 test_ID3DXSprite(device
);
452 test_ID3DXFont(device
);
454 check_release((IUnknown
*)device
, 0);
455 check_release((IUnknown
*)d3d
, 0);
456 if (wnd
) DestroyWindow(wnd
);