2 * Copyright 2008 David Adam
3 * Copyright 2008 Luis Busquets
4 * Copyright 2008 Philip Nilsson
5 * Copyright 2008 Henri Verbeet
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/test.h"
28 #define admitted_error 0.0001f
30 #define relative_error(exp, out) (fabsf(exp) < 1e-38f ? fabsf(exp - out) : fabsf(1.0f - (out) / (exp)))
32 static BOOL
compare_float(float f
, float g
, unsigned int ulps
)
42 if (abs(x
- y
) > ulps
)
48 static BOOL
compare_vec2(const D3DXVECTOR2
*v1
, const D3DXVECTOR2
*v2
, unsigned int ulps
)
50 return compare_float(v1
->x
, v2
->x
, ulps
) && compare_float(v1
->y
, v2
->y
, ulps
);
53 static BOOL
compare_vec3(const D3DXVECTOR3
*v1
, const D3DXVECTOR3
*v2
, unsigned int ulps
)
55 return compare_float(v1
->x
, v2
->x
, ulps
)
56 && compare_float(v1
->y
, v2
->y
, ulps
)
57 && compare_float(v1
->z
, v2
->z
, ulps
);
60 static BOOL
compare_vec4(const D3DXVECTOR4
*v1
, const D3DXVECTOR4
*v2
, unsigned int ulps
)
62 return compare_float(v1
->x
, v2
->x
, ulps
)
63 && compare_float(v1
->y
, v2
->y
, ulps
)
64 && compare_float(v1
->z
, v2
->z
, ulps
)
65 && compare_float(v1
->w
, v2
->w
, ulps
);
68 static BOOL
compare_color(const D3DXCOLOR
*c1
, const D3DXCOLOR
*c2
, unsigned int ulps
)
70 return compare_float(c1
->r
, c2
->r
, ulps
)
71 && compare_float(c1
->g
, c2
->g
, ulps
)
72 && compare_float(c1
->b
, c2
->b
, ulps
)
73 && compare_float(c1
->a
, c2
->a
, ulps
);
76 static BOOL
compare_plane(const D3DXPLANE
*p1
, const D3DXPLANE
*p2
, unsigned int ulps
)
78 return compare_float(p1
->a
, p2
->a
, ulps
)
79 && compare_float(p1
->b
, p2
->b
, ulps
)
80 && compare_float(p1
->c
, p2
->c
, ulps
)
81 && compare_float(p1
->d
, p2
->d
, ulps
);
84 static BOOL
compare_quaternion(const D3DXQUATERNION
*q1
, const D3DXQUATERNION
*q2
, unsigned int ulps
)
86 return compare_float(q1
->x
, q2
->x
, ulps
)
87 && compare_float(q1
->y
, q2
->y
, ulps
)
88 && compare_float(q1
->z
, q2
->z
, ulps
)
89 && compare_float(q1
->w
, q2
->w
, ulps
);
92 static BOOL
compare_matrix(const D3DXMATRIX
*m1
, const D3DXMATRIX
*m2
, unsigned int ulps
)
96 for (i
= 0; i
< 4; ++i
)
98 for (j
= 0; j
< 4; ++j
)
100 if (!compare_float(U(*m1
).m
[i
][j
], U(*m2
).m
[i
][j
], ulps
))
108 #define expect_vec2(expected, vector, ulps) expect_vec2_(__LINE__, expected, vector, ulps)
109 static void expect_vec2_(unsigned int line
, const D3DXVECTOR2
*expected
, const D3DXVECTOR2
*vector
, unsigned int ulps
)
111 BOOL equal
= compare_vec2(expected
, vector
, ulps
);
112 ok_(__FILE__
, line
)(equal
,
113 "Got unexpected vector {%.8e, %.8e}, expected {%.8e, %.8e}.\n",
114 vector
->x
, vector
->y
, expected
->x
, expected
->y
);
117 #define expect_vec3(expected, vector, ulps) expect_vec3_(__LINE__, expected, vector, ulps)
118 static void expect_vec3_(unsigned int line
, const D3DXVECTOR3
*expected
, const D3DXVECTOR3
*vector
, unsigned int ulps
)
120 BOOL equal
= compare_vec3(expected
, vector
, ulps
);
121 ok_(__FILE__
, line
)(equal
,
122 "Got unexpected vector {%.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e}.\n",
123 vector
->x
, vector
->y
, vector
->z
, expected
->x
, expected
->y
, expected
->z
);
126 #define expect_vec4(expected, vector, ulps) expect_vec4_(__LINE__, expected, vector, ulps)
127 static void expect_vec4_(unsigned int line
, const D3DXVECTOR4
*expected
, const D3DXVECTOR4
*vector
, unsigned int ulps
)
129 BOOL equal
= compare_vec4(expected
, vector
, ulps
);
130 ok_(__FILE__
, line
)(equal
,
131 "Got unexpected vector {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
132 vector
->x
, vector
->y
, vector
->z
, vector
->w
, expected
->x
, expected
->y
, expected
->z
, expected
->w
);
135 #define expect_color(expected, color, ulps) expect_color_(__LINE__, expected, color, ulps)
136 static void expect_color_(unsigned int line
, const D3DXCOLOR
*expected
, const D3DXCOLOR
*color
, unsigned int ulps
)
138 BOOL equal
= compare_color(expected
, color
, ulps
);
139 ok_(__FILE__
, line
)(equal
,
140 "Got unexpected color {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
141 color
->r
, color
->g
, color
->b
, color
->a
, expected
->r
, expected
->g
, expected
->b
, expected
->a
);
144 #define expect_plane(expected, plane, ulps) expect_plane_(__LINE__, expected, plane, ulps)
145 static void expect_plane_(unsigned int line
, const D3DXPLANE
*expected
, const D3DXPLANE
*plane
, unsigned int ulps
)
147 BOOL equal
= compare_plane(expected
, plane
, ulps
);
148 ok_(__FILE__
, line
)(equal
,
149 "Got unexpected plane {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
150 plane
->a
, plane
->b
, plane
->c
, plane
->d
, expected
->a
, expected
->b
, expected
->c
, expected
->d
);
153 #define expect_quaternion(expected, quaternion, ulps) expect_quaternion_(__LINE__, expected, quaternion, ulps)
154 static void expect_quaternion_(unsigned int line
, const D3DXQUATERNION
*expected
,
155 const D3DXQUATERNION
*quaternion
, unsigned int ulps
)
157 BOOL equal
= compare_quaternion(expected
, quaternion
, ulps
);
158 ok_(__FILE__
, line
)(equal
,
159 "Got unexpected quaternion {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
160 quaternion
->x
, quaternion
->y
, quaternion
->z
, quaternion
->w
,
161 expected
->x
, expected
->y
, expected
->z
, expected
->w
);
164 #define expect_matrix(expected, matrix, ulps) expect_matrix_(__LINE__, expected, matrix, ulps)
165 static void expect_matrix_(unsigned int line
, const D3DXMATRIX
*expected
, const D3DXMATRIX
*matrix
, unsigned int ulps
)
167 BOOL equal
= compare_matrix(expected
, matrix
, ulps
);
168 ok_(__FILE__
, line
)(equal
,
169 "Got unexpected matrix {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, "
170 "%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e}, "
171 "expected {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, "
172 "%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e}.\n",
173 U(*matrix
).m
[0][0], U(*matrix
).m
[0][1], U(*matrix
).m
[0][2], U(*matrix
).m
[0][3],
174 U(*matrix
).m
[1][0], U(*matrix
).m
[1][1], U(*matrix
).m
[1][2], U(*matrix
).m
[1][3],
175 U(*matrix
).m
[2][0], U(*matrix
).m
[2][1], U(*matrix
).m
[2][2], U(*matrix
).m
[2][3],
176 U(*matrix
).m
[3][0], U(*matrix
).m
[3][1], U(*matrix
).m
[3][2], U(*matrix
).m
[3][3],
177 U(*expected
).m
[0][0], U(*expected
).m
[0][1], U(*expected
).m
[0][2], U(*expected
).m
[0][3],
178 U(*expected
).m
[1][0], U(*expected
).m
[1][1], U(*expected
).m
[1][2], U(*expected
).m
[1][3],
179 U(*expected
).m
[2][0], U(*expected
).m
[2][1], U(*expected
).m
[2][2], U(*expected
).m
[2][3],
180 U(*expected
).m
[3][0], U(*expected
).m
[3][1], U(*expected
).m
[3][2], U(*expected
).m
[3][3]);
183 #define expect_vec4_array(count, expected, vector, ulps) expect_vec4_array_(__LINE__, count, expected, vector, ulps)
184 static void expect_vec4_array_(unsigned int line
, SIZE_T count
, const D3DXVECTOR4
*expected
,
185 const D3DXVECTOR4
*vector
, unsigned int ulps
)
190 for (i
= 0; i
< count
; ++i
)
192 equal
= compare_vec4(&expected
[i
], &vector
[i
], ulps
);
193 ok_(__FILE__
, line
)(equal
,
194 "Got unexpected vector {%.8e, %.8e, %.8e, %.8e} at index %lu, expected {%.8e, %.8e, %.8e, %.8e}.\n",
195 vector
[i
].x
, vector
[i
].y
, vector
[i
].z
, vector
[i
].w
, i
,
196 expected
[i
].x
, expected
[i
].y
, expected
[i
].z
, expected
[i
].w
);
202 static void D3DXColorTest(void)
204 D3DXCOLOR color
, color1
, color2
, expected
, got
;
205 LPD3DXCOLOR funcpointer
;
208 color
.r
= 0.2f
; color
.g
= 0.75f
; color
.b
= 0.41f
; color
.a
= 0.93f
;
209 color1
.r
= 0.6f
; color1
.g
= 0.55f
; color1
.b
= 0.23f
; color1
.a
= 0.82f
;
210 color2
.r
= 0.3f
; color2
.g
= 0.5f
; color2
.b
= 0.76f
; color2
.a
= 0.11f
;
214 /*_______________D3DXColorAdd________________*/
215 expected
.r
= 0.9f
; expected
.g
= 1.05f
; expected
.b
= 0.99f
, expected
.a
= 0.93f
;
216 D3DXColorAdd(&got
,&color1
,&color2
);
217 expect_color(&expected
, &got
, 1);
218 /* Test the NULL case */
219 funcpointer
= D3DXColorAdd(&got
,NULL
,&color2
);
220 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
221 funcpointer
= D3DXColorAdd(NULL
,NULL
,&color2
);
222 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
223 funcpointer
= D3DXColorAdd(NULL
,NULL
,NULL
);
224 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
226 /*_______________D3DXColorAdjustContrast______*/
227 expected
.r
= 0.41f
; expected
.g
= 0.575f
; expected
.b
= 0.473f
, expected
.a
= 0.93f
;
228 D3DXColorAdjustContrast(&got
,&color
,scale
);
229 expect_color(&expected
, &got
, 0);
231 /*_______________D3DXColorAdjustSaturation______*/
232 expected
.r
= 0.486028f
; expected
.g
= 0.651028f
; expected
.b
= 0.549028f
, expected
.a
= 0.93f
;
233 D3DXColorAdjustSaturation(&got
,&color
,scale
);
234 expect_color(&expected
, &got
, 16);
236 /*_______________D3DXColorLerp________________*/
237 expected
.r
= 0.32f
; expected
.g
= 0.69f
; expected
.b
= 0.356f
; expected
.a
= 0.897f
;
238 D3DXColorLerp(&got
,&color
,&color1
,scale
);
239 expect_color(&expected
, &got
, 0);
240 /* Test the NULL case */
241 funcpointer
= D3DXColorLerp(&got
,NULL
,&color1
,scale
);
242 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
243 funcpointer
= D3DXColorLerp(NULL
,NULL
,&color1
,scale
);
244 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
245 funcpointer
= D3DXColorLerp(NULL
,NULL
,NULL
,scale
);
246 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
248 /*_______________D3DXColorModulate________________*/
249 expected
.r
= 0.18f
; expected
.g
= 0.275f
; expected
.b
= 0.1748f
; expected
.a
= 0.0902f
;
250 D3DXColorModulate(&got
,&color1
,&color2
);
251 expect_color(&expected
, &got
, 0);
252 /* Test the NULL case */
253 funcpointer
= D3DXColorModulate(&got
,NULL
,&color2
);
254 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
255 funcpointer
= D3DXColorModulate(NULL
,NULL
,&color2
);
256 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
257 funcpointer
= D3DXColorModulate(NULL
,NULL
,NULL
);
258 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
260 /*_______________D3DXColorNegative________________*/
261 expected
.r
= 0.8f
; expected
.g
= 0.25f
; expected
.b
= 0.59f
; expected
.a
= 0.93f
;
262 D3DXColorNegative(&got
,&color
);
263 expect_color(&expected
, &got
, 1);
264 /* Test the greater than 1 case */
265 color1
.r
= 0.2f
; color1
.g
= 1.75f
; color1
.b
= 0.41f
; color1
.a
= 0.93f
;
266 expected
.r
= 0.8f
; expected
.g
= -0.75f
; expected
.b
= 0.59f
; expected
.a
= 0.93f
;
267 D3DXColorNegative(&got
,&color1
);
268 expect_color(&expected
, &got
, 1);
269 /* Test the negative case */
270 color1
.r
= 0.2f
; color1
.g
= -0.75f
; color1
.b
= 0.41f
; color1
.a
= 0.93f
;
271 expected
.r
= 0.8f
; expected
.g
= 1.75f
; expected
.b
= 0.59f
; expected
.a
= 0.93f
;
272 D3DXColorNegative(&got
,&color1
);
273 expect_color(&expected
, &got
, 1);
274 /* Test the NULL case */
275 funcpointer
= D3DXColorNegative(&got
,NULL
);
276 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
277 funcpointer
= D3DXColorNegative(NULL
,NULL
);
278 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
280 /*_______________D3DXColorScale________________*/
281 expected
.r
= 0.06f
; expected
.g
= 0.225f
; expected
.b
= 0.123f
; expected
.a
= 0.279f
;
282 D3DXColorScale(&got
,&color
,scale
);
283 expect_color(&expected
, &got
, 1);
284 /* Test the NULL case */
285 funcpointer
= D3DXColorScale(&got
,NULL
,scale
);
286 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
287 funcpointer
= D3DXColorScale(NULL
,NULL
,scale
);
288 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
290 /*_______________D3DXColorSubtract_______________*/
291 expected
.r
= -0.1f
; expected
.g
= 0.25f
; expected
.b
= -0.35f
, expected
.a
= 0.82f
;
292 D3DXColorSubtract(&got
,&color
,&color2
);
293 expect_color(&expected
, &got
, 1);
294 /* Test the NULL case */
295 funcpointer
= D3DXColorSubtract(&got
,NULL
,&color2
);
296 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
297 funcpointer
= D3DXColorSubtract(NULL
,NULL
,&color2
);
298 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
299 funcpointer
= D3DXColorSubtract(NULL
,NULL
,NULL
);
300 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
303 static void D3DXFresnelTest(void)
308 fresnel
= D3DXFresnelTerm(0.5f
, 1.5f
);
309 equal
= compare_float(fresnel
, 8.91867056e-02f
, 1);
310 ok(equal
, "Got unexpected Fresnel term %.8e.\n", fresnel
);
313 static void D3DXMatrixTest(void)
315 D3DXMATRIX expectedmat
, gotmat
, mat
, mat2
, mat3
;
316 BOOL expected
, got
, equal
;
317 float angle
, determinant
;
318 D3DXMATRIX
*funcpointer
;
321 D3DXVECTOR3 at
, axis
, eye
, last
;
324 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
325 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
326 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
327 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
328 U(mat
).m
[0][0] = 10.0f
; U(mat
).m
[1][1] = 20.0f
; U(mat
).m
[2][2] = 30.0f
;
329 U(mat
).m
[3][3] = -40.0f
;
331 U(mat2
).m
[0][0] = 1.0f
; U(mat2
).m
[1][0] = 2.0f
; U(mat2
).m
[2][0] = 3.0f
;
332 U(mat2
).m
[3][0] = 4.0f
; U(mat2
).m
[0][1] = 5.0f
; U(mat2
).m
[1][1] = 6.0f
;
333 U(mat2
).m
[2][1] = 7.0f
; U(mat2
).m
[3][1] = 8.0f
; U(mat2
).m
[0][2] = -8.0f
;
334 U(mat2
).m
[1][2] = -7.0f
; U(mat2
).m
[2][2] = -6.0f
; U(mat2
).m
[3][2] = -5.0f
;
335 U(mat2
).m
[0][3] = -4.0f
; U(mat2
).m
[1][3] = -3.0f
; U(mat2
).m
[2][3] = -2.0f
;
336 U(mat2
).m
[3][3] = -1.0f
;
338 plane
.a
= -3.0f
; plane
.b
= -1.0f
; plane
.c
= 4.0f
; plane
.d
= 7.0f
;
340 q
.x
= 1.0f
; q
.y
= -4.0f
; q
.z
=7.0f
; q
.w
= -11.0f
;
341 r
.x
= 0.87f
; r
.y
= 0.65f
; r
.z
=0.43f
; r
.w
= 0.21f
;
343 at
.x
= -2.0f
; at
.y
= 13.0f
; at
.z
= -9.0f
;
344 axis
.x
= 1.0f
; axis
.y
= -3.0f
; axis
.z
= 7.0f
;
345 eye
.x
= 8.0f
; eye
.y
= -5.0f
; eye
.z
= 5.75f
;
346 last
.x
= 9.7f
; last
.y
= -8.6; last
.z
= 1.3f
;
348 light
.x
= 9.6f
; light
.y
= 8.5f
; light
.z
= 7.4; light
.w
= 6.3;
350 angle
= D3DX_PI
/3.0f
;
352 /*____________D3DXMatrixAffineTransformation______*/
353 U(expectedmat
).m
[0][0] = -459.239990f
; U(expectedmat
).m
[0][1] = -576.719971f
; U(expectedmat
).m
[0][2] = -263.440002f
; U(expectedmat
).m
[0][3] = 0.0f
;
354 U(expectedmat
).m
[1][0] = 519.760010f
; U(expectedmat
).m
[1][1] = -352.440002f
; U(expectedmat
).m
[1][2] = -277.679993f
; U(expectedmat
).m
[1][3] = 0.0f
;
355 U(expectedmat
).m
[2][0] = 363.119995f
; U(expectedmat
).m
[2][1] = -121.040001f
; U(expectedmat
).m
[2][2] = -117.479996f
; U(expectedmat
).m
[2][3] = 0.0f
;
356 U(expectedmat
).m
[3][0] = -1239.0f
; U(expectedmat
).m
[3][1] = 667.0f
; U(expectedmat
).m
[3][2] = 567.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
357 D3DXMatrixAffineTransformation(&gotmat
, 3.56f
, &at
, &q
, &axis
);
358 expect_matrix(&expectedmat
, &gotmat
, 0);
360 /* Test the NULL case */
361 U(expectedmat
).m
[3][0] = 1.0f
; U(expectedmat
).m
[3][1] = -3.0f
; U(expectedmat
).m
[3][2] = 7.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
362 D3DXMatrixAffineTransformation(&gotmat
, 3.56f
, NULL
, &q
, &axis
);
363 expect_matrix(&expectedmat
, &gotmat
, 0);
365 U(expectedmat
).m
[3][0] = -1240.0f
; U(expectedmat
).m
[3][1] = 670.0f
; U(expectedmat
).m
[3][2] = 560.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
366 D3DXMatrixAffineTransformation(&gotmat
, 3.56f
, &at
, &q
, NULL
);
367 expect_matrix(&expectedmat
, &gotmat
, 0);
369 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 0.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
370 D3DXMatrixAffineTransformation(&gotmat
, 3.56f
, NULL
, &q
, NULL
);
371 expect_matrix(&expectedmat
, &gotmat
, 0);
373 U(expectedmat
).m
[0][0] = 3.56f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
374 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 3.56f
; U(expectedmat
).m
[1][2] = 0.0f
; U(expectedmat
).m
[1][3] = 0.0f
;
375 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 3.56f
; U(expectedmat
).m
[2][3] = 0.0f
;
376 U(expectedmat
).m
[3][0] = 1.0f
; U(expectedmat
).m
[3][1] = -3.0f
; U(expectedmat
).m
[3][2] = 7.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
377 D3DXMatrixAffineTransformation(&gotmat
, 3.56f
, NULL
, NULL
, &axis
);
378 expect_matrix(&expectedmat
, &gotmat
, 0);
380 D3DXMatrixAffineTransformation(&gotmat
, 3.56f
, &at
, NULL
, &axis
);
381 expect_matrix(&expectedmat
, &gotmat
, 0);
383 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 0.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
384 D3DXMatrixAffineTransformation(&gotmat
, 3.56f
, &at
, NULL
, NULL
);
385 expect_matrix(&expectedmat
, &gotmat
, 0);
387 D3DXMatrixAffineTransformation(&gotmat
, 3.56f
, NULL
, NULL
, NULL
);
388 expect_matrix(&expectedmat
, &gotmat
, 0);
390 /*____________D3DXMatrixfDeterminant_____________*/
391 determinant
= D3DXMatrixDeterminant(&mat
);
392 equal
= compare_float(determinant
, -147888.0f
, 0);
393 ok(equal
, "Got unexpected determinant %.8e.\n", determinant
);
395 /*____________D3DXMatrixInverse______________*/
396 U(expectedmat
).m
[0][0] = 16067.0f
/73944.0f
; U(expectedmat
).m
[0][1] = -10165.0f
/147888.0f
; U(expectedmat
).m
[0][2] = -2729.0f
/147888.0f
; U(expectedmat
).m
[0][3] = -1631.0f
/49296.0f
;
397 U(expectedmat
).m
[1][0] = -565.0f
/36972.0f
; U(expectedmat
).m
[1][1] = 2723.0f
/73944.0f
; U(expectedmat
).m
[1][2] = -1073.0f
/73944.0f
; U(expectedmat
).m
[1][3] = 289.0f
/24648.0f
;
398 U(expectedmat
).m
[2][0] = -389.0f
/2054.0f
; U(expectedmat
).m
[2][1] = 337.0f
/4108.0f
; U(expectedmat
).m
[2][2] = 181.0f
/4108.0f
; U(expectedmat
).m
[2][3] = 317.0f
/4108.0f
;
399 U(expectedmat
).m
[3][0] = 163.0f
/5688.0f
; U(expectedmat
).m
[3][1] = -101.0f
/11376.0f
; U(expectedmat
).m
[3][2] = -73.0f
/11376.0f
; U(expectedmat
).m
[3][3] = -127.0f
/3792.0f
;
400 D3DXMatrixInverse(&gotmat
,&determinant
,&mat
);
401 expect_matrix(&expectedmat
, &gotmat
, 1);
402 equal
= compare_float(determinant
, -147888.0f
, 0);
403 ok(equal
, "Got unexpected determinant %.8e.\n", determinant
);
404 funcpointer
= D3DXMatrixInverse(&gotmat
,NULL
,&mat2
);
405 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
407 /*____________D3DXMatrixIsIdentity______________*/
409 memset(&mat3
, 0, sizeof(mat3
));
410 got
= D3DXMatrixIsIdentity(&mat3
);
411 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
412 D3DXMatrixIdentity(&mat3
);
414 got
= D3DXMatrixIsIdentity(&mat3
);
415 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
416 U(mat3
).m
[0][0] = 0.000009f
;
418 got
= D3DXMatrixIsIdentity(&mat3
);
419 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
420 /* Test the NULL case */
422 got
= D3DXMatrixIsIdentity(NULL
);
423 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
425 /*____________D3DXMatrixLookatLH_______________*/
426 U(expectedmat
).m
[0][0] = -0.822465f
; U(expectedmat
).m
[0][1] = -0.409489f
; U(expectedmat
).m
[0][2] = -0.394803f
; U(expectedmat
).m
[0][3] = 0.0f
;
427 U(expectedmat
).m
[1][0] = -0.555856f
; U(expectedmat
).m
[1][1] = 0.431286f
; U(expectedmat
).m
[1][2] = 0.710645f
; U(expectedmat
).m
[1][3] = 0.0f
;
428 U(expectedmat
).m
[2][0] = -0.120729f
; U(expectedmat
).m
[2][1] = 0.803935f
; U(expectedmat
).m
[2][2] = -0.582335f
; U(expectedmat
).m
[2][3] = 0.0f
;
429 U(expectedmat
).m
[3][0] = 4.494634f
; U(expectedmat
).m
[3][1] = 0.809719f
; U(expectedmat
).m
[3][2] = 10.060076f
; U(expectedmat
).m
[3][3] = 1.0f
;
430 D3DXMatrixLookAtLH(&gotmat
,&eye
,&at
,&axis
);
431 expect_matrix(&expectedmat
, &gotmat
, 32);
433 /*____________D3DXMatrixLookatRH_______________*/
434 U(expectedmat
).m
[0][0] = 0.822465f
; U(expectedmat
).m
[0][1] = -0.409489f
; U(expectedmat
).m
[0][2] = 0.394803f
; U(expectedmat
).m
[0][3] = 0.0f
;
435 U(expectedmat
).m
[1][0] = 0.555856f
; U(expectedmat
).m
[1][1] = 0.431286f
; U(expectedmat
).m
[1][2] = -0.710645f
; U(expectedmat
).m
[1][3] = 0.0f
;
436 U(expectedmat
).m
[2][0] = 0.120729f
; U(expectedmat
).m
[2][1] = 0.803935f
; U(expectedmat
).m
[2][2] = 0.582335f
; U(expectedmat
).m
[2][3] = 0.0f
;
437 U(expectedmat
).m
[3][0] = -4.494634f
; U(expectedmat
).m
[3][1] = 0.809719f
; U(expectedmat
).m
[3][2] = -10.060076f
; U(expectedmat
).m
[3][3] = 1.0f
;
438 D3DXMatrixLookAtRH(&gotmat
,&eye
,&at
,&axis
);
439 expect_matrix(&expectedmat
, &gotmat
, 32);
441 /*____________D3DXMatrixMultiply______________*/
442 U(expectedmat
).m
[0][0] = 73.0f
; U(expectedmat
).m
[0][1] = 193.0f
; U(expectedmat
).m
[0][2] = -197.0f
; U(expectedmat
).m
[0][3] = -77.0f
;
443 U(expectedmat
).m
[1][0] = 231.0f
; U(expectedmat
).m
[1][1] = 551.0f
; U(expectedmat
).m
[1][2] = -489.0f
; U(expectedmat
).m
[1][3] = -169.0;
444 U(expectedmat
).m
[2][0] = 239.0f
; U(expectedmat
).m
[2][1] = 523.0f
; U(expectedmat
).m
[2][2] = -400.0f
; U(expectedmat
).m
[2][3] = -116.0f
;
445 U(expectedmat
).m
[3][0] = -164.0f
; U(expectedmat
).m
[3][1] = -320.0f
; U(expectedmat
).m
[3][2] = 187.0f
; U(expectedmat
).m
[3][3] = 31.0f
;
446 D3DXMatrixMultiply(&gotmat
,&mat
,&mat2
);
447 expect_matrix(&expectedmat
, &gotmat
, 0);
449 /*____________D3DXMatrixMultiplyTranspose____*/
450 U(expectedmat
).m
[0][0] = 73.0f
; U(expectedmat
).m
[0][1] = 231.0f
; U(expectedmat
).m
[0][2] = 239.0f
; U(expectedmat
).m
[0][3] = -164.0f
;
451 U(expectedmat
).m
[1][0] = 193.0f
; U(expectedmat
).m
[1][1] = 551.0f
; U(expectedmat
).m
[1][2] = 523.0f
; U(expectedmat
).m
[1][3] = -320.0;
452 U(expectedmat
).m
[2][0] = -197.0f
; U(expectedmat
).m
[2][1] = -489.0f
; U(expectedmat
).m
[2][2] = -400.0f
; U(expectedmat
).m
[2][3] = 187.0f
;
453 U(expectedmat
).m
[3][0] = -77.0f
; U(expectedmat
).m
[3][1] = -169.0f
; U(expectedmat
).m
[3][2] = -116.0f
; U(expectedmat
).m
[3][3] = 31.0f
;
454 D3DXMatrixMultiplyTranspose(&gotmat
,&mat
,&mat2
);
455 expect_matrix(&expectedmat
, &gotmat
, 0);
457 /*____________D3DXMatrixOrthoLH_______________*/
458 U(expectedmat
).m
[0][0] = 0.8f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
459 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 0.270270f
; U(expectedmat
).m
[1][2] = 0.0f
; U(expectedmat
).m
[1][3] = 0.0f
;
460 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = -0.151515f
; U(expectedmat
).m
[2][3] = 0.0f
;
461 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = -0.484848f
; U(expectedmat
).m
[3][3] = 1.0f
;
462 D3DXMatrixOrthoLH(&gotmat
, 2.5f
, 7.4f
, -3.2f
, -9.8f
);
463 expect_matrix(&expectedmat
, &gotmat
, 16);
465 /*____________D3DXMatrixOrthoOffCenterLH_______________*/
466 U(expectedmat
).m
[0][0] = 3.636364f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
467 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 0.180180f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
468 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = -0.045662f
; U(expectedmat
).m
[2][3] = 0.0f
;
469 U(expectedmat
).m
[3][0] = -1.727272f
; U(expectedmat
).m
[3][1] = -0.567568f
; U(expectedmat
).m
[3][2] = 0.424658f
; U(expectedmat
).m
[3][3] = 1.0f
;
470 D3DXMatrixOrthoOffCenterLH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
, 9.3, -12.6);
471 expect_matrix(&expectedmat
, &gotmat
, 32);
473 /*____________D3DXMatrixOrthoOffCenterRH_______________*/
474 U(expectedmat
).m
[0][0] = 3.636364f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
475 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 0.180180f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
476 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 0.045662f
; U(expectedmat
).m
[2][3] = 0.0f
;
477 U(expectedmat
).m
[3][0] = -1.727272f
; U(expectedmat
).m
[3][1] = -0.567568f
; U(expectedmat
).m
[3][2] = 0.424658f
; U(expectedmat
).m
[3][3] = 1.0f
;
478 D3DXMatrixOrthoOffCenterRH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
, 9.3, -12.6);
479 expect_matrix(&expectedmat
, &gotmat
, 32);
481 /*____________D3DXMatrixOrthoRH_______________*/
482 U(expectedmat
).m
[0][0] = 0.8f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
483 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 0.270270f
; U(expectedmat
).m
[1][2] = 0.0f
; U(expectedmat
).m
[1][3] = 0.0f
;
484 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 0.151515f
; U(expectedmat
).m
[2][3] = 0.0f
;
485 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = -0.484848f
; U(expectedmat
).m
[3][3] = 1.0f
;
486 D3DXMatrixOrthoRH(&gotmat
, 2.5f
, 7.4f
, -3.2f
, -9.8f
);
487 expect_matrix(&expectedmat
, &gotmat
, 16);
489 /*____________D3DXMatrixPerspectiveFovLH_______________*/
490 U(expectedmat
).m
[0][0] = 13.288858f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
491 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 9.966644f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
492 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 0.783784f
; U(expectedmat
).m
[2][3] = 1.0f
;
493 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 1.881081f
; U(expectedmat
).m
[3][3] = 0.0f
;
494 D3DXMatrixPerspectiveFovLH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
);
495 expect_matrix(&expectedmat
, &gotmat
, 4);
497 /*____________D3DXMatrixPerspectiveFovRH_______________*/
498 U(expectedmat
).m
[0][0] = 13.288858f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
499 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 9.966644f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
500 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = -0.783784f
; U(expectedmat
).m
[2][3] = -1.0f
;
501 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 1.881081f
; U(expectedmat
).m
[3][3] = 0.0f
;
502 D3DXMatrixPerspectiveFovRH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
);
503 expect_matrix(&expectedmat
, &gotmat
, 4);
505 /*____________D3DXMatrixPerspectiveLH_______________*/
506 U(expectedmat
).m
[0][0] = -24.0f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
507 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = -6.4f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
508 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 0.783784f
; U(expectedmat
).m
[2][3] = 1.0f
;
509 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 1.881081f
; U(expectedmat
).m
[3][3] = 0.0f
;
510 D3DXMatrixPerspectiveLH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
);
511 expect_matrix(&expectedmat
, &gotmat
, 4);
513 /*____________D3DXMatrixPerspectiveOffCenterLH_______________*/
514 U(expectedmat
).m
[0][0] = 11.636364f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
515 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 0.576577f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
516 U(expectedmat
).m
[2][0] = -1.727273f
; U(expectedmat
).m
[2][1] = -0.567568f
; U(expectedmat
).m
[2][2] = 0.840796f
; U(expectedmat
).m
[2][3] = 1.0f
;
517 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = -2.690547f
; U(expectedmat
).m
[3][3] = 0.0f
;
518 D3DXMatrixPerspectiveOffCenterLH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
, 3.2f
, -16.9f
);
519 expect_matrix(&expectedmat
, &gotmat
, 8);
521 /*____________D3DXMatrixPerspectiveOffCenterRH_______________*/
522 U(expectedmat
).m
[0][0] = 11.636364f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
523 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 0.576577f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
524 U(expectedmat
).m
[2][0] = 1.727273f
; U(expectedmat
).m
[2][1] = 0.567568f
; U(expectedmat
).m
[2][2] = -0.840796f
; U(expectedmat
).m
[2][3] = -1.0f
;
525 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = -2.690547f
; U(expectedmat
).m
[3][3] = 0.0f
;
526 D3DXMatrixPerspectiveOffCenterRH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
, 3.2f
, -16.9f
);
527 expect_matrix(&expectedmat
, &gotmat
, 8);
529 /*____________D3DXMatrixPerspectiveRH_______________*/
530 U(expectedmat
).m
[0][0] = -24.0f
; U(expectedmat
).m
[0][1] = -0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
531 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = -6.4f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
532 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = -0.783784f
; U(expectedmat
).m
[2][3] = -1.0f
;
533 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 1.881081f
; U(expectedmat
).m
[3][3] = 0.0f
;
534 D3DXMatrixPerspectiveRH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
);
535 expect_matrix(&expectedmat
, &gotmat
, 4);
537 /*____________D3DXMatrixReflect______________*/
538 U(expectedmat
).m
[0][0] = 0.307692f
; U(expectedmat
).m
[0][1] = -0.230769f
; U(expectedmat
).m
[0][2] = 0.923077f
; U(expectedmat
).m
[0][3] = 0.0f
;
539 U(expectedmat
).m
[1][0] = -0.230769; U(expectedmat
).m
[1][1] = 0.923077f
; U(expectedmat
).m
[1][2] = 0.307693f
; U(expectedmat
).m
[1][3] = 0.0f
;
540 U(expectedmat
).m
[2][0] = 0.923077f
; U(expectedmat
).m
[2][1] = 0.307693f
; U(expectedmat
).m
[2][2] = -0.230769f
; U(expectedmat
).m
[2][3] = 0.0f
;
541 U(expectedmat
).m
[3][0] = 1.615385f
; U(expectedmat
).m
[3][1] = 0.538462f
; U(expectedmat
).m
[3][2] = -2.153846f
; U(expectedmat
).m
[3][3] = 1.0f
;
542 D3DXMatrixReflect(&gotmat
,&plane
);
543 expect_matrix(&expectedmat
, &gotmat
, 32);
545 /*____________D3DXMatrixRotationAxis_____*/
546 U(expectedmat
).m
[0][0] = 0.508475f
; U(expectedmat
).m
[0][1] = 0.763805f
; U(expectedmat
).m
[0][2] = 0.397563f
; U(expectedmat
).m
[0][3] = 0.0f
;
547 U(expectedmat
).m
[1][0] = -0.814652f
; U(expectedmat
).m
[1][1] = 0.576271f
; U(expectedmat
).m
[1][2] = -0.065219f
; U(expectedmat
).m
[1][3] = 0.0f
;
548 U(expectedmat
).m
[2][0] = -0.278919f
; U(expectedmat
).m
[2][1] = -0.290713f
; U(expectedmat
).m
[2][2] = 0.915254f
; U(expectedmat
).m
[2][3] = 0.0f
;
549 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 0.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
550 D3DXMatrixRotationAxis(&gotmat
,&axis
,angle
);
551 expect_matrix(&expectedmat
, &gotmat
, 32);
553 /*____________D3DXMatrixRotationQuaternion______________*/
554 U(expectedmat
).m
[0][0] = -129.0f
; U(expectedmat
).m
[0][1] = -162.0f
; U(expectedmat
).m
[0][2] = -74.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
555 U(expectedmat
).m
[1][0] = 146.0f
; U(expectedmat
).m
[1][1] = -99.0f
; U(expectedmat
).m
[1][2] = -78.0f
; U(expectedmat
).m
[1][3] = 0.0f
;
556 U(expectedmat
).m
[2][0] = 102.0f
; U(expectedmat
).m
[2][1] = -34.0f
; U(expectedmat
).m
[2][2] = -33.0f
; U(expectedmat
).m
[2][3] = 0.0f
;
557 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 0.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
558 D3DXMatrixRotationQuaternion(&gotmat
,&q
);
559 expect_matrix(&expectedmat
, &gotmat
, 0);
561 /*____________D3DXMatrixRotationX______________*/
562 U(expectedmat
).m
[0][0] = 1.0f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
563 U(expectedmat
).m
[1][0] = 0.0; U(expectedmat
).m
[1][1] = 0.5f
; U(expectedmat
).m
[1][2] = sqrt(3.0f
)/2.0f
; U(expectedmat
).m
[1][3] = 0.0f
;
564 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = -sqrt(3.0f
)/2.0f
; U(expectedmat
).m
[2][2] = 0.5f
; U(expectedmat
).m
[2][3] = 0.0f
;
565 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 0.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
566 D3DXMatrixRotationX(&gotmat
,angle
);
567 expect_matrix(&expectedmat
, &gotmat
, 1);
569 /*____________D3DXMatrixRotationY______________*/
570 U(expectedmat
).m
[0][0] = 0.5f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = -sqrt(3.0f
)/2.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
571 U(expectedmat
).m
[1][0] = 0.0; U(expectedmat
).m
[1][1] = 1.0f
; U(expectedmat
).m
[1][2] = 0.0f
; U(expectedmat
).m
[1][3] = 0.0f
;
572 U(expectedmat
).m
[2][0] = sqrt(3.0f
)/2.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 0.5f
; U(expectedmat
).m
[2][3] = 0.0f
;
573 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 0.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
574 D3DXMatrixRotationY(&gotmat
,angle
);
575 expect_matrix(&expectedmat
, &gotmat
, 1);
577 /*____________D3DXMatrixRotationYawPitchRoll____*/
578 U(expectedmat
).m
[0][0] = 0.888777f
; U(expectedmat
).m
[0][1] = 0.091875f
; U(expectedmat
).m
[0][2] = -0.449037f
; U(expectedmat
).m
[0][3] = 0.0f
;
579 U(expectedmat
).m
[1][0] = 0.351713f
; U(expectedmat
).m
[1][1] = 0.491487f
; U(expectedmat
).m
[1][2] = 0.796705f
; U(expectedmat
).m
[1][3] = 0.0f
;
580 U(expectedmat
).m
[2][0] = 0.293893f
; U(expectedmat
).m
[2][1] = -0.866025f
; U(expectedmat
).m
[2][2] = 0.404509f
; U(expectedmat
).m
[2][3] = 0.0f
;
581 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 0.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
582 D3DXMatrixRotationYawPitchRoll(&gotmat
, 3.0f
*angle
/5.0f
, angle
, 3.0f
*angle
/17.0f
);
583 expect_matrix(&expectedmat
, &gotmat
, 64);
585 /*____________D3DXMatrixRotationZ______________*/
586 U(expectedmat
).m
[0][0] = 0.5f
; U(expectedmat
).m
[0][1] = sqrt(3.0f
)/2.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
587 U(expectedmat
).m
[1][0] = -sqrt(3.0f
)/2.0f
; U(expectedmat
).m
[1][1] = 0.5f
; U(expectedmat
).m
[1][2] = 0.0f
; U(expectedmat
).m
[1][3] = 0.0f
;
588 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 1.0f
; U(expectedmat
).m
[2][3] = 0.0f
;
589 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 0.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
590 D3DXMatrixRotationZ(&gotmat
,angle
);
591 expect_matrix(&expectedmat
, &gotmat
, 1);
593 /*____________D3DXMatrixScaling______________*/
594 U(expectedmat
).m
[0][0] = 0.69f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
595 U(expectedmat
).m
[1][0] = 0.0; U(expectedmat
).m
[1][1] = 0.53f
; U(expectedmat
).m
[1][2] = 0.0f
; U(expectedmat
).m
[1][3] = 0.0f
;
596 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 4.11f
; U(expectedmat
).m
[2][3] = 0.0f
;
597 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 0.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
598 D3DXMatrixScaling(&gotmat
,0.69f
,0.53f
,4.11f
);
599 expect_matrix(&expectedmat
, &gotmat
, 0);
601 /*____________D3DXMatrixShadow______________*/
602 U(expectedmat
).m
[0][0] = 12.786773f
; U(expectedmat
).m
[0][1] = 5.000961f
; U(expectedmat
).m
[0][2] = 4.353778f
; U(expectedmat
).m
[0][3] = 3.706595f
;
603 U(expectedmat
).m
[1][0] = 1.882715; U(expectedmat
).m
[1][1] = 8.805615f
; U(expectedmat
).m
[1][2] = 1.451259f
; U(expectedmat
).m
[1][3] = 1.235532f
;
604 U(expectedmat
).m
[2][0] = -7.530860f
; U(expectedmat
).m
[2][1] = -6.667949f
; U(expectedmat
).m
[2][2] = 1.333590f
; U(expectedmat
).m
[2][3] = -4.942127f
;
605 U(expectedmat
).m
[3][0] = -13.179006f
; U(expectedmat
).m
[3][1] = -11.668910f
; U(expectedmat
).m
[3][2] = -10.158816f
; U(expectedmat
).m
[3][3] = -1.510094f
;
606 D3DXMatrixShadow(&gotmat
,&light
,&plane
);
607 expect_matrix(&expectedmat
, &gotmat
, 8);
609 /*____________D3DXMatrixTransformation______________*/
610 U(expectedmat
).m
[0][0] = -0.2148f
; U(expectedmat
).m
[0][1] = 1.3116f
; U(expectedmat
).m
[0][2] = 0.4752f
; U(expectedmat
).m
[0][3] = 0.0f
;
611 U(expectedmat
).m
[1][0] = 0.9504f
; U(expectedmat
).m
[1][1] = -0.8836f
; U(expectedmat
).m
[1][2] = 0.9244f
; U(expectedmat
).m
[1][3] = 0.0f
;
612 U(expectedmat
).m
[2][0] = 1.0212f
; U(expectedmat
).m
[2][1] = 0.1936f
; U(expectedmat
).m
[2][2] = -1.3588f
; U(expectedmat
).m
[2][3] = 0.0f
;
613 U(expectedmat
).m
[3][0] = 18.2985f
; U(expectedmat
).m
[3][1] = -29.624001f
; U(expectedmat
).m
[3][2] = 15.683499f
; U(expectedmat
).m
[3][3] = 1.0f
;
614 D3DXMatrixTransformation(&gotmat
,&at
,&q
,NULL
,&eye
,&r
,&last
);
615 expect_matrix(&expectedmat
, &gotmat
, 512);
617 /*____________D3DXMatrixTranslation______________*/
618 U(expectedmat
).m
[0][0] = 1.0f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
619 U(expectedmat
).m
[1][0] = 0.0; U(expectedmat
).m
[1][1] = 1.0f
; U(expectedmat
).m
[1][2] = 0.0f
; U(expectedmat
).m
[1][3] = 0.0f
;
620 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 1.0f
; U(expectedmat
).m
[2][3] = 0.0f
;
621 U(expectedmat
).m
[3][0] = 0.69f
; U(expectedmat
).m
[3][1] = 0.53f
; U(expectedmat
).m
[3][2] = 4.11f
; U(expectedmat
).m
[3][3] = 1.0f
;
622 D3DXMatrixTranslation(&gotmat
,0.69f
,0.53f
,4.11f
);
623 expect_matrix(&expectedmat
, &gotmat
, 0);
625 /*____________D3DXMatrixTranspose______________*/
626 U(expectedmat
).m
[0][0] = 10.0f
; U(expectedmat
).m
[0][1] = 11.0f
; U(expectedmat
).m
[0][2] = 19.0f
; U(expectedmat
).m
[0][3] = 2.0f
;
627 U(expectedmat
).m
[1][0] = 5.0; U(expectedmat
).m
[1][1] = 20.0f
; U(expectedmat
).m
[1][2] = -21.0f
; U(expectedmat
).m
[1][3] = 3.0f
;
628 U(expectedmat
).m
[2][0] = 7.0f
; U(expectedmat
).m
[2][1] = 16.0f
; U(expectedmat
).m
[2][2] = 30.f
; U(expectedmat
).m
[2][3] = -4.0f
;
629 U(expectedmat
).m
[3][0] = 8.0f
; U(expectedmat
).m
[3][1] = 33.0f
; U(expectedmat
).m
[3][2] = 43.0f
; U(expectedmat
).m
[3][3] = -40.0f
;
630 D3DXMatrixTranspose(&gotmat
,&mat
);
631 expect_matrix(&expectedmat
, &gotmat
, 0);
634 static void D3DXPlaneTest(void)
637 D3DXPLANE expectedplane
, gotplane
, nulplane
, plane
;
638 D3DXVECTOR3 expectedvec
, gotvec
, vec1
, vec2
, vec3
;
639 LPD3DXVECTOR3 funcpointer
;
643 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
644 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
645 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
646 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
647 U(mat
).m
[0][0] = 10.0f
; U(mat
).m
[1][1] = 20.0f
; U(mat
).m
[2][2] = 30.0f
;
648 U(mat
).m
[3][3] = -40.0f
;
650 plane
.a
= -3.0f
; plane
.b
= -1.0f
; plane
.c
= 4.0f
; plane
.d
= 7.0f
;
652 vec
.x
= 2.0f
; vec
.y
= 5.0f
; vec
.z
= -6.0f
; vec
.w
= 11.0f
;
654 /*_______________D3DXPlaneDot________________*/
656 got
= D3DXPlaneDot(&plane
,&vec
),
657 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
659 got
= D3DXPlaneDot(NULL
,&vec
),
660 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
662 got
= D3DXPlaneDot(NULL
,NULL
),
663 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
665 /*_______________D3DXPlaneDotCoord________________*/
667 got
= D3DXPlaneDotCoord(&plane
,&vec
),
668 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
670 got
= D3DXPlaneDotCoord(NULL
,&vec
),
671 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
673 got
= D3DXPlaneDotCoord(NULL
,NULL
),
674 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
676 /*_______________D3DXPlaneDotNormal______________*/
678 got
= D3DXPlaneDotNormal(&plane
,&vec
),
679 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
681 got
= D3DXPlaneDotNormal(NULL
,&vec
),
682 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
684 got
= D3DXPlaneDotNormal(NULL
,NULL
),
685 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
687 /*_______________D3DXPlaneFromPointNormal_______*/
688 vec1
.x
= 11.0f
; vec1
.y
= 13.0f
; vec1
.z
= 15.0f
;
689 vec2
.x
= 17.0f
; vec2
.y
= 31.0f
; vec2
.z
= 24.0f
;
690 expectedplane
.a
= 17.0f
; expectedplane
.b
= 31.0f
; expectedplane
.c
= 24.0f
; expectedplane
.d
= -950.0f
;
691 D3DXPlaneFromPointNormal(&gotplane
, &vec1
, &vec2
);
692 expect_plane(&expectedplane
, &gotplane
, 0);
693 gotplane
.a
= vec2
.x
; gotplane
.b
= vec2
.y
; gotplane
.c
= vec2
.z
;
694 D3DXPlaneFromPointNormal(&gotplane
, &vec1
, (D3DXVECTOR3
*)&gotplane
);
695 expect_plane(&expectedplane
, &gotplane
, 0);
696 gotplane
.a
= vec1
.x
; gotplane
.b
= vec1
.y
; gotplane
.c
= vec1
.z
;
697 expectedplane
.d
= -1826.0f
;
698 D3DXPlaneFromPointNormal(&gotplane
, (D3DXVECTOR3
*)&gotplane
, &vec2
);
699 expect_plane(&expectedplane
, &gotplane
, 0);
701 /*_______________D3DXPlaneFromPoints_______*/
702 vec1
.x
= 1.0f
; vec1
.y
= 2.0f
; vec1
.z
= 3.0f
;
703 vec2
.x
= 1.0f
; vec2
.y
= -6.0f
; vec2
.z
= -5.0f
;
704 vec3
.x
= 83.0f
; vec3
.y
= 74.0f
; vec3
.z
= 65.0f
;
705 expectedplane
.a
= 0.085914f
; expectedplane
.b
= -0.704492f
; expectedplane
.c
= 0.704492f
; expectedplane
.d
= -0.790406f
;
706 D3DXPlaneFromPoints(&gotplane
,&vec1
,&vec2
,&vec3
);
707 expect_plane(&expectedplane
, &gotplane
, 64);
709 /*_______________D3DXPlaneIntersectLine___________*/
710 vec1
.x
= 9.0f
; vec1
.y
= 6.0f
; vec1
.z
= 3.0f
;
711 vec2
.x
= 2.0f
; vec2
.y
= 5.0f
; vec2
.z
= 8.0f
;
712 expectedvec
.x
= 20.0f
/3.0f
; expectedvec
.y
= 17.0f
/3.0f
; expectedvec
.z
= 14.0f
/3.0f
;
713 D3DXPlaneIntersectLine(&gotvec
,&plane
,&vec1
,&vec2
);
714 expect_vec3(&expectedvec
, &gotvec
, 1);
715 /* Test a parallel line */
716 vec1
.x
= 11.0f
; vec1
.y
= 13.0f
; vec1
.z
= 15.0f
;
717 vec2
.x
= 17.0f
; vec2
.y
= 31.0f
; vec2
.z
= 24.0f
;
718 expectedvec
.x
= 20.0f
/3.0f
; expectedvec
.y
= 17.0f
/3.0f
; expectedvec
.z
= 14.0f
/3.0f
;
719 funcpointer
= D3DXPlaneIntersectLine(&gotvec
,&plane
,&vec1
,&vec2
);
720 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
722 /*_______________D3DXPlaneNormalize______________*/
723 expectedplane
.a
= -3.0f
/sqrt(26.0f
); expectedplane
.b
= -1.0f
/sqrt(26.0f
); expectedplane
.c
= 4.0f
/sqrt(26.0f
); expectedplane
.d
= 7.0/sqrt(26.0f
);
724 D3DXPlaneNormalize(&gotplane
, &plane
);
725 expect_plane(&expectedplane
, &gotplane
, 2);
726 nulplane
.a
= 0.0; nulplane
.b
= 0.0f
, nulplane
.c
= 0.0f
; nulplane
.d
= 0.0f
;
727 expectedplane
.a
= 0.0f
; expectedplane
.b
= 0.0f
; expectedplane
.c
= 0.0f
; expectedplane
.d
= 0.0f
;
728 D3DXPlaneNormalize(&gotplane
, &nulplane
);
729 expect_plane(&expectedplane
, &gotplane
, 0);
731 /*_______________D3DXPlaneTransform____________*/
732 expectedplane
.a
= 49.0f
; expectedplane
.b
= -98.0f
; expectedplane
.c
= 55.0f
; expectedplane
.d
= -165.0f
;
733 D3DXPlaneTransform(&gotplane
,&plane
,&mat
);
734 expect_plane(&expectedplane
, &gotplane
, 0);
737 static void D3DXQuaternionTest(void)
740 D3DXQUATERNION expectedquat
, gotquat
, Nq
, Nq1
, nul
, smallq
, smallr
, q
, r
, s
, t
, u
;
741 BOOL expectedbool
, gotbool
, equal
;
742 float angle
, got
, scale
, scale2
;
743 LPD3DXQUATERNION funcpointer
;
744 D3DXVECTOR3 axis
, expectedvec
;
746 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
; nul
.w
= 0.0f
;
747 q
.x
= 1.0f
, q
.y
= 2.0f
; q
.z
= 4.0f
; q
.w
= 10.0f
;
748 r
.x
= -3.0f
; r
.y
= 4.0f
; r
.z
= -5.0f
; r
.w
= 7.0;
749 t
.x
= -1111.0f
, t
.y
= 111.0f
; t
.z
= -11.0f
; t
.w
= 1.0f
;
750 u
.x
= 91.0f
; u
.y
= - 82.0f
; u
.z
= 7.3f
; u
.w
= -6.4f
;
751 smallq
.x
= 0.1f
; smallq
.y
= 0.2f
; smallq
.z
= 0.3f
; smallq
.w
= 0.4f
;
752 smallr
.x
= 0.5f
; smallr
.y
= 0.6f
; smallr
.z
= 0.7f
; smallr
.w
= 0.8f
;
757 /*_______________D3DXQuaternionBaryCentric________________________*/
758 expectedquat
.x
= -867.444458; expectedquat
.y
= 87.851111f
; expectedquat
.z
= -9.937778f
; expectedquat
.w
= 3.235555f
;
759 D3DXQuaternionBaryCentric(&gotquat
,&q
,&r
,&t
,scale
,scale2
);
760 expect_quaternion(&expectedquat
, &gotquat
, 1);
762 /*_______________D3DXQuaternionConjugate________________*/
763 expectedquat
.x
= -1.0f
; expectedquat
.y
= -2.0f
; expectedquat
.z
= -4.0f
; expectedquat
.w
= 10.0f
;
764 D3DXQuaternionConjugate(&gotquat
,&q
);
765 expect_quaternion(&expectedquat
, &gotquat
, 0);
766 /* Test the NULL case */
767 funcpointer
= D3DXQuaternionConjugate(&gotquat
,NULL
);
768 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
769 funcpointer
= D3DXQuaternionConjugate(NULL
,NULL
);
770 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
772 /*_______________D3DXQuaternionDot______________________*/
773 got
= D3DXQuaternionDot(&q
,&r
);
774 equal
= compare_float(got
, 55.0f
, 0);
775 ok(equal
, "Got unexpected dot %.8e.\n", got
);
776 /* Tests the case NULL */
777 got
= D3DXQuaternionDot(NULL
,&r
);
778 equal
= compare_float(got
, 0.0f
, 0);
779 ok(equal
, "Got unexpected dot %.8e.\n", got
);
780 got
= D3DXQuaternionDot(NULL
,NULL
);
781 equal
= compare_float(got
, 0.0f
, 0);
782 ok(equal
, "Got unexpected dot %.8e.\n", got
);
784 /*_______________D3DXQuaternionExp______________________________*/
785 expectedquat
.x
= -0.216382f
; expectedquat
.y
= -0.432764f
; expectedquat
.z
= -0.8655270f
; expectedquat
.w
= -0.129449f
;
786 D3DXQuaternionExp(&gotquat
,&q
);
787 expect_quaternion(&expectedquat
, &gotquat
, 16);
788 /* Test the null quaternion */
789 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 1.0f
;
790 D3DXQuaternionExp(&gotquat
,&nul
);
791 expect_quaternion(&expectedquat
, &gotquat
, 0);
792 /* Test the case where the norm of the quaternion is <1 */
793 Nq1
.x
= 0.2f
; Nq1
.y
= 0.1f
; Nq1
.z
= 0.3; Nq1
.w
= 0.9f
;
794 expectedquat
.x
= 0.195366; expectedquat
.y
= 0.097683f
; expectedquat
.z
= 0.293049f
; expectedquat
.w
= 0.930813f
;
795 D3DXQuaternionExp(&gotquat
,&Nq1
);
796 expect_quaternion(&expectedquat
, &gotquat
, 8);
798 /*_______________D3DXQuaternionIdentity________________*/
799 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 1.0f
;
800 D3DXQuaternionIdentity(&gotquat
);
801 expect_quaternion(&expectedquat
, &gotquat
, 0);
802 /* Test the NULL case */
803 funcpointer
= D3DXQuaternionIdentity(NULL
);
804 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
806 /*_______________D3DXQuaternionInverse________________________*/
807 expectedquat
.x
= -1.0f
/121.0f
; expectedquat
.y
= -2.0f
/121.0f
; expectedquat
.z
= -4.0f
/121.0f
; expectedquat
.w
= 10.0f
/121.0f
;
808 D3DXQuaternionInverse(&gotquat
,&q
);
809 expect_quaternion(&expectedquat
, &gotquat
, 0);
811 expectedquat
.x
= 1.0f
; expectedquat
.y
= 2.0f
; expectedquat
.z
= 4.0f
; expectedquat
.w
= 10.0f
;
812 D3DXQuaternionInverse(&gotquat
,&gotquat
);
813 expect_quaternion(&expectedquat
, &gotquat
, 1);
816 /*_______________D3DXQuaternionIsIdentity________________*/
817 s
.x
= 0.0f
; s
.y
= 0.0f
; s
.z
= 0.0f
; s
.w
= 1.0f
;
819 gotbool
= D3DXQuaternionIsIdentity(&s
);
820 ok( expectedbool
== gotbool
, "Expected boolean : %d, Got bool : %d\n", expectedbool
, gotbool
);
821 s
.x
= 2.3f
; s
.y
= -4.2f
; s
.z
= 1.2f
; s
.w
=0.2f
;
822 expectedbool
= FALSE
;
823 gotbool
= D3DXQuaternionIsIdentity(&q
);
824 ok( expectedbool
== gotbool
, "Expected boolean : %d, Got bool : %d\n", expectedbool
, gotbool
);
825 /* Test the NULL case */
826 gotbool
= D3DXQuaternionIsIdentity(NULL
);
827 ok(gotbool
== FALSE
, "Expected boolean: %d, Got boolean: %d\n", FALSE
, gotbool
);
829 /*_______________D3DXQuaternionLength__________________________*/
830 got
= D3DXQuaternionLength(&q
);
831 equal
= compare_float(got
, 11.0f
, 0);
832 ok(equal
, "Got unexpected length %.8e.\n", got
);
833 /* Tests the case NULL. */
834 got
= D3DXQuaternionLength(NULL
);
835 equal
= compare_float(got
, 0.0f
, 0);
836 ok(equal
, "Got unexpected length %.8e.\n", got
);
838 /*_______________D3DXQuaternionLengthSq________________________*/
839 got
= D3DXQuaternionLengthSq(&q
);
840 equal
= compare_float(got
, 121.0f
, 0);
841 ok(equal
, "Got unexpected length %.8e.\n", got
);
842 /* Tests the case NULL */
843 got
= D3DXQuaternionLengthSq(NULL
);
844 equal
= compare_float(got
, 0.0f
, 0);
845 ok(equal
, "Got unexpected length %.8e.\n", got
);
847 /*_______________D3DXQuaternionLn______________________________*/
848 expectedquat
.x
= 1.0f
; expectedquat
.y
= 2.0f
; expectedquat
.z
= 4.0f
; expectedquat
.w
= 0.0f
;
849 D3DXQuaternionLn(&gotquat
,&q
);
850 expect_quaternion(&expectedquat
, &gotquat
, 0);
851 expectedquat
.x
= -3.0f
; expectedquat
.y
= 4.0f
; expectedquat
.z
= -5.0f
; expectedquat
.w
= 0.0f
;
852 D3DXQuaternionLn(&gotquat
,&r
);
853 expect_quaternion(&expectedquat
, &gotquat
, 0);
854 Nq
.x
= 1.0f
/11.0f
; Nq
.y
= 2.0f
/11.0f
; Nq
.z
= 4.0f
/11.0f
; Nq
.w
=10.0f
/11.0f
;
855 expectedquat
.x
= 0.093768f
; expectedquat
.y
= 0.187536f
; expectedquat
.z
= 0.375073f
; expectedquat
.w
= 0.0f
;
856 D3DXQuaternionLn(&gotquat
,&Nq
);
857 expect_quaternion(&expectedquat
, &gotquat
, 32);
858 Nq
.x
= 0.0f
; Nq
.y
= 0.0f
; Nq
.z
= 0.0f
; Nq
.w
= 1.0f
;
859 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.0f
;
860 D3DXQuaternionLn(&gotquat
,&Nq
);
861 expect_quaternion(&expectedquat
, &gotquat
, 0);
862 Nq
.x
= 5.4f
; Nq
.y
= 1.2f
; Nq
.z
= -0.3f
; Nq
.w
= -0.3f
;
863 expectedquat
.x
= 10.616652f
; expectedquat
.y
= 2.359256f
; expectedquat
.z
= -0.589814f
; expectedquat
.w
= 0.0f
;
864 D3DXQuaternionLn(&gotquat
,&Nq
);
865 expect_quaternion(&expectedquat
, &gotquat
, 1);
866 /* Test the case where the norm of the quaternion is <1 */
867 Nq1
.x
= 0.2f
; Nq1
.y
= 0.1f
; Nq1
.z
= 0.3; Nq1
.w
= 0.9f
;
868 expectedquat
.x
= 0.206945f
; expectedquat
.y
= 0.103473f
; expectedquat
.z
= 0.310418f
; expectedquat
.w
= 0.0f
;
869 D3DXQuaternionLn(&gotquat
,&Nq1
);
870 expect_quaternion(&expectedquat
, &gotquat
, 64);
871 /* Test the case where the real part of the quaternion is -1.0f */
872 Nq1
.x
= 0.2f
; Nq1
.y
= 0.1f
; Nq1
.z
= 0.3; Nq1
.w
= -1.0f
;
873 expectedquat
.x
= 0.2f
; expectedquat
.y
= 0.1f
; expectedquat
.z
= 0.3f
; expectedquat
.w
= 0.0f
;
874 D3DXQuaternionLn(&gotquat
,&Nq1
);
875 expect_quaternion(&expectedquat
, &gotquat
, 0);
877 /*_______________D3DXQuaternionMultiply________________________*/
878 expectedquat
.x
= 3.0f
; expectedquat
.y
= 61.0f
; expectedquat
.z
= -32.0f
; expectedquat
.w
= 85.0f
;
879 D3DXQuaternionMultiply(&gotquat
,&q
,&r
);
880 expect_quaternion(&expectedquat
, &gotquat
, 0);
882 /*_______________D3DXQuaternionNormalize________________________*/
883 expectedquat
.x
= 1.0f
/11.0f
; expectedquat
.y
= 2.0f
/11.0f
; expectedquat
.z
= 4.0f
/11.0f
; expectedquat
.w
= 10.0f
/11.0f
;
884 D3DXQuaternionNormalize(&gotquat
,&q
);
885 expect_quaternion(&expectedquat
, &gotquat
, 1);
887 /*_______________D3DXQuaternionRotationAxis___________________*/
888 axis
.x
= 2.0f
; axis
.y
= 7.0; axis
.z
= 13.0f
;
889 angle
= D3DX_PI
/3.0f
;
890 expectedquat
.x
= 0.067116; expectedquat
.y
= 0.234905f
; expectedquat
.z
= 0.436251f
; expectedquat
.w
= 0.866025f
;
891 D3DXQuaternionRotationAxis(&gotquat
,&axis
,angle
);
892 expect_quaternion(&expectedquat
, &gotquat
, 64);
893 /* Test the nul quaternion */
894 axis
.x
= 0.0f
; axis
.y
= 0.0; axis
.z
= 0.0f
;
895 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.866025f
;
896 D3DXQuaternionRotationAxis(&gotquat
,&axis
,angle
);
897 expect_quaternion(&expectedquat
, &gotquat
, 8);
899 /*_______________D3DXQuaternionRotationMatrix___________________*/
900 /* test when the trace is >0 */
901 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
902 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
903 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
904 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
905 U(mat
).m
[0][0] = 10.0f
; U(mat
).m
[1][1] = 20.0f
; U(mat
).m
[2][2] = 30.0f
;
906 U(mat
).m
[3][3] = 48.0f
;
907 expectedquat
.x
= 2.368682f
; expectedquat
.y
= 0.768221f
; expectedquat
.z
= -0.384111f
; expectedquat
.w
= 3.905125f
;
908 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
909 expect_quaternion(&expectedquat
, &gotquat
, 16);
910 /* test the case when the greater element is (2,2) */
911 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
912 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
913 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
914 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
915 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = -60.0f
; U(mat
).m
[2][2] = 40.0f
;
916 U(mat
).m
[3][3] = 48.0f
;
917 expectedquat
.x
= 1.233905f
; expectedquat
.y
= -0.237290f
; expectedquat
.z
= 5.267827f
; expectedquat
.w
= -0.284747f
;
918 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
919 expect_quaternion(&expectedquat
, &gotquat
, 64);
920 /* test the case when the greater element is (1,1) */
921 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
922 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
923 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
924 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
925 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 60.0f
; U(mat
).m
[2][2] = -80.0f
;
926 U(mat
).m
[3][3] = 48.0f
;
927 expectedquat
.x
= 0.651031f
; expectedquat
.y
= 6.144103f
; expectedquat
.z
= -0.203447f
; expectedquat
.w
= 0.488273f
;
928 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
929 expect_quaternion(&expectedquat
, &gotquat
, 8);
930 /* test the case when the trace is near 0 in a matrix which is not a rotation */
931 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
932 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
933 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
934 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
935 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = -0.9f
;
936 U(mat
).m
[3][3] = 48.0f
;
937 expectedquat
.x
= 1.709495f
; expectedquat
.y
= 2.339872f
; expectedquat
.z
= -0.534217f
; expectedquat
.w
= 1.282122f
;
938 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
939 expect_quaternion(&expectedquat
, &gotquat
, 8);
940 /* test the case when the trace is 0.49 in a matrix which is not a rotation */
941 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
942 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
943 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
944 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
945 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = -0.51f
;
946 U(mat
).m
[3][3] = 48.0f
;
947 expectedquat
.x
= 1.724923f
; expectedquat
.y
= 2.318944f
; expectedquat
.z
= -0.539039f
; expectedquat
.w
= 1.293692f
;
948 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
949 expect_quaternion(&expectedquat
, &gotquat
, 8);
950 /* test the case when the trace is 0.51 in a matrix which is not a rotation */
951 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
952 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
953 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
954 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
955 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = -0.49f
;
956 U(mat
).m
[3][3] = 48.0f
;
957 expectedquat
.x
= 1.725726f
; expectedquat
.y
= 2.317865f
; expectedquat
.z
= -0.539289f
; expectedquat
.w
= 1.294294f
;
958 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
959 expect_quaternion(&expectedquat
, &gotquat
, 8);
960 /* test the case when the trace is 0.99 in a matrix which is not a rotation */
961 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
962 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
963 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
964 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
965 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = -0.01f
;
966 U(mat
).m
[3][3] = 48.0f
;
967 expectedquat
.x
= 1.745328f
; expectedquat
.y
= 2.291833f
; expectedquat
.z
= -0.545415f
; expectedquat
.w
= 1.308996f
;
968 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
969 expect_quaternion(&expectedquat
, &gotquat
, 4);
970 /* test the case when the trace is 1.0 in a matrix which is not a rotation */
971 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
972 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
973 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
974 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
975 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 0.0f
;
976 U(mat
).m
[3][3] = 48.0f
;
977 expectedquat
.x
= 1.745743f
; expectedquat
.y
= 2.291288f
; expectedquat
.z
= -0.545545f
; expectedquat
.w
= 1.309307f
;
978 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
979 expect_quaternion(&expectedquat
, &gotquat
, 8);
980 /* test the case when the trace is 1.01 in a matrix which is not a rotation */
981 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
982 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
983 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
984 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
985 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 0.01f
;
986 U(mat
).m
[3][3] = 48.0f
;
987 expectedquat
.x
= 18.408188f
; expectedquat
.y
= 5.970223f
; expectedquat
.z
= -2.985111f
; expectedquat
.w
= 0.502494f
;
988 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
989 expect_quaternion(&expectedquat
, &gotquat
, 4);
990 /* test the case when the trace is 1.5 in a matrix which is not a rotation */
991 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
992 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
993 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
994 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
995 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 0.5f
;
996 U(mat
).m
[3][3] = 48.0f
;
997 expectedquat
.x
= 15.105186f
; expectedquat
.y
= 4.898980f
; expectedquat
.z
= -2.449490f
; expectedquat
.w
= 0.612372f
;
998 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
999 expect_quaternion(&expectedquat
, &gotquat
, 8);
1000 /* test the case when the trace is 1.7 in a matrix which is not a rotation */
1001 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
1002 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
1003 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
1004 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
1005 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 0.70f
;
1006 U(mat
).m
[3][3] = 48.0f
;
1007 expectedquat
.x
= 14.188852f
; expectedquat
.y
= 4.601790f
; expectedquat
.z
= -2.300895f
; expectedquat
.w
= 0.651920f
;
1008 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
1009 expect_quaternion(&expectedquat
, &gotquat
, 4);
1010 /* test the case when the trace is 1.99 in a matrix which is not a rotation */
1011 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
1012 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
1013 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
1014 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
1015 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 0.99f
;
1016 U(mat
).m
[3][3] = 48.0f
;
1017 expectedquat
.x
= 13.114303f
; expectedquat
.y
= 4.253287f
; expectedquat
.z
= -2.126644f
; expectedquat
.w
= 0.705337f
;
1018 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
1019 expect_quaternion(&expectedquat
, &gotquat
, 4);
1020 /* test the case when the trace is 2.0 in a matrix which is not a rotation */
1021 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
1022 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
1023 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
1024 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
1025 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 2.0f
;
1026 U(mat
).m
[3][3] = 48.0f
;
1027 expectedquat
.x
= 10.680980f
; expectedquat
.y
= 3.464102f
; expectedquat
.z
= -1.732051f
; expectedquat
.w
= 0.866025f
;
1028 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
1029 expect_quaternion(&expectedquat
, &gotquat
, 8);
1031 /*_______________D3DXQuaternionRotationYawPitchRoll__________*/
1032 expectedquat
.x
= 0.303261f
; expectedquat
.y
= 0.262299f
; expectedquat
.z
= 0.410073f
; expectedquat
.w
= 0.819190f
;
1033 D3DXQuaternionRotationYawPitchRoll(&gotquat
,D3DX_PI
/4.0f
,D3DX_PI
/11.0f
,D3DX_PI
/3.0f
);
1034 expect_quaternion(&expectedquat
, &gotquat
, 16);
1036 /*_______________D3DXQuaternionSlerp________________________*/
1037 expectedquat
.x
= -0.2f
; expectedquat
.y
= 2.6f
; expectedquat
.z
= 1.3f
; expectedquat
.w
= 9.1f
;
1038 D3DXQuaternionSlerp(&gotquat
,&q
,&r
,scale
);
1039 expect_quaternion(&expectedquat
, &gotquat
, 4);
1040 expectedquat
.x
= 334.0f
; expectedquat
.y
= -31.9f
; expectedquat
.z
= 6.1f
; expectedquat
.w
= 6.7f
;
1041 D3DXQuaternionSlerp(&gotquat
,&q
,&t
,scale
);
1042 expect_quaternion(&expectedquat
, &gotquat
, 2);
1043 expectedquat
.x
= 0.239485f
; expectedquat
.y
= 0.346580f
; expectedquat
.z
= 0.453676f
; expectedquat
.w
= 0.560772f
;
1044 D3DXQuaternionSlerp(&gotquat
,&smallq
,&smallr
,scale
);
1045 expect_quaternion(&expectedquat
, &gotquat
, 32);
1047 /*_______________D3DXQuaternionSquad________________________*/
1048 expectedquat
.x
= -156.296f
; expectedquat
.y
= 30.242f
; expectedquat
.z
= -2.5022f
; expectedquat
.w
= 7.3576f
;
1049 D3DXQuaternionSquad(&gotquat
,&q
,&r
,&t
,&u
,scale
);
1050 expect_quaternion(&expectedquat
, &gotquat
, 2);
1052 /*_______________D3DXQuaternionSquadSetup___________________*/
1053 r
.x
= 1.0f
, r
.y
= 2.0f
; r
.z
= 4.0f
; r
.w
= 10.0f
;
1054 s
.x
= -3.0f
; s
.y
= 4.0f
; s
.z
= -5.0f
; s
.w
= 7.0;
1055 t
.x
= -1111.0f
, t
.y
= 111.0f
; t
.z
= -11.0f
; t
.w
= 1.0f
;
1056 u
.x
= 91.0f
; u
.y
= - 82.0f
; u
.z
= 7.3f
; u
.w
= -6.4f
;
1057 D3DXQuaternionSquadSetup(&gotquat
, &Nq
, &Nq1
, &r
, &s
, &t
, &u
);
1058 expectedquat
.x
= 7.121285f
; expectedquat
.y
= 2.159964f
; expectedquat
.z
= -3.855094f
; expectedquat
.w
= 5.362844f
;
1059 expect_quaternion(&expectedquat
, &gotquat
, 2);
1060 expectedquat
.x
= -1113.492920f
; expectedquat
.y
= 82.679260f
; expectedquat
.z
= -6.696645f
; expectedquat
.w
= -4.090050f
;
1061 expect_quaternion(&expectedquat
, &Nq
, 2);
1062 expectedquat
.x
= -1111.0f
; expectedquat
.y
= 111.0f
; expectedquat
.z
= -11.0f
; expectedquat
.w
= 1.0f
;
1063 expect_quaternion(&expectedquat
, &Nq1
, 0);
1065 D3DXQuaternionSquadSetup(&gotquat
, &Nq
, &Nq1
, &r
, &gotquat
, &t
, &u
);
1066 expectedquat
.x
= -1113.492920f
; expectedquat
.y
= 82.679260f
; expectedquat
.z
= -6.696645f
; expectedquat
.w
= -4.090050f
;
1067 expect_quaternion(&expectedquat
, &Nq
, 2);
1069 D3DXQuaternionSquadSetup(&gotquat
, &Nq
, &Nq1
, &r
, &s
, &t
, &Nq1
);
1070 expect_quaternion(&expectedquat
, &Nq
, 2);
1071 r
.x
= 0.2f
; r
.y
= 0.3f
; r
.z
= 1.3f
; r
.w
= -0.6f
;
1072 s
.x
= -3.0f
; s
.y
=-2.0f
; s
.z
= 4.0f
; s
.w
= 0.2f
;
1073 t
.x
= 0.4f
; t
.y
= 8.3f
; t
.z
= -3.1f
; t
.w
= -2.7f
;
1074 u
.x
= 1.1f
; u
.y
= -0.7f
; u
.z
= 9.2f
; u
.w
= 0.0f
;
1075 D3DXQuaternionSquadSetup(&gotquat
, &Nq
, &Nq1
, &r
, &s
, &u
, &t
);
1076 expectedquat
.x
= -4.139569f
; expectedquat
.y
= -2.469115f
; expectedquat
.z
= 2.364477f
; expectedquat
.w
= 0.465494f
;
1077 expect_quaternion(&expectedquat
, &gotquat
, 16);
1078 expectedquat
.x
= 2.342533f
; expectedquat
.y
= 2.365127f
; expectedquat
.z
= 8.628538f
; expectedquat
.w
= -0.898356f
;
1079 expect_quaternion(&expectedquat
, &Nq
, 16);
1080 expectedquat
.x
= 1.1f
; expectedquat
.y
= -0.7f
; expectedquat
.z
= 9.2f
; expectedquat
.w
= 0.0f
;
1081 expect_quaternion(&expectedquat
, &Nq1
, 0);
1082 D3DXQuaternionSquadSetup(&gotquat
, &Nq
, &Nq1
, &r
, &s
, &t
, &u
);
1083 expectedquat
.x
= -3.754567f
; expectedquat
.y
= -0.586085f
; expectedquat
.z
= 3.815818f
; expectedquat
.w
= -0.198150f
;
1084 expect_quaternion(&expectedquat
, &gotquat
, 32);
1085 expectedquat
.x
= 0.140773f
; expectedquat
.y
= -8.737090f
; expectedquat
.z
= -0.516593f
; expectedquat
.w
= 3.053942f
;
1086 expect_quaternion(&expectedquat
, &Nq
, 16);
1087 expectedquat
.x
= -0.4f
; expectedquat
.y
= -8.3f
; expectedquat
.z
= 3.1f
; expectedquat
.w
= 2.7f
;
1088 expect_quaternion(&expectedquat
, &Nq1
, 0);
1089 r
.x
= -1.0f
; r
.y
= 0.0f
; r
.z
= 0.0f
; r
.w
= 0.0f
;
1090 s
.x
= 1.0f
; s
.y
=0.0f
; s
.z
= 0.0f
; s
.w
= 0.0f
;
1091 t
.x
= 1.0f
; t
.y
= 0.0f
; t
.z
= 0.0f
; t
.w
= 0.0f
;
1092 u
.x
= -1.0f
; u
.y
= 0.0f
; u
.z
= 0.0f
; u
.w
= 0.0f
;
1093 D3DXQuaternionSquadSetup(&gotquat
, &Nq
, &Nq1
, &r
, &s
, &t
, &u
);
1094 expectedquat
.x
= 1.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.0f
;
1095 expect_quaternion(&expectedquat
, &gotquat
, 0);
1096 expectedquat
.x
= 1.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.0f
;
1097 expect_quaternion(&expectedquat
, &Nq
, 0);
1098 expectedquat
.x
= 1.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.0f
;
1099 expect_quaternion(&expectedquat
, &Nq1
, 0);
1101 /*_______________D3DXQuaternionToAxisAngle__________________*/
1102 Nq
.x
= 1.0f
/22.0f
; Nq
.y
= 2.0f
/22.0f
; Nq
.z
= 4.0f
/22.0f
; Nq
.w
= 10.0f
/22.0f
;
1103 expectedvec
.x
= 1.0f
/22.0f
; expectedvec
.y
= 2.0f
/22.0f
; expectedvec
.z
= 4.0f
/22.0f
;
1104 D3DXQuaternionToAxisAngle(&Nq
,&axis
,&angle
);
1105 expect_vec3(&expectedvec
, &axis
, 0);
1106 equal
= compare_float(angle
, 2.197869f
, 0);
1107 ok(equal
, "Got unexpected angle %.8e.\n", angle
);
1108 /* Test if |w|>1.0f */
1109 expectedvec
.x
= 1.0f
; expectedvec
.y
= 2.0f
; expectedvec
.z
= 4.0f
;
1110 D3DXQuaternionToAxisAngle(&q
,&axis
,&angle
);
1111 expect_vec3(&expectedvec
, &axis
, 0);
1112 /* Test the null quaternion */
1113 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
;
1114 D3DXQuaternionToAxisAngle(&nul
, &axis
, &angle
);
1115 expect_vec3(&expectedvec
, &axis
, 0);
1116 equal
= compare_float(angle
, 3.14159274e+00f
, 0);
1117 ok(equal
, "Got unexpected angle %.8e.\n", angle
);
1119 D3DXQuaternionToAxisAngle(&nul
, &axis
, NULL
);
1120 D3DXQuaternionToAxisAngle(&nul
, NULL
, &angle
);
1121 expect_vec3(&expectedvec
, &axis
, 0);
1122 equal
= compare_float(angle
, 3.14159274e+00f
, 0);
1123 ok(equal
, "Got unexpected angle %.8e.\n", angle
);
1126 static void D3DXVector2Test(void)
1128 D3DXVECTOR2 expectedvec
, gotvec
, nul
, u
, v
, w
, x
;
1129 LPD3DXVECTOR2 funcpointer
;
1130 D3DXVECTOR4 expectedtrans
, gottrans
;
1131 float coeff1
, coeff2
, got
, scale
;
1135 nul
.x
= 0.0f
; nul
.y
= 0.0f
;
1136 u
.x
= 3.0f
; u
.y
= 4.0f
;
1137 v
.x
= -7.0f
; v
.y
= 9.0f
;
1138 w
.x
= 4.0f
; w
.y
= -3.0f
;
1139 x
.x
= 2.0f
; x
.y
= -11.0f
;
1141 U(mat
).m
[0][0] = 1.0f
; U(mat
).m
[0][1] = 2.0f
; U(mat
).m
[0][2] = 3.0f
; U(mat
).m
[0][3] = 4.0f
;
1142 U(mat
).m
[1][0] = 5.0f
; U(mat
).m
[1][1] = 6.0f
; U(mat
).m
[1][2] = 7.0f
; U(mat
).m
[1][3] = 8.0f
;
1143 U(mat
).m
[2][0] = 9.0f
; U(mat
).m
[2][1] = 10.0f
; U(mat
).m
[2][2] = 11.0f
; U(mat
).m
[2][3] = 12.0f
;
1144 U(mat
).m
[3][0] = 13.0f
; U(mat
).m
[3][1] = 14.0f
; U(mat
).m
[3][2] = 15.0f
; U(mat
).m
[3][3] = 16.0f
;
1146 coeff1
= 2.0f
; coeff2
= 5.0f
;
1149 /*_______________D3DXVec2Add__________________________*/
1150 expectedvec
.x
= -4.0f
; expectedvec
.y
= 13.0f
;
1151 D3DXVec2Add(&gotvec
,&u
,&v
);
1152 expect_vec2(&expectedvec
, &gotvec
, 0);
1153 /* Tests the case NULL */
1154 funcpointer
= D3DXVec2Add(&gotvec
,NULL
,&v
);
1155 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1156 funcpointer
= D3DXVec2Add(NULL
,NULL
,NULL
);
1157 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1159 /*_______________D3DXVec2BaryCentric___________________*/
1160 expectedvec
.x
= -12.0f
; expectedvec
.y
= -21.0f
;
1161 D3DXVec2BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
1162 expect_vec2(&expectedvec
, &gotvec
, 0);
1164 /*_______________D3DXVec2CatmullRom____________________*/
1165 expectedvec
.x
= 5820.25f
; expectedvec
.y
= -3654.5625f
;
1166 D3DXVec2CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1167 expect_vec2(&expectedvec
, &gotvec
, 0);
1169 /*_______________D3DXVec2CCW__________________________*/
1170 got
= D3DXVec2CCW(&u
, &v
);
1171 equal
= compare_float(got
, 55.0f
, 0);
1172 ok(equal
, "Got unexpected ccw %.8e.\n", got
);
1173 /* Tests the case NULL. */
1174 got
= D3DXVec2CCW(NULL
, &v
);
1175 equal
= compare_float(got
, 0.0f
, 0);
1176 ok(equal
, "Got unexpected ccw %.8e.\n", got
);
1177 got
= D3DXVec2CCW(NULL
, NULL
);
1178 equal
= compare_float(got
, 0.0f
, 0);
1179 ok(equal
, "Got unexpected ccw %.8e.\n", got
);
1181 /*_______________D3DXVec2Dot__________________________*/
1182 got
= D3DXVec2Dot(&u
, &v
);
1183 equal
= compare_float(got
, 15.0f
, 0);
1184 ok(equal
, "Got unexpected dot %.8e.\n", got
);
1185 /* Tests the case NULL */
1186 got
= D3DXVec2Dot(NULL
, &v
);
1187 equal
= compare_float(got
, 0.0f
, 0);
1188 ok(equal
, "Got unexpected dot %.8e.\n", got
);
1189 got
= D3DXVec2Dot(NULL
, NULL
);
1190 equal
= compare_float(got
, 0.0f
, 0);
1191 ok(equal
, "Got unexpected dot %.8e.\n", got
);
1193 /*_______________D3DXVec2Hermite__________________________*/
1194 expectedvec
.x
= 2604.625f
; expectedvec
.y
= -4533.0f
;
1195 D3DXVec2Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1196 expect_vec2(&expectedvec
, &gotvec
, 0);
1198 /*_______________D3DXVec2Length__________________________*/
1199 got
= D3DXVec2Length(&u
);
1200 equal
= compare_float(got
, 5.0f
, 0);
1201 ok(equal
, "Got unexpected length %.8e.\n", got
);
1202 /* Tests the case NULL. */
1203 got
= D3DXVec2Length(NULL
);
1204 equal
= compare_float(got
, 0.0f
, 0);
1205 ok(equal
, "Got unexpected length %.8e.\n", got
);
1207 /*_______________D3DXVec2LengthSq________________________*/
1208 got
= D3DXVec2LengthSq(&u
);
1209 equal
= compare_float(got
, 25.0f
, 0);
1210 ok(equal
, "Got unexpected length %.8e.\n", got
);
1211 /* Tests the case NULL. */
1212 got
= D3DXVec2LengthSq(NULL
);
1213 equal
= compare_float(got
, 0.0f
, 0);
1214 ok(equal
, "Got unexpected length %.8e.\n", got
);
1216 /*_______________D3DXVec2Lerp__________________________*/
1217 expectedvec
.x
= 68.0f
; expectedvec
.y
= -28.5f
;
1218 D3DXVec2Lerp(&gotvec
, &u
, &v
, scale
);
1219 expect_vec2(&expectedvec
, &gotvec
, 0);
1220 /* Tests the case NULL. */
1221 funcpointer
= D3DXVec2Lerp(&gotvec
,NULL
,&v
,scale
);
1222 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1223 funcpointer
= D3DXVec2Lerp(NULL
,NULL
,NULL
,scale
);
1224 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1226 /*_______________D3DXVec2Maximize__________________________*/
1227 expectedvec
.x
= 3.0f
; expectedvec
.y
= 9.0f
;
1228 D3DXVec2Maximize(&gotvec
, &u
, &v
);
1229 expect_vec2(&expectedvec
, &gotvec
, 0);
1230 /* Tests the case NULL. */
1231 funcpointer
= D3DXVec2Maximize(&gotvec
,NULL
,&v
);
1232 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1233 funcpointer
= D3DXVec2Maximize(NULL
,NULL
,NULL
);
1234 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1236 /*_______________D3DXVec2Minimize__________________________*/
1237 expectedvec
.x
= -7.0f
; expectedvec
.y
= 4.0f
;
1238 D3DXVec2Minimize(&gotvec
,&u
,&v
);
1239 expect_vec2(&expectedvec
, &gotvec
, 0);
1240 /* Tests the case NULL */
1241 funcpointer
= D3DXVec2Minimize(&gotvec
,NULL
,&v
);
1242 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1243 funcpointer
= D3DXVec2Minimize(NULL
,NULL
,NULL
);
1244 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1246 /*_______________D3DXVec2Normalize_________________________*/
1247 expectedvec
.x
= 0.6f
; expectedvec
.y
= 0.8f
;
1248 D3DXVec2Normalize(&gotvec
,&u
);
1249 expect_vec2(&expectedvec
, &gotvec
, 0);
1250 /* Test the nul vector */
1251 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
;
1252 D3DXVec2Normalize(&gotvec
,&nul
);
1253 expect_vec2(&expectedvec
, &gotvec
, 0);
1255 /*_______________D3DXVec2Scale____________________________*/
1256 expectedvec
.x
= -19.5f
; expectedvec
.y
= -26.0f
;
1257 D3DXVec2Scale(&gotvec
,&u
,scale
);
1258 expect_vec2(&expectedvec
, &gotvec
, 0);
1259 /* Tests the case NULL */
1260 funcpointer
= D3DXVec2Scale(&gotvec
,NULL
,scale
);
1261 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1262 funcpointer
= D3DXVec2Scale(NULL
,NULL
,scale
);
1263 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1265 /*_______________D3DXVec2Subtract__________________________*/
1266 expectedvec
.x
= 10.0f
; expectedvec
.y
= -5.0f
;
1267 D3DXVec2Subtract(&gotvec
, &u
, &v
);
1268 expect_vec2(&expectedvec
, &gotvec
, 0);
1269 /* Tests the case NULL. */
1270 funcpointer
= D3DXVec2Subtract(&gotvec
,NULL
,&v
);
1271 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1272 funcpointer
= D3DXVec2Subtract(NULL
,NULL
,NULL
);
1273 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1275 /*_______________D3DXVec2Transform_______________________*/
1276 expectedtrans
.x
= 36.0f
; expectedtrans
.y
= 44.0f
; expectedtrans
.z
= 52.0f
; expectedtrans
.w
= 60.0f
;
1277 D3DXVec2Transform(&gottrans
, &u
, &mat
);
1278 expect_vec4(&expectedtrans
, &gottrans
, 0);
1279 gottrans
.x
= u
.x
; gottrans
.y
= u
.y
;
1280 D3DXVec2Transform(&gottrans
, (D3DXVECTOR2
*)&gottrans
, &mat
);
1281 expect_vec4(&expectedtrans
, &gottrans
, 0);
1283 /*_______________D3DXVec2TransformCoord_______________________*/
1284 expectedvec
.x
= 0.6f
; expectedvec
.y
= 11.0f
/15.0f
;
1285 D3DXVec2TransformCoord(&gotvec
, &u
, &mat
);
1286 expect_vec2(&expectedvec
, &gotvec
, 1);
1287 gotvec
.x
= u
.x
; gotvec
.y
= u
.y
;
1288 D3DXVec2TransformCoord(&gotvec
, (D3DXVECTOR2
*)&gotvec
, &mat
);
1289 expect_vec2(&expectedvec
, &gotvec
, 1);
1291 /*_______________D3DXVec2TransformNormal______________________*/
1292 expectedvec
.x
= 23.0f
; expectedvec
.y
= 30.0f
;
1293 D3DXVec2TransformNormal(&gotvec
,&u
,&mat
);
1294 expect_vec2(&expectedvec
, &gotvec
, 0);
1297 static void D3DXVector3Test(void)
1299 D3DVIEWPORT9 viewport
;
1300 D3DXVECTOR3 expectedvec
, gotvec
, nul
, u
, v
, w
, x
;
1301 LPD3DXVECTOR3 funcpointer
;
1302 D3DXVECTOR4 expectedtrans
, gottrans
;
1303 D3DXMATRIX mat
, projection
, view
, world
;
1304 float coeff1
, coeff2
, got
, scale
;
1307 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
;
1308 u
.x
= 9.0f
; u
.y
= 6.0f
; u
.z
= 2.0f
;
1309 v
.x
= 2.0f
; v
.y
= -3.0f
; v
.z
= -4.0;
1310 w
.x
= 3.0f
; w
.y
= -5.0f
; w
.z
= 7.0f
;
1311 x
.x
= 4.0f
; x
.y
= 1.0f
; x
.z
= 11.0f
;
1313 viewport
.Width
= 800; viewport
.MinZ
= 0.2f
; viewport
.X
= 10;
1314 viewport
.Height
= 680; viewport
.MaxZ
= 0.9f
; viewport
.Y
= 5;
1316 U(mat
).m
[0][0] = 1.0f
; U(mat
).m
[0][1] = 2.0f
; U(mat
).m
[0][2] = 3.0f
; U(mat
).m
[0][3] = 4.0f
;
1317 U(mat
).m
[1][0] = 5.0f
; U(mat
).m
[1][1] = 6.0f
; U(mat
).m
[1][2] = 7.0f
; U(mat
).m
[1][3] = 8.0f
;
1318 U(mat
).m
[2][0] = 9.0f
; U(mat
).m
[2][1] = 10.0f
; U(mat
).m
[2][2] = 11.0f
; U(mat
).m
[2][3] = 12.0f
;
1319 U(mat
).m
[3][0] = 13.0f
; U(mat
).m
[3][1] = 14.0f
; U(mat
).m
[3][2] = 15.0f
; U(mat
).m
[3][3] = 16.0f
;
1321 U(view
).m
[0][1] = 5.0f
; U(view
).m
[0][2] = 7.0f
; U(view
).m
[0][3] = 8.0f
;
1322 U(view
).m
[1][0] = 11.0f
; U(view
).m
[1][2] = 16.0f
; U(view
).m
[1][3] = 33.0f
;
1323 U(view
).m
[2][0] = 19.0f
; U(view
).m
[2][1] = -21.0f
; U(view
).m
[2][3] = 43.0f
;
1324 U(view
).m
[3][0] = 2.0f
; U(view
).m
[3][1] = 3.0f
; U(view
).m
[3][2] = -4.0f
;
1325 U(view
).m
[0][0] = 10.0f
; U(view
).m
[1][1] = 20.0f
; U(view
).m
[2][2] = 30.0f
;
1326 U(view
).m
[3][3] = -40.0f
;
1328 U(world
).m
[0][0] = 21.0f
; U(world
).m
[0][1] = 2.0f
; U(world
).m
[0][2] = 3.0f
; U(world
).m
[0][3] = 4.0;
1329 U(world
).m
[1][0] = 5.0f
; U(world
).m
[1][1] = 23.0f
; U(world
).m
[1][2] = 7.0f
; U(world
).m
[1][3] = 8.0f
;
1330 U(world
).m
[2][0] = -8.0f
; U(world
).m
[2][1] = -7.0f
; U(world
).m
[2][2] = 25.0f
; U(world
).m
[2][3] = -5.0f
;
1331 U(world
).m
[3][0] = -4.0f
; U(world
).m
[3][1] = -3.0f
; U(world
).m
[3][2] = -2.0f
; U(world
).m
[3][3] = 27.0f
;
1333 coeff1
= 2.0f
; coeff2
= 5.0f
;
1336 /*_______________D3DXVec3Add__________________________*/
1337 expectedvec
.x
= 11.0f
; expectedvec
.y
= 3.0f
; expectedvec
.z
= -2.0f
;
1338 D3DXVec3Add(&gotvec
,&u
,&v
);
1339 expect_vec3(&expectedvec
, &gotvec
, 0);
1340 /* Tests the case NULL */
1341 funcpointer
= D3DXVec3Add(&gotvec
,NULL
,&v
);
1342 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1343 funcpointer
= D3DXVec3Add(NULL
,NULL
,NULL
);
1344 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1346 /*_______________D3DXVec3BaryCentric___________________*/
1347 expectedvec
.x
= -35.0f
; expectedvec
.y
= -67.0; expectedvec
.z
= 15.0f
;
1348 D3DXVec3BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
1349 expect_vec3(&expectedvec
, &gotvec
, 0);
1351 /*_______________D3DXVec3CatmullRom____________________*/
1352 expectedvec
.x
= 1458.0f
; expectedvec
.y
= 22.1875f
; expectedvec
.z
= 4141.375f
;
1353 D3DXVec3CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1354 expect_vec3(&expectedvec
, &gotvec
, 0);
1356 /*_______________D3DXVec3Cross________________________*/
1357 expectedvec
.x
= -18.0f
; expectedvec
.y
= 40.0f
; expectedvec
.z
= -39.0f
;
1358 D3DXVec3Cross(&gotvec
,&u
,&v
);
1359 expect_vec3(&expectedvec
, &gotvec
, 0);
1360 expectedvec
.x
= -277.0f
; expectedvec
.y
= -150.0f
; expectedvec
.z
= -26.0f
;
1361 D3DXVec3Cross(&gotvec
,&gotvec
,&v
);
1362 expect_vec3(&expectedvec
, &gotvec
, 0);
1363 /* Tests the case NULL */
1364 funcpointer
= D3DXVec3Cross(&gotvec
,NULL
,&v
);
1365 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1366 funcpointer
= D3DXVec3Cross(NULL
,NULL
,NULL
);
1367 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1369 /*_______________D3DXVec3Dot__________________________*/
1370 got
= D3DXVec3Dot(&u
, &v
);
1371 equal
= compare_float(got
, -8.0f
, 0);
1372 ok(equal
, "Got unexpected dot %.8e.\n", got
);
1373 /* Tests the case NULL */
1374 got
= D3DXVec3Dot(NULL
, &v
);
1375 equal
= compare_float(got
, 0.0f
, 0);
1376 ok(equal
, "Got unexpected dot %.8e.\n", got
);
1377 got
= D3DXVec3Dot(NULL
, NULL
);
1378 equal
= compare_float(got
, 0.0f
, 0);
1379 ok(equal
, "Got unexpected dot %.8e.\n", got
);
1381 /*_______________D3DXVec3Hermite__________________________*/
1382 expectedvec
.x
= -6045.75f
; expectedvec
.y
= -6650.0f
; expectedvec
.z
= 1358.875f
;
1383 D3DXVec3Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1384 expect_vec3(&expectedvec
, &gotvec
, 0);
1386 /*_______________D3DXVec3Length__________________________*/
1387 got
= D3DXVec3Length(&u
);
1388 equal
= compare_float(got
, 11.0f
, 0);
1389 ok(equal
, "Got unexpected length %.8e.\n", got
);
1390 /* Tests the case NULL. */
1391 got
= D3DXVec3Length(NULL
);
1392 equal
= compare_float(got
, 0.0f
, 0);
1393 ok(equal
, "Got unexpected length %.8e.\n", got
);
1395 /*_______________D3DXVec3LengthSq________________________*/
1396 got
= D3DXVec3LengthSq(&u
);
1397 equal
= compare_float(got
, 121.0f
, 0);
1398 ok(equal
, "Got unexpected length %.8e.\n", got
);
1399 /* Tests the case NULL. */
1400 got
= D3DXVec3LengthSq(NULL
);
1401 equal
= compare_float(got
, 0.0f
, 0);
1402 ok(equal
, "Got unexpected length %.8e.\n", got
);
1404 /*_______________D3DXVec3Lerp__________________________*/
1405 expectedvec
.x
= 54.5f
; expectedvec
.y
= 64.5f
, expectedvec
.z
= 41.0f
;
1406 D3DXVec3Lerp(&gotvec
,&u
,&v
,scale
);
1407 expect_vec3(&expectedvec
, &gotvec
, 0);
1408 /* Tests the case NULL */
1409 funcpointer
= D3DXVec3Lerp(&gotvec
,NULL
,&v
,scale
);
1410 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1411 funcpointer
= D3DXVec3Lerp(NULL
,NULL
,NULL
,scale
);
1412 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1414 /*_______________D3DXVec3Maximize__________________________*/
1415 expectedvec
.x
= 9.0f
; expectedvec
.y
= 6.0f
; expectedvec
.z
= 2.0f
;
1416 D3DXVec3Maximize(&gotvec
,&u
,&v
);
1417 expect_vec3(&expectedvec
, &gotvec
, 0);
1418 /* Tests the case NULL */
1419 funcpointer
= D3DXVec3Maximize(&gotvec
,NULL
,&v
);
1420 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1421 funcpointer
= D3DXVec3Maximize(NULL
,NULL
,NULL
);
1422 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1424 /*_______________D3DXVec3Minimize__________________________*/
1425 expectedvec
.x
= 2.0f
; expectedvec
.y
= -3.0f
; expectedvec
.z
= -4.0f
;
1426 D3DXVec3Minimize(&gotvec
,&u
,&v
);
1427 expect_vec3(&expectedvec
, &gotvec
, 0);
1428 /* Tests the case NULL */
1429 funcpointer
= D3DXVec3Minimize(&gotvec
,NULL
,&v
);
1430 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1431 funcpointer
= D3DXVec3Minimize(NULL
,NULL
,NULL
);
1432 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1434 /*_______________D3DXVec3Normalize_________________________*/
1435 expectedvec
.x
= 9.0f
/11.0f
; expectedvec
.y
= 6.0f
/11.0f
; expectedvec
.z
= 2.0f
/11.0f
;
1436 D3DXVec3Normalize(&gotvec
,&u
);
1437 expect_vec3(&expectedvec
, &gotvec
, 1);
1438 /* Test the nul vector */
1439 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
;
1440 D3DXVec3Normalize(&gotvec
,&nul
);
1441 expect_vec3(&expectedvec
, &gotvec
, 0);
1443 /*_______________D3DXVec3Scale____________________________*/
1444 expectedvec
.x
= -58.5f
; expectedvec
.y
= -39.0f
; expectedvec
.z
= -13.0f
;
1445 D3DXVec3Scale(&gotvec
,&u
,scale
);
1446 expect_vec3(&expectedvec
, &gotvec
, 0);
1447 /* Tests the case NULL */
1448 funcpointer
= D3DXVec3Scale(&gotvec
,NULL
,scale
);
1449 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1450 funcpointer
= D3DXVec3Scale(NULL
,NULL
,scale
);
1451 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1453 /*_______________D3DXVec3Subtract_______________________*/
1454 expectedvec
.x
= 7.0f
; expectedvec
.y
= 9.0f
; expectedvec
.z
= 6.0f
;
1455 D3DXVec3Subtract(&gotvec
,&u
,&v
);
1456 expect_vec3(&expectedvec
, &gotvec
, 0);
1457 /* Tests the case NULL */
1458 funcpointer
= D3DXVec3Subtract(&gotvec
,NULL
,&v
);
1459 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1460 funcpointer
= D3DXVec3Subtract(NULL
,NULL
,NULL
);
1461 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1463 /*_______________D3DXVec3Transform_______________________*/
1464 expectedtrans
.x
= 70.0f
; expectedtrans
.y
= 88.0f
; expectedtrans
.z
= 106.0f
; expectedtrans
.w
= 124.0f
;
1465 D3DXVec3Transform(&gottrans
, &u
, &mat
);
1466 expect_vec4(&expectedtrans
, &gottrans
, 0);
1468 gottrans
.x
= u
.x
; gottrans
.y
= u
.y
; gottrans
.z
= u
.z
;
1469 D3DXVec3Transform(&gottrans
, (D3DXVECTOR3
*)&gottrans
, &mat
);
1470 expect_vec4(&expectedtrans
, &gottrans
, 0);
1472 /*_______________D3DXVec3TransformCoord_______________________*/
1473 expectedvec
.x
= 70.0f
/124.0f
; expectedvec
.y
= 88.0f
/124.0f
; expectedvec
.z
= 106.0f
/124.0f
;
1474 D3DXVec3TransformCoord(&gotvec
,&u
,&mat
);
1475 expect_vec3(&expectedvec
, &gotvec
, 1);
1477 /*_______________D3DXVec3TransformNormal______________________*/
1478 expectedvec
.x
= 57.0f
; expectedvec
.y
= 74.0f
; expectedvec
.z
= 91.0f
;
1479 D3DXVec3TransformNormal(&gotvec
,&u
,&mat
);
1480 expect_vec3(&expectedvec
, &gotvec
, 0);
1482 /*_______________D3DXVec3Project_________________________*/
1483 expectedvec
.x
= 1135.721924f
; expectedvec
.y
= 147.086914f
; expectedvec
.z
= 0.153412f
;
1484 D3DXMatrixPerspectiveFovLH(&projection
,D3DX_PI
/4.0f
,20.0f
/17.0f
,1.0f
,1000.0f
);
1485 D3DXVec3Project(&gotvec
,&u
,&viewport
,&projection
,&view
,&world
);
1486 expect_vec3(&expectedvec
, &gotvec
, 32);
1487 /* World matrix can be omitted */
1488 D3DXMatrixMultiply(&mat
,&world
,&view
);
1489 D3DXVec3Project(&gotvec
,&u
,&viewport
,&projection
,&mat
,NULL
);
1490 expect_vec3(&expectedvec
, &gotvec
, 32);
1491 /* Projection matrix can be omitted */
1492 D3DXMatrixMultiply(&mat
,&view
,&projection
);
1493 D3DXVec3Project(&gotvec
,&u
,&viewport
,NULL
,&mat
,&world
);
1494 expect_vec3(&expectedvec
, &gotvec
, 32);
1495 /* View matrix can be omitted */
1496 D3DXMatrixMultiply(&mat
,&world
,&view
);
1497 D3DXVec3Project(&gotvec
,&u
,&viewport
,&projection
,NULL
,&mat
);
1498 expect_vec3(&expectedvec
, &gotvec
, 32);
1499 /* All matrices can be omitted */
1500 expectedvec
.x
= 4010.000000f
; expectedvec
.y
= -1695.000000f
; expectedvec
.z
= 1.600000f
;
1501 D3DXVec3Project(&gotvec
,&u
,&viewport
,NULL
,NULL
,NULL
);
1502 expect_vec3(&expectedvec
, &gotvec
, 2);
1503 /* Viewport can be omitted */
1504 expectedvec
.x
= 1.814305f
; expectedvec
.y
= 0.582097f
; expectedvec
.z
= -0.066555f
;
1505 D3DXVec3Project(&gotvec
,&u
,NULL
,&projection
,&view
,&world
);
1506 expect_vec3(&expectedvec
, &gotvec
, 64);
1508 /*_______________D3DXVec3Unproject_________________________*/
1509 expectedvec
.x
= -2.913411f
; expectedvec
.y
= 1.593215f
; expectedvec
.z
= 0.380724f
;
1510 D3DXMatrixPerspectiveFovLH(&projection
,D3DX_PI
/4.0f
,20.0f
/17.0f
,1.0f
,1000.0f
);
1511 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,&projection
,&view
,&world
);
1512 expect_vec3(&expectedvec
, &gotvec
, 16);
1513 /* World matrix can be omitted */
1514 D3DXMatrixMultiply(&mat
,&world
,&view
);
1515 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,&projection
,&mat
,NULL
);
1516 expect_vec3(&expectedvec
, &gotvec
, 16);
1517 /* Projection matrix can be omitted */
1518 D3DXMatrixMultiply(&mat
,&view
,&projection
);
1519 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,NULL
,&mat
,&world
);
1520 expect_vec3(&expectedvec
, &gotvec
, 32);
1521 /* View matrix can be omitted */
1522 D3DXMatrixMultiply(&mat
,&world
,&view
);
1523 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,&projection
,NULL
,&mat
);
1524 expect_vec3(&expectedvec
, &gotvec
, 16);
1525 /* All matrices can be omitted */
1526 expectedvec
.x
= -1.002500f
; expectedvec
.y
= 0.997059f
; expectedvec
.z
= 2.571429f
;
1527 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,NULL
,NULL
,NULL
);
1528 expect_vec3(&expectedvec
, &gotvec
, 4);
1529 /* Viewport can be omitted */
1530 expectedvec
.x
= -11.018396f
; expectedvec
.y
= 3.218991f
; expectedvec
.z
= 1.380329f
;
1531 D3DXVec3Unproject(&gotvec
,&u
,NULL
,&projection
,&view
,&world
);
1532 expect_vec3(&expectedvec
, &gotvec
, 8);
1535 static void D3DXVector4Test(void)
1537 D3DXVECTOR4 expectedvec
, gotvec
, u
, v
, w
, x
;
1538 LPD3DXVECTOR4 funcpointer
;
1539 D3DXVECTOR4 expectedtrans
, gottrans
;
1540 float coeff1
, coeff2
, got
, scale
;
1544 u
.x
= 1.0f
; u
.y
= 2.0f
; u
.z
= 4.0f
; u
.w
= 10.0;
1545 v
.x
= -3.0f
; v
.y
= 4.0f
; v
.z
= -5.0f
; v
.w
= 7.0;
1546 w
.x
= 4.0f
; w
.y
=6.0f
; w
.z
= -2.0f
; w
.w
= 1.0f
;
1547 x
.x
= 6.0f
; x
.y
= -7.0f
; x
.z
=8.0f
; x
.w
= -9.0f
;
1549 U(mat
).m
[0][0] = 1.0f
; U(mat
).m
[0][1] = 2.0f
; U(mat
).m
[0][2] = 3.0f
; U(mat
).m
[0][3] = 4.0f
;
1550 U(mat
).m
[1][0] = 5.0f
; U(mat
).m
[1][1] = 6.0f
; U(mat
).m
[1][2] = 7.0f
; U(mat
).m
[1][3] = 8.0f
;
1551 U(mat
).m
[2][0] = 9.0f
; U(mat
).m
[2][1] = 10.0f
; U(mat
).m
[2][2] = 11.0f
; U(mat
).m
[2][3] = 12.0f
;
1552 U(mat
).m
[3][0] = 13.0f
; U(mat
).m
[3][1] = 14.0f
; U(mat
).m
[3][2] = 15.0f
; U(mat
).m
[3][3] = 16.0f
;
1554 coeff1
= 2.0f
; coeff2
= 5.0;
1557 /*_______________D3DXVec4Add__________________________*/
1558 expectedvec
.x
= -2.0f
; expectedvec
.y
= 6.0f
; expectedvec
.z
= -1.0f
; expectedvec
.w
= 17.0f
;
1559 D3DXVec4Add(&gotvec
,&u
,&v
);
1560 expect_vec4(&expectedvec
, &gotvec
, 0);
1561 /* Tests the case NULL */
1562 funcpointer
= D3DXVec4Add(&gotvec
,NULL
,&v
);
1563 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1564 funcpointer
= D3DXVec4Add(NULL
,NULL
,NULL
);
1565 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1567 /*_______________D3DXVec4BaryCentric____________________*/
1568 expectedvec
.x
= 8.0f
; expectedvec
.y
= 26.0; expectedvec
.z
= -44.0f
; expectedvec
.w
= -41.0f
;
1569 D3DXVec4BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
1570 expect_vec4(&expectedvec
, &gotvec
, 0);
1572 /*_______________D3DXVec4CatmullRom____________________*/
1573 expectedvec
.x
= 2754.625f
; expectedvec
.y
= 2367.5625f
; expectedvec
.z
= 1060.1875f
; expectedvec
.w
= 131.3125f
;
1574 D3DXVec4CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1575 expect_vec4(&expectedvec
, &gotvec
, 0);
1577 /*_______________D3DXVec4Cross_________________________*/
1578 expectedvec
.x
= 390.0f
; expectedvec
.y
= -393.0f
; expectedvec
.z
= -316.0f
; expectedvec
.w
= 166.0f
;
1579 D3DXVec4Cross(&gotvec
,&u
,&v
,&w
);
1580 expect_vec4(&expectedvec
, &gotvec
, 0);
1582 /*_______________D3DXVec4Dot__________________________*/
1583 got
= D3DXVec4Dot(&u
, &v
);
1584 equal
= compare_float(got
, 55.0f
, 0);
1585 ok(equal
, "Got unexpected dot %.8e.\n", got
);
1586 /* Tests the case NULL. */
1587 got
= D3DXVec4Dot(NULL
, &v
);
1588 equal
= compare_float(got
, 0.0f
, 0);
1589 ok(equal
, "Got unexpected dot %.8e.\n", got
);
1590 got
= D3DXVec4Dot(NULL
, NULL
);
1591 equal
= compare_float(got
, 0.0f
, 0);
1592 ok(equal
, "Got unexpected dot %.8e.\n", got
);
1594 /*_______________D3DXVec4Hermite_________________________*/
1595 expectedvec
.x
= 1224.625f
; expectedvec
.y
= 3461.625f
; expectedvec
.z
= -4758.875f
; expectedvec
.w
= -5781.5f
;
1596 D3DXVec4Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1597 expect_vec4(&expectedvec
, &gotvec
, 0);
1599 /*_______________D3DXVec4Length__________________________*/
1600 got
= D3DXVec4Length(&u
);
1601 equal
= compare_float(got
, 11.0f
, 0);
1602 ok(equal
, "Got unexpected length %.8e.\n", got
);
1603 /* Tests the case NULL. */
1604 got
= D3DXVec4Length(NULL
);
1605 equal
= compare_float(got
, 0.0f
, 0);
1606 ok(equal
, "Got unexpected length %.8e.\n", got
);
1608 /*_______________D3DXVec4LengthSq________________________*/
1609 got
= D3DXVec4LengthSq(&u
);
1610 equal
= compare_float(got
, 121.0f
, 0);
1611 ok(equal
, "Got unexpected length %.8e.\n", got
);
1612 /* Tests the case NULL. */
1613 got
= D3DXVec4LengthSq(NULL
);
1614 equal
= compare_float(got
, 0.0f
, 0);
1615 ok(equal
, "Got unexpected length %.8e.\n", got
);
1617 /*_______________D3DXVec4Lerp__________________________*/
1618 expectedvec
.x
= 27.0f
; expectedvec
.y
= -11.0f
; expectedvec
.z
= 62.5; expectedvec
.w
= 29.5;
1619 D3DXVec4Lerp(&gotvec
,&u
,&v
,scale
);
1620 expect_vec4(&expectedvec
, &gotvec
, 0);
1621 /* Tests the case NULL */
1622 funcpointer
= D3DXVec4Lerp(&gotvec
,NULL
,&v
,scale
);
1623 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1624 funcpointer
= D3DXVec4Lerp(NULL
,NULL
,NULL
,scale
);
1625 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1627 /*_______________D3DXVec4Maximize__________________________*/
1628 expectedvec
.x
= 1.0f
; expectedvec
.y
= 4.0f
; expectedvec
.z
= 4.0f
; expectedvec
.w
= 10.0;
1629 D3DXVec4Maximize(&gotvec
,&u
,&v
);
1630 expect_vec4(&expectedvec
, &gotvec
, 0);
1631 /* Tests the case NULL */
1632 funcpointer
= D3DXVec4Maximize(&gotvec
,NULL
,&v
);
1633 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1634 funcpointer
= D3DXVec4Maximize(NULL
,NULL
,NULL
);
1635 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1637 /*_______________D3DXVec4Minimize__________________________*/
1638 expectedvec
.x
= -3.0f
; expectedvec
.y
= 2.0f
; expectedvec
.z
= -5.0f
; expectedvec
.w
= 7.0;
1639 D3DXVec4Minimize(&gotvec
,&u
,&v
);
1640 expect_vec4(&expectedvec
, &gotvec
, 0);
1641 /* Tests the case NULL */
1642 funcpointer
= D3DXVec4Minimize(&gotvec
,NULL
,&v
);
1643 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1644 funcpointer
= D3DXVec4Minimize(NULL
,NULL
,NULL
);
1645 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1647 /*_______________D3DXVec4Normalize_________________________*/
1648 expectedvec
.x
= 1.0f
/11.0f
; expectedvec
.y
= 2.0f
/11.0f
; expectedvec
.z
= 4.0f
/11.0f
; expectedvec
.w
= 10.0f
/11.0f
;
1649 D3DXVec4Normalize(&gotvec
,&u
);
1650 expect_vec4(&expectedvec
, &gotvec
, 1);
1652 /*_______________D3DXVec4Scale____________________________*/
1653 expectedvec
.x
= -6.5f
; expectedvec
.y
= -13.0f
; expectedvec
.z
= -26.0f
; expectedvec
.w
= -65.0f
;
1654 D3DXVec4Scale(&gotvec
,&u
,scale
);
1655 expect_vec4(&expectedvec
, &gotvec
, 0);
1656 /* Tests the case NULL */
1657 funcpointer
= D3DXVec4Scale(&gotvec
,NULL
,scale
);
1658 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1659 funcpointer
= D3DXVec4Scale(NULL
,NULL
,scale
);
1660 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1662 /*_______________D3DXVec4Subtract__________________________*/
1663 expectedvec
.x
= 4.0f
; expectedvec
.y
= -2.0f
; expectedvec
.z
= 9.0f
; expectedvec
.w
= 3.0f
;
1664 D3DXVec4Subtract(&gotvec
,&u
,&v
);
1665 expect_vec4(&expectedvec
, &gotvec
, 0);
1666 /* Tests the case NULL */
1667 funcpointer
= D3DXVec4Subtract(&gotvec
,NULL
,&v
);
1668 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1669 funcpointer
= D3DXVec4Subtract(NULL
,NULL
,NULL
);
1670 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1672 /*_______________D3DXVec4Transform_______________________*/
1673 expectedtrans
.x
= 177.0f
; expectedtrans
.y
= 194.0f
; expectedtrans
.z
= 211.0f
; expectedtrans
.w
= 228.0f
;
1674 D3DXVec4Transform(&gottrans
,&u
,&mat
);
1675 expect_vec4(&expectedtrans
, &gottrans
, 0);
1678 static void test_matrix_stack(void)
1680 ID3DXMatrixStack
*stack
;
1684 const D3DXMATRIX mat1
= {{{
1685 1.0f
, 2.0f
, 3.0f
, 4.0f
,
1686 5.0f
, 6.0f
, 7.0f
, 8.0f
,
1687 9.0f
, 10.0f
, 11.0f
, 12.0f
,
1688 13.0f
, 14.0f
, 15.0f
, 16.0f
1691 const D3DXMATRIX mat2
= {{{
1692 17.0f
, 18.0f
, 19.0f
, 20.0f
,
1693 21.0f
, 22.0f
, 23.0f
, 24.0f
,
1694 25.0f
, 26.0f
, 27.0f
, 28.0f
,
1695 29.0f
, 30.0f
, 31.0f
, 32.0f
1698 hr
= D3DXCreateMatrixStack(0, &stack
);
1699 ok(SUCCEEDED(hr
), "Failed to create a matrix stack, hr %#x\n", hr
);
1700 if (FAILED(hr
)) return;
1702 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)),
1703 "The top of an empty matrix stack should be an identity matrix\n");
1705 hr
= ID3DXMatrixStack_Pop(stack
);
1706 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
1708 hr
= ID3DXMatrixStack_Push(stack
);
1709 ok(SUCCEEDED(hr
), "Push failed, hr %#x\n", hr
);
1710 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)), "The top should be an identity matrix\n");
1712 hr
= ID3DXMatrixStack_Push(stack
);
1713 ok(SUCCEEDED(hr
), "Push failed, hr %#x\n", hr
);
1715 hr
= ID3DXMatrixStack_LoadMatrix(stack
, &mat1
);
1716 ok(SUCCEEDED(hr
), "LoadMatrix failed, hr %#x\n", hr
);
1717 expect_matrix(&mat1
, ID3DXMatrixStack_GetTop(stack
), 0);
1719 hr
= ID3DXMatrixStack_Push(stack
);
1720 ok(SUCCEEDED(hr
), "Push failed, hr %#x\n", hr
);
1721 expect_matrix(&mat1
, ID3DXMatrixStack_GetTop(stack
), 0);
1723 hr
= ID3DXMatrixStack_LoadMatrix(stack
, &mat2
);
1724 ok(SUCCEEDED(hr
), "LoadMatrix failed, hr %#x\n", hr
);
1725 expect_matrix(&mat2
, ID3DXMatrixStack_GetTop(stack
), 0);
1727 hr
= ID3DXMatrixStack_Push(stack
);
1728 ok(SUCCEEDED(hr
), "Push failed, hr %#x\n", hr
);
1729 expect_matrix(&mat2
, ID3DXMatrixStack_GetTop(stack
), 0);
1731 hr
= ID3DXMatrixStack_LoadIdentity(stack
);
1732 ok(SUCCEEDED(hr
), "LoadIdentity failed, hr %#x\n", hr
);
1733 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)), "The top should be an identity matrix\n");
1735 hr
= ID3DXMatrixStack_Pop(stack
);
1736 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
1737 expect_matrix(&mat2
, ID3DXMatrixStack_GetTop(stack
), 0);
1739 hr
= ID3DXMatrixStack_Pop(stack
);
1740 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
1741 expect_matrix(&mat1
, ID3DXMatrixStack_GetTop(stack
), 0);
1743 hr
= ID3DXMatrixStack_Pop(stack
);
1744 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
1745 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)), "The top should be an identity matrix\n");
1747 hr
= ID3DXMatrixStack_Pop(stack
);
1748 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
1749 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)), "The top should be an identity matrix\n");
1751 refcount
= ID3DXMatrixStack_Release(stack
);
1752 ok(!refcount
, "Matrix stack has %u references left.\n", refcount
);
1755 static void test_Matrix_AffineTransformation2D(void)
1757 D3DXMATRIX exp_mat
, got_mat
;
1758 D3DXVECTOR2 center
, position
;
1767 angle
= D3DX_PI
/3.0f
;
1771 U(exp_mat
).m
[0][0] = 10.0f
;
1772 U(exp_mat
).m
[1][0] = -17.320507f
;
1773 U(exp_mat
).m
[2][0] = 0.0f
;
1774 U(exp_mat
).m
[3][0] = -1.035898f
;
1775 U(exp_mat
).m
[0][1] = 17.320507f
;
1776 U(exp_mat
).m
[1][1] = 10.0f
;
1777 U(exp_mat
).m
[2][1] = 0.0f
;
1778 U(exp_mat
).m
[3][1] = 6.401924f
;
1779 U(exp_mat
).m
[0][2] = 0.0f
;
1780 U(exp_mat
).m
[1][2] = 0.0f
;
1781 U(exp_mat
).m
[2][2] = 1.0f
;
1782 U(exp_mat
).m
[3][2] = 0.0f
;
1783 U(exp_mat
).m
[0][3] = 0.0f
;
1784 U(exp_mat
).m
[1][3] = 0.0f
;
1785 U(exp_mat
).m
[2][3] = 0.0f
;
1786 U(exp_mat
).m
[3][3] = 1.0f
;
1788 D3DXMatrixAffineTransformation2D(&got_mat
, scale
, ¢er
, angle
, &position
);
1789 expect_matrix(&exp_mat
, &got_mat
, 2);
1796 angle
= D3DX_PI
/3.0f
;
1800 U(exp_mat
).m
[0][0] = 10.0f
;
1801 U(exp_mat
).m
[1][0] = -17.320507f
;
1802 U(exp_mat
).m
[2][0] = 0.0f
;
1803 U(exp_mat
).m
[3][0] = 4.964102f
;
1804 U(exp_mat
).m
[0][1] = 17.320507f
;
1805 U(exp_mat
).m
[1][1] = 10.0f
;
1806 U(exp_mat
).m
[2][1] = 0.0f
;
1807 U(exp_mat
).m
[3][1] = -0.598076f
;
1808 U(exp_mat
).m
[0][2] = 0.0f
;
1809 U(exp_mat
).m
[1][2] = 0.0f
;
1810 U(exp_mat
).m
[2][2] = 1.0f
;
1811 U(exp_mat
).m
[3][2] = 0.0f
;
1812 U(exp_mat
).m
[0][3] = 0.0f
;
1813 U(exp_mat
).m
[1][3] = 0.0f
;
1814 U(exp_mat
).m
[2][3] = 0.0f
;
1815 U(exp_mat
).m
[3][3] = 1.0f
;
1817 D3DXMatrixAffineTransformation2D(&got_mat
, scale
, ¢er
, angle
, NULL
);
1818 expect_matrix(&exp_mat
, &got_mat
, 8);
1825 angle
= D3DX_PI
/3.0f
;
1829 U(exp_mat
).m
[0][0] = 10.0f
;
1830 U(exp_mat
).m
[1][0] = -17.320507f
;
1831 U(exp_mat
).m
[2][0] = 0.0f
;
1832 U(exp_mat
).m
[3][0] = -6.0f
;
1833 U(exp_mat
).m
[0][1] = 17.320507f
;
1834 U(exp_mat
).m
[1][1] = 10.0f
;
1835 U(exp_mat
).m
[2][1] = 0.0f
;
1836 U(exp_mat
).m
[3][1] = 7.0f
;
1837 U(exp_mat
).m
[0][2] = 0.0f
;
1838 U(exp_mat
).m
[1][2] = 0.0f
;
1839 U(exp_mat
).m
[2][2] = 1.0f
;
1840 U(exp_mat
).m
[3][2] = 0.0f
;
1841 U(exp_mat
).m
[0][3] = 0.0f
;
1842 U(exp_mat
).m
[1][3] = 0.0f
;
1843 U(exp_mat
).m
[2][3] = 0.0f
;
1844 U(exp_mat
).m
[3][3] = 1.0f
;
1846 D3DXMatrixAffineTransformation2D(&got_mat
, scale
, NULL
, angle
, &position
);
1847 expect_matrix(&exp_mat
, &got_mat
, 1);
1851 angle
= 5.0f
* D3DX_PI
/4.0f
;
1855 U(exp_mat
).m
[0][0] = 14.142133f
;
1856 U(exp_mat
).m
[1][0] = -14.142133f
;
1857 U(exp_mat
).m
[2][0] = 0.0f
;
1858 U(exp_mat
).m
[3][0] = 0.0f
;
1859 U(exp_mat
).m
[0][1] = 14.142133;
1860 U(exp_mat
).m
[1][1] = 14.142133f
;
1861 U(exp_mat
).m
[2][1] = 0.0f
;
1862 U(exp_mat
).m
[3][1] = 0.0f
;
1863 U(exp_mat
).m
[0][2] = 0.0f
;
1864 U(exp_mat
).m
[1][2] = 0.0f
;
1865 U(exp_mat
).m
[2][2] = 1.0f
;
1866 U(exp_mat
).m
[3][2] = 0.0f
;
1867 U(exp_mat
).m
[0][3] = 0.0f
;
1868 U(exp_mat
).m
[1][3] = 0.0f
;
1869 U(exp_mat
).m
[2][3] = 0.0f
;
1870 U(exp_mat
).m
[3][3] = 1.0f
;
1872 D3DXMatrixAffineTransformation2D(&got_mat
, scale
, NULL
, angle
, NULL
);
1873 expect_matrix(&exp_mat
, &got_mat
, 8);
1876 static void test_Matrix_Decompose(void)
1879 D3DXQUATERNION exp_rotation
, got_rotation
;
1880 D3DXVECTOR3 exp_scale
, got_scale
, exp_translation
, got_translation
;
1886 U(pm
).m
[0][0] = -9.23879206e-01f
;
1887 U(pm
).m
[1][0] = -2.70598412e-01f
;
1888 U(pm
).m
[2][0] = 2.70598441e-01f
;
1889 U(pm
).m
[3][0] = -5.00000000e+00f
;
1890 U(pm
).m
[0][1] = 2.70598471e-01f
;
1891 U(pm
).m
[1][1] = 3.80604863e-02f
;
1892 U(pm
).m
[2][1] = 9.61939573e-01f
;
1893 U(pm
).m
[3][1] = 0.00000000e+00f
;
1894 U(pm
).m
[0][2] = -2.70598441e-01f
;
1895 U(pm
).m
[1][2] = 9.61939573e-01f
;
1896 U(pm
).m
[2][2] = 3.80603075e-02f
;
1897 U(pm
).m
[3][2] = 1.00000000e+01f
;
1898 U(pm
).m
[0][3] = 0.00000000e+00f
;
1899 U(pm
).m
[1][3] = 0.00000000e+00f
;
1900 U(pm
).m
[2][3] = 0.00000000e+00f
;
1901 U(pm
).m
[3][3] = 1.00000000e+00f
;
1903 exp_scale
.x
= 9.99999881e-01f
;
1904 exp_scale
.y
= 9.99999881e-01f
;
1905 exp_scale
.z
= 9.99999881e-01f
;
1907 exp_rotation
.x
= 2.14862776e-08f
;
1908 exp_rotation
.y
= 6.93519890e-01f
;
1909 exp_rotation
.z
= 6.93519890e-01f
;
1910 exp_rotation
.w
= 1.95090637e-01f
;
1912 exp_translation
.x
= -5.0f
;
1913 exp_translation
.y
= 0.0f
;
1914 exp_translation
.z
= 10.0f
;
1916 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
1917 expect_vec3(&exp_scale
, &got_scale
, 1);
1918 expect_quaternion(&exp_rotation
, &got_rotation
, 1);
1919 expect_vec3(&exp_translation
, &got_translation
, 0);
1923 U(pm
).m
[0][0] = -2.255813f
;
1924 U(pm
).m
[1][0] = 1.302324f
;
1925 U(pm
).m
[2][0] = 1.488373f
;
1926 U(pm
).m
[3][0] = 1.0f
;
1927 U(pm
).m
[0][1] = 1.302327f
;
1928 U(pm
).m
[1][1] = -0.7209296f
;
1929 U(pm
).m
[2][1] = 2.60465f
;
1930 U(pm
).m
[3][1] = 2.0f
;
1931 U(pm
).m
[0][2] = 1.488371f
;
1932 U(pm
).m
[1][2] = 2.604651f
;
1933 U(pm
).m
[2][2] = -0.02325551f
;
1934 U(pm
).m
[3][2] = 3.0f
;
1935 U(pm
).m
[0][3] = 0.0f
;
1936 U(pm
).m
[1][3] = 0.0f
;
1937 U(pm
).m
[2][3] = 0.0f
;
1938 U(pm
).m
[3][3] = 1.0f
;
1940 exp_scale
.x
= 2.99999928e+00f
;
1941 exp_scale
.y
= 2.99999905e+00f
;
1942 exp_scale
.z
= 2.99999952e+00f
;
1944 exp_rotation
.x
= 3.52180451e-01f
;
1945 exp_rotation
.y
= 6.16315663e-01f
;
1946 exp_rotation
.z
= 7.04360664e-01f
;
1947 exp_rotation
.w
= 3.38489343e-07f
;
1949 exp_translation
.x
= 1.0f
;
1950 exp_translation
.y
= 2.0f
;
1951 exp_translation
.z
= 3.0f
;
1953 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
1954 expect_vec3(&exp_scale
, &got_scale
, 0);
1955 expect_quaternion(&exp_rotation
, &got_rotation
, 2);
1956 expect_vec3(&exp_translation
, &got_translation
, 0);
1960 U(pm
).m
[0][0] = 2.427051f
;
1961 U(pm
).m
[1][0] = 0.0f
;
1962 U(pm
).m
[2][0] = 1.763355f
;
1963 U(pm
).m
[3][0] = 5.0f
;
1964 U(pm
).m
[0][1] = 0.0f
;
1965 U(pm
).m
[1][1] = 3.0f
;
1966 U(pm
).m
[2][1] = 0.0f
;
1967 U(pm
).m
[3][1] = 5.0f
;
1968 U(pm
).m
[0][2] = -1.763355f
;
1969 U(pm
).m
[1][2] = 0.0f
;
1970 U(pm
).m
[2][2] = 2.427051f
;
1971 U(pm
).m
[3][2] = 5.0f
;
1972 U(pm
).m
[0][3] = 0.0f
;
1973 U(pm
).m
[1][3] = 0.0f
;
1974 U(pm
).m
[2][3] = 0.0f
;
1975 U(pm
).m
[3][3] = 1.0f
;
1977 exp_scale
.x
= 2.99999976e+00f
;
1978 exp_scale
.y
= 3.00000000e+00f
;
1979 exp_scale
.z
= 2.99999976e+00f
;
1981 exp_rotation
.x
= 0.00000000e+00f
;
1982 exp_rotation
.y
= 3.09016883e-01f
;
1983 exp_rotation
.z
= 0.00000000e+00f
;
1984 exp_rotation
.w
= 9.51056540e-01f
;
1986 exp_translation
.x
= 5.0f
;
1987 exp_translation
.y
= 5.0f
;
1988 exp_translation
.z
= 5.0f
;
1990 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
1991 expect_vec3(&exp_scale
, &got_scale
, 1);
1992 expect_quaternion(&exp_rotation
, &got_rotation
, 1);
1993 expect_vec3(&exp_translation
, &got_translation
, 0);
1997 U(pm
).m
[0][0] = -9.23879206e-01f
;
1998 U(pm
).m
[1][0] = -2.70598412e-01f
;
1999 U(pm
).m
[2][0] = 2.70598441e-01f
;
2000 U(pm
).m
[3][0] = -5.00000000e+00f
;
2001 U(pm
).m
[0][1] = 2.70598471e-01f
;
2002 U(pm
).m
[1][1] = 3.80604863e-02f
;
2003 U(pm
).m
[2][1] = 9.61939573e-01f
;
2004 U(pm
).m
[3][1] = 0.00000000e+00f
;
2005 U(pm
).m
[0][2] = -2.70598441e-01f
;
2006 U(pm
).m
[1][2] = 9.61939573e-01f
;
2007 U(pm
).m
[2][2] = 3.80603075e-02f
;
2008 U(pm
).m
[3][2] = 1.00000000e+01f
;
2009 U(pm
).m
[0][3] = 0.00000000e+00f
;
2010 U(pm
).m
[1][3] = 0.00000000e+00f
;
2011 U(pm
).m
[2][3] = 0.00000000e+00f
;
2012 U(pm
).m
[3][3] = 1.00000000e+00f
;
2014 exp_scale
.x
= 9.99999881e-01f
;
2015 exp_scale
.y
= 9.99999881e-01f
;
2016 exp_scale
.z
= 9.99999881e-01f
;
2018 exp_rotation
.x
= 2.14862776e-08f
;
2019 exp_rotation
.y
= 6.93519890e-01f
;
2020 exp_rotation
.z
= 6.93519890e-01f
;
2021 exp_rotation
.w
= 1.95090637e-01f
;
2023 exp_translation
.x
= -5.0f
;
2024 exp_translation
.y
= 0.0f
;
2025 exp_translation
.z
= 10.0f
;
2027 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2028 expect_vec3(&exp_scale
, &got_scale
, 1);
2029 expect_quaternion(&exp_rotation
, &got_rotation
, 1);
2030 expect_vec3(&exp_translation
, &got_translation
, 0);
2034 U(pm
).m
[0][0] = -9.23878908e-01f
;
2035 U(pm
).m
[1][0] = -5.41196704e-01f
;
2036 U(pm
).m
[2][0] = 8.11795175e-01f
;
2037 U(pm
).m
[3][0] = -5.00000000e+00f
;
2038 U(pm
).m
[0][1] = 2.70598322e-01f
;
2039 U(pm
).m
[1][1] = 7.61209577e-02f
;
2040 U(pm
).m
[2][1] = 2.88581824e+00f
;
2041 U(pm
).m
[3][1] = 0.00000000e+00f
;
2042 U(pm
).m
[0][2] = -2.70598352e-01f
;
2043 U(pm
).m
[1][2] = 1.92387879e+00f
;
2044 U(pm
).m
[2][2] = 1.14180908e-01f
;
2045 U(pm
).m
[3][2] = 1.00000000e+01f
;
2046 U(pm
).m
[0][3] = 0.00000000e+00f
;
2047 U(pm
).m
[1][3] = 0.00000000e+00f
;
2048 U(pm
).m
[2][3] = 0.00000000e+00f
;
2049 U(pm
).m
[3][3] = 1.00000000e+00f
;
2051 exp_scale
.x
= 9.99999583e-01f
;
2052 exp_scale
.y
= 1.99999940e+00f
;
2053 exp_scale
.z
= 2.99999928e+00f
;
2055 exp_rotation
.x
= 1.07431388e-08f
;
2056 exp_rotation
.y
= 6.93519890e-01f
;
2057 exp_rotation
.z
= 6.93519831e-01f
;
2058 exp_rotation
.w
= 1.95090622e-01f
;
2060 exp_translation
.x
= -5.0f
;
2061 exp_translation
.y
= 0.0f
;
2062 exp_translation
.z
= 10.0f
;
2064 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2065 expect_vec3(&exp_scale
, &got_scale
, 1);
2066 equal
= compare_quaternion(&exp_rotation
, &got_rotation
, 1);
2067 exp_rotation
.x
= 0.0f
;
2068 equal
|= compare_quaternion(&exp_rotation
, &got_rotation
, 2);
2069 ok(equal
, "Got unexpected quaternion {%.8e, %.8e, %.8e, %.8e}.\n",
2070 got_rotation
.x
, got_rotation
.y
, got_rotation
.z
, got_rotation
.w
);
2071 expect_vec3(&exp_translation
, &got_translation
, 0);
2075 U(pm
).m
[0][0] = 0.7156004f
;
2076 U(pm
).m
[1][0] = -0.5098283f
;
2077 U(pm
).m
[2][0] = -0.4774843f
;
2078 U(pm
).m
[3][0] = -5.0f
;
2079 U(pm
).m
[0][1] = -0.6612288f
;
2080 U(pm
).m
[1][1] = -0.7147621f
;
2081 U(pm
).m
[2][1] = -0.2277977f
;
2082 U(pm
).m
[3][1] = 0.0f
;
2083 U(pm
).m
[0][2] = -0.2251499f
;
2084 U(pm
).m
[1][2] = 0.4787385f
;
2085 U(pm
).m
[2][2] = -0.8485972f
;
2086 U(pm
).m
[3][2] = 10.0f
;
2087 U(pm
).m
[0][3] = 0.0f
;
2088 U(pm
).m
[1][3] = 0.0f
;
2089 U(pm
).m
[2][3] = 0.0f
;
2090 U(pm
).m
[3][3] = 1.0f
;
2092 exp_scale
.x
= 9.99999940e-01f
;
2093 exp_scale
.y
= 1.00000012e+00f
;
2094 exp_scale
.z
= 1.00000012e+00f
;
2096 exp_rotation
.x
= 9.05394852e-01f
;
2097 exp_rotation
.y
= -3.23355347e-01f
;
2098 exp_rotation
.z
= -1.94013178e-01f
;
2099 exp_rotation
.w
= 1.95090592e-01f
;
2101 exp_translation
.x
= -5.0f
;
2102 exp_translation
.y
= 0.0f
;
2103 exp_translation
.z
= 10.0f
;
2105 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2106 expect_vec3(&exp_scale
, &got_scale
, 0);
2107 expect_quaternion(&exp_rotation
, &got_rotation
, 1);
2108 expect_vec3(&exp_translation
, &got_translation
, 0);
2112 U(pm
).m
[0][0] = 0.06554436f
;
2113 U(pm
).m
[1][0] = -0.6873012f
;
2114 U(pm
).m
[2][0] = 0.7234092f
;
2115 U(pm
).m
[3][0] = -5.0f
;
2116 U(pm
).m
[0][1] = -0.9617381f
;
2117 U(pm
).m
[1][1] = -0.2367795f
;
2118 U(pm
).m
[2][1] = -0.1378230f
;
2119 U(pm
).m
[3][1] = 0.0f
;
2120 U(pm
).m
[0][2] = 0.2660144f
;
2121 U(pm
).m
[1][2] = -0.6866967f
;
2122 U(pm
).m
[2][2] = -0.6765233f
;
2123 U(pm
).m
[3][2] = 10.0f
;
2124 U(pm
).m
[0][3] = 0.0f
;
2125 U(pm
).m
[1][3] = 0.0f
;
2126 U(pm
).m
[2][3] = 0.0f
;
2127 U(pm
).m
[3][3] = 1.0f
;
2129 exp_scale
.x
= 9.99999940e-01f
;
2130 exp_scale
.y
= 9.99999940e-01f
;
2131 exp_scale
.z
= 9.99999881e-01f
;
2133 exp_rotation
.x
= 7.03357518e-01f
;
2134 exp_rotation
.y
= -5.86131275e-01f
;
2135 exp_rotation
.z
= 3.51678789e-01f
;
2136 exp_rotation
.w
= -1.95090577e-01f
;
2138 exp_translation
.x
= -5.0f
;
2139 exp_translation
.y
= 0.0f
;
2140 exp_translation
.z
= 10.0f
;
2142 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2143 expect_vec3(&exp_scale
, &got_scale
, 1);
2144 expect_quaternion(&exp_rotation
, &got_rotation
, 2);
2145 expect_vec3(&exp_translation
, &got_translation
, 0);
2149 U(pm
).m
[0][0] = 7.12104797e+00f
;
2150 U(pm
).m
[1][0] = -5.88348627e+00f
;
2151 U(pm
).m
[2][0] = 1.18184204e+01f
;
2152 U(pm
).m
[3][0] = -5.00000000e+00f
;
2153 U(pm
).m
[0][1] = 5.88348627e+00f
;
2154 U(pm
).m
[1][1] = -1.06065865e+01f
;
2155 U(pm
).m
[2][1] = -8.82523251e+00f
;
2156 U(pm
).m
[3][1] = 0.00000000e+00f
;
2157 U(pm
).m
[0][2] = 1.18184204e+01f
;
2158 U(pm
).m
[1][2] = 8.82523155e+00f
;
2159 U(pm
).m
[2][2] = -2.72764111e+00f
;
2160 U(pm
).m
[3][2] = 2.00000000e+00f
;
2161 U(pm
).m
[0][3] = 0.00000000e+00f
;
2162 U(pm
).m
[1][3] = 0.00000000e+00f
;
2163 U(pm
).m
[2][3] = 0.00000000e+00f
;
2164 U(pm
).m
[3][3] = 1.00000000e+00f
;
2166 exp_scale
.x
= 1.49999933e+01f
;
2167 exp_scale
.y
= 1.49999933e+01f
;
2168 exp_scale
.z
= 1.49999943e+01f
;
2170 exp_rotation
.x
= 7.68714130e-01f
;
2171 exp_rotation
.y
= 0.00000000e+00f
;
2172 exp_rotation
.z
= 5.12475967e-01f
;
2173 exp_rotation
.w
= 3.82683903e-01f
;
2175 exp_translation
.x
= -5.0f
;
2176 exp_translation
.y
= 0.0f
;
2177 exp_translation
.z
= 2.0f
;
2179 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2180 expect_vec3(&exp_scale
, &got_scale
, 0);
2181 expect_quaternion(&exp_rotation
, &got_rotation
, 1);
2182 expect_vec3(&exp_translation
, &got_translation
, 0);
2186 U(pm
).m
[0][0] = 0.0f
;
2187 U(pm
).m
[1][0] = 4.0f
;
2188 U(pm
).m
[2][0] = 5.0f
;
2189 U(pm
).m
[3][0] = -5.0f
;
2190 U(pm
).m
[0][1] = 0.0f
;
2191 U(pm
).m
[1][1] = -10.60660f
;
2192 U(pm
).m
[2][1] = -8.825232f
;
2193 U(pm
).m
[3][1] = 6.0f
;
2194 U(pm
).m
[0][2] = 0.0f
;
2195 U(pm
).m
[1][2] = 8.8252320f
;
2196 U(pm
).m
[2][2] = 2.727645;
2197 U(pm
).m
[3][2] = 3.0f
;
2198 U(pm
).m
[0][3] = 0.0f
;
2199 U(pm
).m
[1][3] = 0.0f
;
2200 U(pm
).m
[2][3] = 0.0f
;
2201 U(pm
).m
[3][3] = 1.0f
;
2203 hr
= D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2204 ok(hr
== D3DERR_INVALIDCALL
, "Expected D3DERR_INVALIDCALL, got %x\n", hr
);
2207 static void test_Matrix_Transformation2D(void)
2209 D3DXMATRIX exp_mat
, got_mat
;
2210 D3DXVECTOR2 rot_center
, sca
, sca_center
, trans
;
2213 rot_center
.x
= 3.0f
;
2214 rot_center
.y
= 4.0f
;
2219 sca_center
.x
= 9.0f
;
2220 sca_center
.y
= -5.0f
;
2227 sca_rot
= 5.0f
*D3DX_PI
/4.0f
;
2229 U(exp_mat
).m
[0][0] = -4.245192f
;
2230 U(exp_mat
).m
[1][0] = -0.147116f
;
2231 U(exp_mat
).m
[2][0] = 0.0f
;
2232 U(exp_mat
).m
[3][0] = 45.265373f
;
2233 U(exp_mat
).m
[0][1] = 7.647113f
;
2234 U(exp_mat
).m
[1][1] = 8.745192f
;
2235 U(exp_mat
).m
[2][1] = 0.0f
;
2236 U(exp_mat
).m
[3][1] = -13.401899f
;
2237 U(exp_mat
).m
[0][2] = 0.0f
;
2238 U(exp_mat
).m
[1][2] = 0.0f
;
2239 U(exp_mat
).m
[2][2] = 1.0f
;
2240 U(exp_mat
).m
[3][2] = 0.0f
;
2241 U(exp_mat
).m
[0][3] = 0.0f
;
2242 U(exp_mat
).m
[1][3] = 0.0f
;
2243 U(exp_mat
).m
[2][3] = 0.0f
;
2244 U(exp_mat
).m
[3][3] = 1.0f
;
2246 D3DXMatrixTransformation2D(&got_mat
, &sca_center
, sca_rot
, &sca
, &rot_center
, rot
, &trans
);
2247 expect_matrix(&exp_mat
, &got_mat
, 64);
2251 sca_center
.x
= 9.0f
;
2252 sca_center
.y
= -5.0f
;
2259 sca_rot
= 5.0f
*D3DX_PI
/4.0f
;
2261 U(exp_mat
).m
[0][0] = 0.50f
;
2262 U(exp_mat
).m
[1][0] = -0.866025f
;
2263 U(exp_mat
).m
[2][0] = 0.0f
;
2264 U(exp_mat
).m
[3][0] = -6.0f
;
2265 U(exp_mat
).m
[0][1] = 0.866025f
;
2266 U(exp_mat
).m
[1][1] = 0.50f
;
2267 U(exp_mat
).m
[2][1] = 0.0f
;
2268 U(exp_mat
).m
[3][1] = 7.0f
;
2269 U(exp_mat
).m
[0][2] = 0.0f
;
2270 U(exp_mat
).m
[1][2] = 0.0f
;
2271 U(exp_mat
).m
[2][2] = 1.0f
;
2272 U(exp_mat
).m
[3][2] = 0.0f
;
2273 U(exp_mat
).m
[0][3] = 0.0f
;
2274 U(exp_mat
).m
[1][3] = 0.0f
;
2275 U(exp_mat
).m
[2][3] = 0.0f
;
2276 U(exp_mat
).m
[3][3] = 1.0f
;
2278 D3DXMatrixTransformation2D(&got_mat
, &sca_center
, sca_rot
, NULL
, NULL
, rot
, &trans
);
2279 expect_matrix(&exp_mat
, &got_mat
, 8);
2283 U(exp_mat
).m
[0][0] = 0.50f
;
2284 U(exp_mat
).m
[1][0] = -0.866025f
;
2285 U(exp_mat
).m
[2][0] = 0.0f
;
2286 U(exp_mat
).m
[3][0] = 0.0f
;
2287 U(exp_mat
).m
[0][1] = 0.866025f
;
2288 U(exp_mat
).m
[1][1] = 0.50f
;
2289 U(exp_mat
).m
[2][1] = 0.0f
;
2290 U(exp_mat
).m
[3][1] = 0.0f
;
2291 U(exp_mat
).m
[0][2] = 0.0f
;
2292 U(exp_mat
).m
[1][2] = 0.0f
;
2293 U(exp_mat
).m
[2][2] = 1.0f
;
2294 U(exp_mat
).m
[3][2] = 0.0f
;
2295 U(exp_mat
).m
[0][3] = 0.0f
;
2296 U(exp_mat
).m
[1][3] = 0.0f
;
2297 U(exp_mat
).m
[2][3] = 0.0f
;
2298 U(exp_mat
).m
[3][3] = 1.0f
;
2300 D3DXMatrixTransformation2D(&got_mat
, NULL
, sca_rot
, NULL
, NULL
, rot
, NULL
);
2301 expect_matrix(&exp_mat
, &got_mat
, 8);
2304 static void test_D3DXVec_Array(void)
2307 D3DVIEWPORT9 viewport
;
2308 D3DXMATRIX mat
, projection
, view
, world
;
2309 D3DXVECTOR4 inp_vec
[ARRAY_SIZE
];
2310 D3DXVECTOR4 out_vec
[ARRAY_SIZE
+ 2];
2311 D3DXVECTOR4 exp_vec
[ARRAY_SIZE
+ 2];
2312 D3DXPLANE inp_plane
[ARRAY_SIZE
];
2313 D3DXPLANE out_plane
[ARRAY_SIZE
+ 2];
2314 D3DXPLANE exp_plane
[ARRAY_SIZE
+ 2];
2316 viewport
.Width
= 800; viewport
.MinZ
= 0.2f
; viewport
.X
= 10;
2317 viewport
.Height
= 680; viewport
.MaxZ
= 0.9f
; viewport
.Y
= 5;
2319 for (i
= 0; i
< ARRAY_SIZE
+ 2; ++i
) {
2320 out_vec
[i
].x
= out_vec
[i
].y
= out_vec
[i
].z
= out_vec
[i
].w
= 0.0f
;
2321 exp_vec
[i
].x
= exp_vec
[i
].y
= exp_vec
[i
].z
= exp_vec
[i
].w
= 0.0f
;
2322 out_plane
[i
].a
= out_plane
[i
].b
= out_plane
[i
].c
= out_plane
[i
].d
= 0.0f
;
2323 exp_plane
[i
].a
= exp_plane
[i
].b
= exp_plane
[i
].c
= exp_plane
[i
].d
= 0.0f
;
2326 for (i
= 0; i
< ARRAY_SIZE
; ++i
) {
2327 inp_plane
[i
].a
= inp_plane
[i
].c
= inp_vec
[i
].x
= inp_vec
[i
].z
= i
;
2328 inp_plane
[i
].b
= inp_plane
[i
].d
= inp_vec
[i
].y
= inp_vec
[i
].w
= ARRAY_SIZE
- i
;
2331 U(mat
).m
[0][0] = 1.0f
; U(mat
).m
[0][1] = 2.0f
; U(mat
).m
[0][2] = 3.0f
; U(mat
).m
[0][3] = 4.0f
;
2332 U(mat
).m
[1][0] = 5.0f
; U(mat
).m
[1][1] = 6.0f
; U(mat
).m
[1][2] = 7.0f
; U(mat
).m
[1][3] = 8.0f
;
2333 U(mat
).m
[2][0] = 9.0f
; U(mat
).m
[2][1] = 10.0f
; U(mat
).m
[2][2] = 11.0f
; U(mat
).m
[2][3] = 12.0f
;
2334 U(mat
).m
[3][0] = 13.0f
; U(mat
).m
[3][1] = 14.0f
; U(mat
).m
[3][2] = 15.0f
; U(mat
).m
[3][3] = 16.0f
;
2336 D3DXMatrixPerspectiveFovLH(&projection
,D3DX_PI
/4.0f
,20.0f
/17.0f
,1.0f
,1000.0f
);
2338 U(view
).m
[0][1] = 5.0f
; U(view
).m
[0][2] = 7.0f
; U(view
).m
[0][3] = 8.0f
;
2339 U(view
).m
[1][0] = 11.0f
; U(view
).m
[1][2] = 16.0f
; U(view
).m
[1][3] = 33.0f
;
2340 U(view
).m
[2][0] = 19.0f
; U(view
).m
[2][1] = -21.0f
; U(view
).m
[2][3] = 43.0f
;
2341 U(view
).m
[3][0] = 2.0f
; U(view
).m
[3][1] = 3.0f
; U(view
).m
[3][2] = -4.0f
;
2342 U(view
).m
[0][0] = 10.0f
; U(view
).m
[1][1] = 20.0f
; U(view
).m
[2][2] = 30.0f
;
2343 U(view
).m
[3][3] = -40.0f
;
2345 U(world
).m
[0][0] = 21.0f
; U(world
).m
[0][1] = 2.0f
; U(world
).m
[0][2] = 3.0f
; U(world
).m
[0][3] = 4.0;
2346 U(world
).m
[1][0] = 5.0f
; U(world
).m
[1][1] = 23.0f
; U(world
).m
[1][2] = 7.0f
; U(world
).m
[1][3] = 8.0f
;
2347 U(world
).m
[2][0] = -8.0f
; U(world
).m
[2][1] = -7.0f
; U(world
).m
[2][2] = 25.0f
; U(world
).m
[2][3] = -5.0f
;
2348 U(world
).m
[3][0] = -4.0f
; U(world
).m
[3][1] = -3.0f
; U(world
).m
[3][2] = -2.0f
; U(world
).m
[3][3] = 27.0f
;
2350 /* D3DXVec2TransformCoordArray */
2351 exp_vec
[1].x
= 6.78571403e-01f
; exp_vec
[1].y
= 7.85714269e-01f
;
2352 exp_vec
[2].x
= 6.53846204e-01f
; exp_vec
[2].y
= 7.69230783e-01f
;
2353 exp_vec
[3].x
= 6.25000000e-01f
; exp_vec
[3].y
= 7.50000000e-01f
;
2354 exp_vec
[4].x
= 5.90909123e-01f
; exp_vec
[4].y
= 7.27272749e-01f
;
2355 exp_vec
[5].x
= 5.49999952e-01f
; exp_vec
[5].y
= 6.99999928e-01f
;
2356 D3DXVec2TransformCoordArray((D3DXVECTOR2
*)&out_vec
[1], sizeof(*out_vec
),
2357 (D3DXVECTOR2
*)inp_vec
, sizeof(*inp_vec
), &mat
, ARRAY_SIZE
);
2358 expect_vec4_array(ARRAY_SIZE
+ 2, exp_vec
, out_vec
, 1);
2360 /* D3DXVec2TransformNormalArray */
2361 exp_vec
[1].x
= 25.0f
; exp_vec
[1].y
= 30.0f
;
2362 exp_vec
[2].x
= 21.0f
; exp_vec
[2].y
= 26.0f
;
2363 exp_vec
[3].x
= 17.0f
; exp_vec
[3].y
= 22.0f
;
2364 exp_vec
[4].x
= 13.0f
; exp_vec
[4].y
= 18.0f
;
2365 exp_vec
[5].x
= 9.0f
; exp_vec
[5].y
= 14.0f
;
2366 D3DXVec2TransformNormalArray((D3DXVECTOR2
*)&out_vec
[1], sizeof(*out_vec
),
2367 (D3DXVECTOR2
*)inp_vec
, sizeof(*inp_vec
), &mat
, ARRAY_SIZE
);
2368 expect_vec4_array(ARRAY_SIZE
+ 2, exp_vec
, out_vec
, 0);
2370 /* D3DXVec3TransformCoordArray */
2371 exp_vec
[1].x
= 6.78571403e-01f
; exp_vec
[1].y
= 7.85714269e-01f
; exp_vec
[1].z
= 8.92857075e-01f
;
2372 exp_vec
[2].x
= 6.71874940e-01f
; exp_vec
[2].y
= 7.81249940e-01f
; exp_vec
[2].z
= 8.90624940e-01f
;
2373 exp_vec
[3].x
= 6.66666627e-01f
; exp_vec
[3].y
= 7.77777731e-01f
; exp_vec
[3].z
= 8.88888836e-01f
;
2374 exp_vec
[4].x
= 6.62499964e-01f
; exp_vec
[4].y
= 7.74999976e-01f
; exp_vec
[4].z
= 8.87499928e-01f
;
2375 exp_vec
[5].x
= 6.59090877e-01f
; exp_vec
[5].y
= 7.72727251e-01f
; exp_vec
[5].z
= 8.86363566e-01f
;
2376 D3DXVec3TransformCoordArray((D3DXVECTOR3
*)&out_vec
[1], sizeof(*out_vec
),
2377 (D3DXVECTOR3
*)inp_vec
, sizeof(*inp_vec
), &mat
, ARRAY_SIZE
);
2378 expect_vec4_array(ARRAY_SIZE
+ 2, exp_vec
, out_vec
, 1);
2380 /* D3DXVec3TransformNormalArray */
2381 exp_vec
[1].x
= 25.0f
; exp_vec
[1].y
= 30.0f
; exp_vec
[1].z
= 35.0f
;
2382 exp_vec
[2].x
= 30.0f
; exp_vec
[2].y
= 36.0f
; exp_vec
[2].z
= 42.0f
;
2383 exp_vec
[3].x
= 35.0f
; exp_vec
[3].y
= 42.0f
; exp_vec
[3].z
= 49.0f
;
2384 exp_vec
[4].x
= 40.0f
; exp_vec
[4].y
= 48.0f
; exp_vec
[4].z
= 56.0f
;
2385 exp_vec
[5].x
= 45.0f
; exp_vec
[5].y
= 54.0f
; exp_vec
[5].z
= 63.0f
;
2386 D3DXVec3TransformNormalArray((D3DXVECTOR3
*)&out_vec
[1], sizeof(*out_vec
),
2387 (D3DXVECTOR3
*)inp_vec
, sizeof(*inp_vec
), &mat
, ARRAY_SIZE
);
2388 expect_vec4_array(ARRAY_SIZE
+ 2, exp_vec
, out_vec
, 0);
2390 /* D3DXVec3ProjectArray */
2391 exp_vec
[1].x
= 1.08955420e+03f
; exp_vec
[1].y
= -2.26590622e+02f
; exp_vec
[1].z
= 2.15272754e-01f
;
2392 exp_vec
[2].x
= 1.06890344e+03f
; exp_vec
[2].y
= 1.03085144e+02f
; exp_vec
[2].z
= 1.83049560e-01f
;
2393 exp_vec
[3].x
= 1.05177905e+03f
; exp_vec
[3].y
= 3.76462280e+02f
; exp_vec
[3].z
= 1.56329080e-01f
;
2394 exp_vec
[4].x
= 1.03734888e+03f
; exp_vec
[4].y
= 6.06827393e+02f
; exp_vec
[4].z
= 1.33812696e-01f
;
2395 exp_vec
[5].x
= 1.02502356e+03f
; exp_vec
[5].y
= 8.03591248e+02f
; exp_vec
[5].z
= 1.14580572e-01f
;
2396 D3DXVec3ProjectArray((D3DXVECTOR3
*)&out_vec
[1], sizeof(*out_vec
), (D3DXVECTOR3
*)inp_vec
,
2397 sizeof(*inp_vec
), &viewport
, &projection
, &view
, &world
, ARRAY_SIZE
);
2398 expect_vec4_array(ARRAY_SIZE
+ 2, exp_vec
, out_vec
, 8);
2400 /* D3DXVec3UnprojectArray */
2401 exp_vec
[1].x
= -6.12403107e+00f
; exp_vec
[1].y
= 3.22536016e+00f
; exp_vec
[1].z
= 6.20571136e-01f
;
2402 exp_vec
[2].x
= -3.80710936e+00f
; exp_vec
[2].y
= 2.04657936e+00f
; exp_vec
[2].z
= 4.46894377e-01f
;
2403 exp_vec
[3].x
= -2.92283988e+00f
; exp_vec
[3].y
= 1.59668946e+00f
; exp_vec
[3].z
= 3.80609393e-01f
;
2404 exp_vec
[4].x
= -2.45622563e+00f
; exp_vec
[4].y
= 1.35928988e+00f
; exp_vec
[4].z
= 3.45631927e-01f
;
2405 exp_vec
[5].x
= -2.16789746e+00f
; exp_vec
[5].y
= 1.21259713e+00f
; exp_vec
[5].z
= 3.24018806e-01f
;
2406 D3DXVec3UnprojectArray((D3DXVECTOR3
*)&out_vec
[1], sizeof(*out_vec
), (D3DXVECTOR3
*)inp_vec
,
2407 sizeof(*inp_vec
), &viewport
, &projection
, &view
, &world
, ARRAY_SIZE
);
2408 expect_vec4_array(ARRAY_SIZE
+ 2, exp_vec
, out_vec
, 4);
2410 /* D3DXVec2TransformArray */
2411 exp_vec
[1].x
= 38.0f
; exp_vec
[1].y
= 44.0f
; exp_vec
[1].z
= 50.0f
; exp_vec
[1].w
= 56.0f
;
2412 exp_vec
[2].x
= 34.0f
; exp_vec
[2].y
= 40.0f
; exp_vec
[2].z
= 46.0f
; exp_vec
[2].w
= 52.0f
;
2413 exp_vec
[3].x
= 30.0f
; exp_vec
[3].y
= 36.0f
; exp_vec
[3].z
= 42.0f
; exp_vec
[3].w
= 48.0f
;
2414 exp_vec
[4].x
= 26.0f
; exp_vec
[4].y
= 32.0f
; exp_vec
[4].z
= 38.0f
; exp_vec
[4].w
= 44.0f
;
2415 exp_vec
[5].x
= 22.0f
; exp_vec
[5].y
= 28.0f
; exp_vec
[5].z
= 34.0f
; exp_vec
[5].w
= 40.0f
;
2416 D3DXVec2TransformArray(&out_vec
[1], sizeof(*out_vec
), (D3DXVECTOR2
*)inp_vec
,
2417 sizeof(*inp_vec
), &mat
, ARRAY_SIZE
);
2418 expect_vec4_array(ARRAY_SIZE
+ 2, exp_vec
, out_vec
, 0);
2420 /* D3DXVec3TransformArray */
2421 exp_vec
[1].x
= 38.0f
; exp_vec
[1].y
= 44.0f
; exp_vec
[1].z
= 50.0f
; exp_vec
[1].w
= 56.0f
;
2422 exp_vec
[2].x
= 43.0f
; exp_vec
[2].y
= 50.0f
; exp_vec
[2].z
= 57.0f
; exp_vec
[2].w
= 64.0f
;
2423 exp_vec
[3].x
= 48.0f
; exp_vec
[3].y
= 56.0f
; exp_vec
[3].z
= 64.0f
; exp_vec
[3].w
= 72.0f
;
2424 exp_vec
[4].x
= 53.0f
; exp_vec
[4].y
= 62.0f
; exp_vec
[4].z
= 71.0f
; exp_vec
[4].w
= 80.0f
;
2425 exp_vec
[5].x
= 58.0f
; exp_vec
[5].y
= 68.0f
; exp_vec
[5].z
= 78.0f
; exp_vec
[5].w
= 88.0f
;
2426 D3DXVec3TransformArray(&out_vec
[1], sizeof(*out_vec
), (D3DXVECTOR3
*)inp_vec
,
2427 sizeof(*inp_vec
), &mat
, ARRAY_SIZE
);
2428 expect_vec4_array(ARRAY_SIZE
+ 2, exp_vec
, out_vec
, 0);
2430 /* D3DXVec4TransformArray */
2431 exp_vec
[1].x
= 90.0f
; exp_vec
[1].y
= 100.0f
; exp_vec
[1].z
= 110.0f
; exp_vec
[1].w
= 120.0f
;
2432 exp_vec
[2].x
= 82.0f
; exp_vec
[2].y
= 92.0f
; exp_vec
[2].z
= 102.0f
; exp_vec
[2].w
= 112.0f
;
2433 exp_vec
[3].x
= 74.0f
; exp_vec
[3].y
= 84.0f
; exp_vec
[3].z
= 94.0f
; exp_vec
[3].w
= 104.0f
;
2434 exp_vec
[4].x
= 66.0f
; exp_vec
[4].y
= 76.0f
; exp_vec
[4].z
= 86.0f
; exp_vec
[4].w
= 96.0f
;
2435 exp_vec
[5].x
= 58.0f
; exp_vec
[5].y
= 68.0f
; exp_vec
[5].z
= 78.0f
; exp_vec
[5].w
= 88.0f
;
2436 D3DXVec4TransformArray(&out_vec
[1], sizeof(*out_vec
), inp_vec
, sizeof(*inp_vec
), &mat
, ARRAY_SIZE
);
2437 expect_vec4_array(ARRAY_SIZE
+ 2, exp_vec
, out_vec
, 0);
2439 /* D3DXPlaneTransformArray */
2440 exp_plane
[1].a
= 90.0f
; exp_plane
[1].b
= 100.0f
; exp_plane
[1].c
= 110.0f
; exp_plane
[1].d
= 120.0f
;
2441 exp_plane
[2].a
= 82.0f
; exp_plane
[2].b
= 92.0f
; exp_plane
[2].c
= 102.0f
; exp_plane
[2].d
= 112.0f
;
2442 exp_plane
[3].a
= 74.0f
; exp_plane
[3].b
= 84.0f
; exp_plane
[3].c
= 94.0f
; exp_plane
[3].d
= 104.0f
;
2443 exp_plane
[4].a
= 66.0f
; exp_plane
[4].b
= 76.0f
; exp_plane
[4].c
= 86.0f
; exp_plane
[4].d
= 96.0f
;
2444 exp_plane
[5].a
= 58.0f
; exp_plane
[5].b
= 68.0f
; exp_plane
[5].c
= 78.0f
; exp_plane
[5].d
= 88.0f
;
2445 D3DXPlaneTransformArray(&out_plane
[1], sizeof(*out_plane
), inp_plane
, sizeof(*inp_plane
), &mat
, ARRAY_SIZE
);
2446 for (i
= 0; i
< ARRAY_SIZE
+ 2; ++i
)
2448 BOOL equal
= compare_plane(&exp_plane
[i
], &out_plane
[i
], 0);
2449 ok(equal
, "Got unexpected plane {%.8e, %.8e, %.8e, %.8e} at index %u, expected {%.8e, %.8e, %.8e, %.8e}.\n",
2450 out_plane
[i
].a
, out_plane
[i
].b
, out_plane
[i
].c
, out_plane
[i
].d
, i
,
2451 exp_plane
[i
].a
, exp_plane
[i
].b
, exp_plane
[i
].c
, exp_plane
[i
].d
);
2457 static void test_D3DXFloat_Array(void)
2464 /* Input floats through bit patterns because compilers do not generate reliable INF and NaN values. */
2473 union convert single_in
;
2475 /* half_ver2 occurs on WXPPROSP3 (32 bit math), WVISTAADM (32/64 bit math), W7PRO (32 bit math) */
2476 WORD half_ver1
, half_ver2
;
2478 /* single_out_ver2 confirms that half -> single conversion is consistent across platforms */
2479 union convert single_out_ver1
, single_out_ver2
;
2483 { { 0x479c4000 }, 0x7c00, 0x7ce2, { 0x47800000 }, { 0x479c4000 } }, /* 80000.0f */
2484 { { 0x477fdf00 }, 0x7bff, 0x7bff, { 0x477fe000 }, { 0x477fe000 } }, /* 65503.0f */
2485 { { 0x477fe000 }, 0x7bff, 0x7bff, { 0x477fe000 }, { 0x477fe000 } }, /* 65504.0f */
2486 { { 0x477ff000 }, 0x7bff, 0x7c00, { 0x477fe000 }, { 0x47800000 } }, /* 65520.0f */
2487 { { 0x477ff100 }, 0x7c00, 0x7c00, { 0x47800000 }, { 0x47800000 } }, /* 65521.0f */
2489 { { 0x477ffe00 }, 0x7c00, 0x7c00, { 0x47800000 }, { 0x47800000 } }, /* 65534.0f */
2490 { { 0x477fff00 }, 0x7c00, 0x7c00, { 0x47800000 }, { 0x47800000 } }, /* 65535.0f */
2491 { { 0x47800000 }, 0x7c00, 0x7c00, { 0x47800000 }, { 0x47800000 } }, /* 65536.0f */
2492 { { 0xc79c4000 }, 0xfc00, 0xfce2, { 0xc7800000 }, { 0xc79c4000 } }, /* -80000.0f */
2493 { { 0xc77fdf00 }, 0xfbff, 0xfbff, { 0xc77fe000 }, { 0xc77fe000 } }, /* -65503.0f */
2495 { { 0xc77fe000 }, 0xfbff, 0xfbff, { 0xc77fe000 }, { 0xc77fe000 } }, /* -65504.0f */
2496 { { 0xc77ff000 }, 0xfbff, 0xfc00, { 0xc77fe000 }, { 0xc7800000 } }, /* -65520.0f */
2497 { { 0xc77ff100 }, 0xfc00, 0xfc00, { 0xc7800000 }, { 0xc7800000 } }, /* -65521.0f */
2498 { { 0xc77ffe00 }, 0xfc00, 0xfc00, { 0xc7800000 }, { 0xc7800000 } }, /* -65534.0f */
2499 { { 0xc77fff00 }, 0xfc00, 0xfc00, { 0xc7800000 }, { 0xc7800000 } }, /* -65535.0f */
2501 { { 0xc7800000 }, 0xfc00, 0xfc00, { 0xc7800000 }, { 0xc7800000 } }, /* -65536.0f */
2502 { { 0x7f800000 }, 0x7c00, 0x7fff, { 0x47800000 }, { 0x47ffe000 } }, /* INF */
2503 { { 0xff800000 }, 0xffff, 0xffff, { 0xc7ffe000 }, { 0xc7ffe000 } }, /* -INF */
2504 { { 0x7fc00000 }, 0x7fff, 0xffff, { 0x47ffe000 }, { 0xc7ffe000 } }, /* NaN */
2505 { { 0xffc00000 }, 0xffff, 0xffff, { 0xc7ffe000 }, { 0xc7ffe000 } }, /* -NaN */
2507 { { 0x00000000 }, 0x0000, 0x0000, { 0x00000000 }, { 0x00000000 } }, /* 0.0f */
2508 { { 0x80000000 }, 0x8000, 0x8000, { 0x80000000 }, { 0x80000000 } }, /* -0.0f */
2509 { { 0x330007ff }, 0x0000, 0x0000, { 0x00000000 }, { 0x00000000 } }, /* 2.9809595e-08f */
2510 { { 0xb30007ff }, 0x8000, 0x8000, { 0x80000000 }, { 0x80000000 } }, /* -2.9809595e-08f */
2511 { { 0x33000800 }, 0x0001, 0x0000, { 0x33800000 }, { 0x00000000 } }, /* 2.9809598e-08f */
2513 { { 0xb3000800 }, 0x8001, 0x8000, { 0xb3800000 }, { 0x80000000 } }, /* -2.9809598e-08f */
2514 { { 0x33c00000 }, 0x0002, 0x0001, { 0x34000000 }, { 0x33800000 } }, /* 8.9406967e-08f */
2517 /* exception on NULL out or in parameter */
2518 out
= D3DXFloat32To16Array(&half
, &single
.f
, 0);
2519 ok(out
== &half
, "Got %p, expected %p.\n", out
, &half
);
2521 out
= D3DXFloat16To32Array(&single
.f
, &half
, 0);
2522 ok(out
== &single
.f
, "Got %p, expected %p.\n", out
, &single
.f
);
2524 for (i
= 0; i
< sizeof(testdata
)/sizeof(testdata
[0]); i
++)
2526 out
= D3DXFloat32To16Array(&half
, &testdata
[i
].single_in
.f
, 1);
2527 ok(out
== &half
, "Got %p, expected %p.\n", out
, &half
);
2528 ok(half
.value
== testdata
[i
].half_ver1
|| half
.value
== testdata
[i
].half_ver2
,
2529 "Got %x, expected %x or %x for index %d.\n", half
.value
, testdata
[i
].half_ver1
,
2530 testdata
[i
].half_ver2
, i
);
2532 out
= D3DXFloat16To32Array(&single
.f
, (D3DXFLOAT16
*)&testdata
[i
].half_ver1
, 1);
2533 ok(out
== &single
.f
, "Got %p, expected %p.\n", out
, &single
.f
);
2534 equal
= compare_float(single
.f
, testdata
[i
].single_out_ver1
.f
, 0);
2535 ok(equal
, "Got %#x, expected %#x at index %u.\n", single
.d
, testdata
[i
].single_out_ver1
.d
, i
);
2537 out
= D3DXFloat16To32Array(&single
.f
, (D3DXFLOAT16
*)&testdata
[i
].half_ver2
, 1);
2538 ok(out
== &single
.f
, "Got %p, expected %p.\n", out
, &single
.f
);
2539 equal
= compare_float(single
.f
, testdata
[i
].single_out_ver2
.f
, 0);
2540 ok(equal
, "Got %#x, expected %#x at index %u.\n", single
.d
, testdata
[i
].single_out_ver2
.d
, i
);
2544 static void test_D3DXSHAdd(void)
2546 float out
[50] = {0.0f
};
2551 static const float in1
[50] =
2553 1.11f
, 1.12f
, 1.13f
, 1.14f
, 1.15f
, 1.16f
, 1.17f
, 1.18f
,
2554 1.19f
, 1.20f
, 1.21f
, 1.22f
, 1.23f
, 1.24f
, 1.25f
, 1.26f
,
2555 1.27f
, 1.28f
, 1.29f
, 1.30f
, 1.31f
, 1.32f
, 1.33f
, 1.34f
,
2556 1.35f
, 1.36f
, 1.37f
, 1.38f
, 1.39f
, 1.40f
, 1.41f
, 1.42f
,
2557 1.43f
, 1.44f
, 1.45f
, 1.46f
, 1.47f
, 1.48f
, 1.49f
, 1.50f
,
2558 1.51f
, 1.52f
, 1.53f
, 1.54f
, 1.55f
, 1.56f
, 1.57f
, 1.58f
,
2561 static const float in2
[50] =
2563 2.11f
, 2.12f
, 2.13f
, 2.14f
, 2.15f
, 2.16f
, 2.17f
, 2.18f
,
2564 2.19f
, 2.20f
, 2.21f
, 2.22f
, 2.23f
, 2.24f
, 2.25f
, 2.26f
,
2565 2.27f
, 2.28f
, 2.29f
, 2.30f
, 2.31f
, 2.32f
, 2.33f
, 2.34f
,
2566 2.35f
, 2.36f
, 2.37f
, 2.38f
, 2.39f
, 2.40f
, 2.41f
, 2.42f
,
2567 2.43f
, 2.44f
, 2.45f
, 2.46f
, 2.47f
, 2.48f
, 2.49f
, 2.50f
,
2568 2.51f
, 2.52f
, 2.53f
, 2.54f
, 2.55f
, 2.56f
, 2.57f
, 2.58f
,
2573 * Order is not limited by D3DXSH_MINORDER and D3DXSH_MAXORDER!
2574 * All values will work, test from 0-7 [D3DXSH_MINORDER = 2, D3DXSH_MAXORDER = 6]
2575 * Exceptions will show up when out, in1 or in2 is NULL
2577 for (k
= 0; k
<= D3DXSH_MAXORDER
+ 1; k
++)
2581 ret
= D3DXSHAdd(&out
[0], k
, &in1
[0], &in2
[0]);
2582 ok(ret
== out
, "%u: D3DXSHAdd() failed, got %p, expected %p\n", k
, out
, ret
);
2584 for (i
= 0; i
< count
; ++i
)
2586 equal
= compare_float(in1
[i
] + in2
[i
], out
[i
], 0);
2587 ok(equal
, "%u-%u: Got %.8e, expected %.8e.\n", k
, i
, out
[i
], in1
[i
] + in2
[i
]);
2589 equal
= compare_float(out
[count
], 0.0f
, 0);
2590 ok(equal
, "%u-%u: Got %.8e, expected 0.0.\n", k
, k
* k
, out
[count
]);
2594 static void test_D3DXSHDot(void)
2596 float a
[49], b
[49], got
;
2600 static const float expected
[] = {0.5f
, 0.5f
, 25.0f
, 262.5f
, 1428.0f
, 5362.5f
, 15873.0f
, 39812.5f
};
2602 for (i
= 0; i
< 49; i
++)
2608 /* D3DXSHDot computes by using order * order elements */
2609 for (i
= 0; i
<= D3DXSH_MAXORDER
+ 1; i
++)
2611 got
= D3DXSHDot(i
, a
, b
);
2612 equal
= compare_float(got
, expected
[i
], 0);
2613 ok(equal
, "order %u: Got %.8e, expected %.8e.\n", i
, got
, expected
[i
]);
2617 static void test_D3DXSHEvalConeLight(void)
2619 float bout
[49], expected
, gout
[49], rout
[49];
2620 unsigned int j
, l
, order
;
2625 static const float table
[] =
2628 1.604815f
, -3.131381f
, 7.202175f
, -2.870432f
, 6.759296f
, -16.959688f
,
2629 32.303082f
, -15.546381f
, -0.588878f
, -5.902123f
, 40.084042f
, -77.423569f
,
2630 137.556320f
, -70.971603f
, -3.492171f
, 7.683092f
, -2.129311f
, -35.971344f
,
2631 183.086548f
, -312.414948f
, 535.091064f
, -286.380371f
, -15.950727f
, 46.825714f
,
2632 -12.127637f
, 11.289261f
, -12.417809f
, -155.039566f
, 681.182556f
, -1079.733643f
,
2633 1807.650513f
, -989.755798f
, -59.345467f
, 201.822815f
, -70.726486f
, 7.206529f
,
2635 3.101155f
, -3.128710f
, 7.196033f
, -2.867984f
, -0.224708f
, 0.563814f
,
2636 -1.073895f
, 0.516829f
, 0.019577f
, 2.059788f
, -13.988971f
, 27.020128f
,
2637 -48.005917f
, 24.768450f
, 1.218736f
, -2.681329f
, -0.088639f
, -1.497410f
,
2638 7.621501f
, -13.005165f
, 22.274696f
, -11.921401f
, -0.663995f
, 1.949254f
,
2639 -0.504848f
, 4.168484f
, -4.585193f
, -57.247314f
, 251.522095f
, -398.684387f
,
2640 667.462891f
, -365.460693f
, -21.912912f
, 74.521721f
, -26.115280f
, 2.660963f
,
2642 2.454422f
, -4.789170f
, 11.015091f
, -4.390072f
, 10.337747f
, -25.938347f
,
2643 49.404713f
, -23.776817f
, -0.900637f
, -9.026776f
, 61.305000f
, -118.412514f
,
2644 210.380249f
, -108.544792f
, -5.340967f
, 11.750610f
, -3.256593f
, -55.014996f
,
2645 280.014709f
, -477.811066f
, 818.374512f
, -437.993469f
, -24.395227f
, 71.615799f
,
2646 -18.548151f
, 17.265928f
, -18.991943f
, -237.119324f
, 1041.808594f
, -1651.357300f
,
2647 2764.642090f
, -1513.744141f
, -90.763657f
, 308.670197f
, -108.169922f
, 11.021750f
,
2649 4.742942f
, -4.785086f
, 11.005697f
, -4.386329f
, -0.343672f
, 0.862303f
,
2650 -1.642427f
, 0.790444f
, 0.029941f
, 3.150264f
, -21.394896f
, 41.324898f
,
2651 -73.420807f
, 37.881153f
, 1.863950f
, -4.100857f
, -0.135565f
, -2.290156f
,
2652 11.656413f
, -19.890251f
, 34.067181f
, -18.232729f
, -1.015521f
, 2.981212f
,
2653 -0.772120f
, 6.375328f
, -7.012648f
, -87.554710f
, 384.680817f
, -609.752563f
,
2654 1020.825500f
, -558.939819f
, -33.513863f
, 113.974388f
, -39.941013f
, 4.069707f
,
2656 3.304030f
, -6.446959f
, 14.828006f
, -5.909713f
, 13.916198f
, -34.917004f
,
2657 66.506340f
, -32.007256f
, -1.212396f
, -12.151429f
, 82.525963f
, -159.401459f
,
2658 283.204193f
, -146.117996f
, -7.189764f
, 15.818130f
, -4.383876f
, -74.058655f
,
2659 376.942871f
, -643.207214f
, 1101.658081f
, -589.606628f
, -32.839729f
, 96.405884f
,
2660 -24.968664f
, 23.242596f
, -25.566080f
, -319.199097f
, 1402.434692f
, -2222.980957f
,
2661 3721.633545f
, -2037.732544f
, -122.181847f
, 415.517578f
, -145.613358f
, 14.836972f
,
2663 6.384730f
, -6.441462f
, 14.815362f
, -5.904673f
, -0.462635f
, 1.160793f
,
2664 -2.210959f
, 1.064060f
, 0.040305f
, 4.240739f
, -28.800821f
, 55.629673f
,
2665 -98.835709f
, 50.993862f
, 2.509163f
, -5.520384f
, -0.182491f
, -3.082903f
,
2666 15.691326f
, -26.775339f
, 45.859665f
, -24.544060f
, -1.367048f
, 4.013170f
,
2667 -1.039392f
, 8.582172f
, -9.440103f
, -117.862114f
, 517.839600f
, -820.820740f
,
2668 1374.188232f
, -752.419067f
, -45.114819f
, 153.427063f
, -53.766754f
, 5.478452f
, };
2671 float *red_received
, *green_received
, *blue_received
;
2672 const float *red_expected
, *green_expected
, *blue_expected
;
2673 float radius
, roffset
, goffset
, boffset
;
2677 { rout
, gout
, bout
, table
, &table
[72], &table
[144], 0.5f
, 1.01f
, 1.02f
, 1.03f
, },
2678 { rout
, gout
, bout
, &table
[36], &table
[108], &table
[180], 1.6f
, 1.01f
, 1.02f
, 1.03f
, },
2679 { rout
, rout
, rout
, &table
[144], &table
[144], &table
[144], 0.5f
, 1.03f
, 1.03f
, 1.03f
, },
2680 { rout
, rout
, bout
, &table
[72], &table
[72], &table
[144], 0.5, 1.02f
, 1.02f
, 1.03f
, },
2681 { rout
, gout
, gout
, table
, &table
[144], &table
[144], 0.5f
, 1.01f
, 1.03f
, 1.03f
, },
2682 { rout
, gout
, rout
, &table
[144], &table
[72], &table
[144], 0.5f
, 1.03f
, 1.02f
, 1.03f
, },
2683 /* D3DXSHEvalConeLight accepts NULL green or blue colour. */
2684 { rout
, NULL
, bout
, table
, NULL
, &table
[144], 0.5f
, 1.01f
, 0.0f
, 1.03f
, },
2685 { rout
, gout
, NULL
, table
, &table
[72], NULL
, 0.5f
, 1.01f
, 1.02f
, 0.0f
, },
2686 { rout
, NULL
, NULL
, table
, NULL
, NULL
, 0.5f
, 1.01f
, 0.0f
, 0.0f
, },
2689 dir
.x
= 1.1f
; dir
.y
= 1.2f
; dir
.z
= 2.76f
;
2691 for (l
= 0; l
< sizeof(test
) / sizeof(test
[0]); l
++)
2693 for (order
= D3DXSH_MINORDER
; order
<= D3DXSH_MAXORDER
; order
++)
2695 for (j
= 0; j
< 49; j
++)
2697 test
[l
].red_received
[j
] = 1.01f
+ j
;
2698 if (test
[l
].green_received
)
2699 test
[l
].green_received
[j
] = 1.02f
+ j
;
2700 if (test
[l
].blue_received
)
2701 test
[l
].blue_received
[j
] = 1.03f
+ j
;
2704 hr
= D3DXSHEvalConeLight(order
, &dir
, test
[l
].radius
, 1.7f
, 2.6f
, 3.5f
, test
[l
].red_received
, test
[l
].green_received
, test
[l
].blue_received
);
2705 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2707 for (j
= 0; j
< 49; j
++)
2709 if (j
>= order
* order
)
2710 expected
= j
+ test
[l
].roffset
;
2712 expected
= test
[l
].red_expected
[j
];
2713 equal
= compare_float(test
[l
].red_received
[j
], expected
, 128);
2714 ok(equal
, "Red: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
2715 l
, order
, j
, expected
, test
[l
].red_received
[j
]);
2717 if (test
[l
].green_received
)
2719 if (j
>= order
* order
)
2720 expected
= j
+ test
[l
].goffset
;
2722 expected
= test
[l
].green_expected
[j
];
2723 equal
= compare_float(test
[l
].green_received
[j
], expected
, 64);
2724 ok(equal
, "Green: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
2725 l
, order
, j
, expected
, test
[l
].green_received
[j
]);
2728 if (test
[l
].blue_received
)
2730 if (j
>= order
* order
)
2731 expected
= j
+ test
[l
].boffset
;
2733 expected
= test
[l
].blue_expected
[j
];
2734 equal
= compare_float(test
[l
].blue_received
[j
], expected
, 128);
2735 ok(equal
, "Blue: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
2736 l
, order
, j
, expected
, test
[l
].blue_received
[j
]);
2742 /* Cone light with radius <= 0.0f behaves as a directional light */
2743 for (order
= D3DXSH_MINORDER
; order
<= D3DXSH_MAXORDER
; order
++)
2745 FLOAT blue
[49], green
[49], red
[49];
2747 for (j
= 0; j
< 49; j
++)
2749 rout
[j
] = 1.01f
+ j
;
2750 gout
[j
] = 1.02f
+ j
;
2751 bout
[j
] = 1.03f
+ j
;
2753 green
[j
] = 1.02f
+ j
;
2754 blue
[j
] = 1.03f
+ j
;
2757 hr
= D3DXSHEvalConeLight(order
, &dir
, -0.1f
, 1.7f
, 2.6f
, 3.5f
, rout
, gout
, bout
);
2758 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2759 D3DXSHEvalDirectionalLight(order
, &dir
, 1.7f
, 2.6f
, 3.5f
, red
, green
, blue
);
2761 for (j
= 0; j
< 49; j
++)
2763 equal
= compare_float(red
[j
], rout
[j
], 0);
2764 ok(equal
, "Red: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
2765 l
, order
, j
, red
[j
], rout
[j
]);
2767 equal
= compare_float(green
[j
], gout
[j
], 0);
2768 ok(equal
, "Green: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
2769 l
, order
, j
, green
[j
], gout
[j
]);
2771 equal
= compare_float(blue
[j
], bout
[j
], 0);
2772 ok(equal
, "Blue: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
2773 l
, order
, j
, blue
[j
], bout
[j
]);
2777 /* D3DXSHEvalConeLight accepts order < D3DXSH_MINORDER or order > D3DXSH_MAXORDER. But tests in native windows show that the colour outputs are not set */
2778 hr
= D3DXSHEvalConeLight(7, &dir
, 0.5f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
2779 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2780 hr
= D3DXSHEvalConeLight(0, &dir
, 0.5f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
2781 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2782 hr
= D3DXSHEvalConeLight(1, &dir
, 0.5f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
2783 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2786 static void test_D3DXSHEvalDirection(void)
2788 float a
[49], expected
, *received_ptr
;
2789 unsigned int i
, order
;
2793 static const float table
[36] =
2795 2.82094806e-01f
, -9.77205038e-01f
, 1.46580756e+00f
, -4.88602519e-01f
, 2.18509698e+00f
, -6.55529118e+00f
,
2796 8.20018101e+00f
, -3.27764559e-00f
, -1.63882279e+00f
, 1.18008721e+00f
, 1.73436680e+01f
, -4.02200317e+01f
,
2797 4.70202179e+01f
, -2.01100159e+01f
, -1.30077515e+01f
, 6.49047947e+00f
, -1.50200577e+01f
, 1.06207848e+01f
,
2798 1.17325661e+02f
, -2.40856750e+02f
, 2.71657288e+02f
, -1.20428375e+02f
, -8.79942474e+01f
, 5.84143143e+01f
,
2799 -4.38084984e+00f
, 2.49425201e+01f
, -1.49447693e+02f
, 7.82781296e+01f
, 7.47791748e+02f
, -1.42768787e+03f
,
2800 1.57461914e+03f
, -7.13843933e+02f
, -5.60843811e+02f
, 4.30529724e+02f
, -4.35889091e+01f
, -2.69116650e+01f
,
2803 d
.x
= 1.0; d
.y
= 2.0f
; d
.z
= 3.0f
;
2805 for (order
= 0; order
<= D3DXSH_MAXORDER
+ 1; order
++)
2807 for (i
= 0; i
< 49; i
++)
2810 received_ptr
= D3DXSHEvalDirection(a
, order
, &d
);
2811 ok(received_ptr
== a
, "Expected %p, received %p\n", a
, received_ptr
);
2813 for (i
= 0; i
< 49; i
++)
2815 /* if the order is < D3DXSH_MINORDER or order > D3DXSH_MAXORDER or
2816 * the index of the element is greater than order * order - 1,
2817 * D3DXSHEvalDirection() does not modify the output. */
2818 if ((order
< D3DXSH_MINORDER
) || (order
> D3DXSH_MAXORDER
) || (i
>= order
* order
))
2819 expected
= 1.5f
+ i
;
2821 expected
= table
[i
];
2823 equal
= compare_float(a
[i
], expected
, 2);
2824 ok(equal
, "order %u, index %u: Got unexpected result %.8e, expected %.8e.\n",
2825 order
, i
, a
[i
], expected
);
2830 static void test_D3DXSHEvalDirectionalLight(void)
2832 float *blue_out
, bout
[49], expected
, gout
[49], *green_out
, *red_out
, rout
[49];
2833 unsigned int j
, l
, order
, startindex
;
2838 static const float table
[] =
2841 2.008781f
, -4.175174f
, 9.602900f
, -3.827243f
, 1.417963f
, -2.947181f
,
2842 6.778517f
, -2.701583f
, 7.249108f
, -18.188671f
, 34.643921f
, -16.672949f
,
2843 -0.631551f
, 1.417963f
, -2.947181f
, 6.778517f
, -2.701583f
, 7.249108f
,
2844 -18.188671f
, 34.643921f
, -16.672949f
, -0.631551f
, -7.794341f
, 52.934967f
,
2845 -102.245529f
, 181.656815f
, -93.725060f
, -4.611760f
, 10.146287f
, 1.555186f
,
2846 -3.232392f
, 7.434503f
, -2.963026f
, 7.950634f
, -19.948866f
, 37.996559f
,
2847 -18.286459f
, -0.692669f
, -8.548632f
, 58.057705f
, -112.140251f
, 199.236496f
,
2848 -102.795227f
, -5.058059f
, 11.128186f
, -4.189955f
, -70.782669f
, 360.268829f
,
2849 -614.755005f
, 1052.926270f
, -563.525391f
, -31.387066f
, 92.141365f
, -23.864176f
,
2850 1.555186f
, -3.232392f
, 7.434503f
, -2.963026f
, 7.950634f
, -19.948866f
,
2851 37.996559f
, -18.286459f
, -0.692669f
, -8.548632f
, 58.057705f
, -112.140251f
,
2852 199.236496f
, -102.795227f
, -5.058059f
, 11.128186f
, -4.189955f
, -70.782669f
,
2853 360.268829f
, -614.755005f
, 1052.926270f
, -563.525391f
, -31.387066f
, 92.141365f
,
2854 -23.864176f
, 34.868664f
, -38.354366f
, -478.864166f
, 2103.939941f
, -3334.927734f
,
2855 5583.213867f
, -3057.017090f
, -183.297836f
, 623.361633f
, -218.449921f
, 22.258503f
,
2857 3.072254f
, -6.385560f
, 14.686787f
, -5.853429f
, 2.168650f
, -4.507453f
,
2858 10.367143f
, -4.131832f
, 11.086870f
, -27.817965f
, 52.984818f
, -25.499800f
,
2859 -0.965902f
, 2.168650f
, -4.507453f
, 10.367143f
, -4.131832f
, 11.086870f
,
2860 -27.817965f
, 52.984818f
, -25.499800f
, -0.965902f
, -11.920755f
, 80.959351f
,
2861 -156.375488f
, 277.828033f
, -143.344193f
, -7.053278f
, 15.517849f
, 2.378519f
,
2862 -4.943659f
, 11.370415f
, -4.531687f
, 12.159794f
, -30.510029f
, 58.112385f
,
2863 -27.967525f
, -1.059376f
, -13.074378f
, 88.794136f
, -171.508621f
, 304.714630f
,
2864 -157.216217f
, -7.735855f
, 17.019577f
, -6.408166f
, -108.255844f
, 550.999390f
,
2865 -940.213501f
, 1610.357788f
, -861.862305f
, -48.003746f
, 140.922089f
, -36.498150f
,
2866 2.378519f
, -4.943659f
, 11.370415f
, -4.531687f
, 12.159794f
, -30.510029f
,
2867 58.112385f
, -27.967525f
, -1.059376f
, -13.074378f
, 88.794136f
, -171.508621f
,
2868 304.714630f
, -157.216217f
, -7.735855f
, 17.019577f
, -6.408166f
, -108.255844f
,
2869 550.999390f
, -940.213501f
, 1610.357788f
, -861.862305f
, -48.003746f
, 140.922089f
,
2870 -36.498150f
, 53.328545f
, -58.659618f
, -732.380493f
, 3217.790283f
, -5100.477539f
,
2871 8539.033203f
, -4675.437500f
, -280.337860f
, 953.376587f
, -334.099884f
, 34.042416f
,
2873 4.135726f
, -8.595945f
, 19.770674f
, -7.879617f
, 2.919336f
, -6.067726f
,
2874 13.955770f
, -5.562082f
, 14.924634f
, -37.447262f
, 71.325722f
, -34.326656f
,
2875 -1.300252f
, 2.919336f
, -6.067726f
, 13.955770f
, -5.562082f
, 14.924634f
,
2876 -37.447262f
, 71.325722f
, -34.326656f
, -1.300252f
, -16.047173f
, 108.983749f
,
2877 -210.505493f
, 373.999298f
, -192.963348f
, -9.494799f
, 20.889414f
, 3.201853f
,
2878 -6.654925f
, 15.306328f
, -6.100348f
, 16.368954f
, -41.071194f
, 78.228210f
,
2879 -37.648590f
, -1.426083f
, -17.600124f
, 119.530563f
, -230.876984f
, 410.192780f
,
2880 -211.637222f
, -10.413651f
, 22.910971f
, -8.626378f
, -145.729019f
, 741.729919f
,
2881 -1265.671997f
, 2167.789307f
, -1160.199219f
, -64.620430f
, 189.702820f
, -49.132126f
,
2882 3.201853f
, -6.654925f
, 15.306328f
, -6.100348f
, 16.368954f
, -41.071194f
,
2883 78.228210f
, -37.648590f
, -1.426083f
, -17.600124f
, 119.530563f
, -230.876984f
,
2884 410.192780f
, -211.637222f
, -10.413651f
, 22.910971f
, -8.626378f
, -145.729019f
,
2885 741.729919f
, -1265.671997f
, 2167.789307f
, -1160.199219f
, -64.620430f
, 189.702820f
,
2886 -49.132126f
, 71.788422f
, -78.964867f
, -985.896790f
, 4331.640625f
, -6866.027344f
,
2887 11494.852539f
, -6293.858398f
, -377.377899f
, 1283.391479f
, -449.749817f
, 45.826328f
, };
2890 float *red_in
, *green_in
, *blue_in
;
2891 const float *red_out
, *green_out
, *blue_out
;
2892 float roffset
, goffset
, boffset
;
2896 { rout
, gout
, bout
, table
, &table
[90], &table
[180], 1.01f
, 1.02f
, 1.03f
, },
2897 { rout
, rout
, rout
, &table
[180], &table
[180], &table
[180], 1.03f
, 1.03f
, 1.03f
, },
2898 { rout
, rout
, bout
, &table
[90], &table
[90], &table
[180], 1.02f
, 1.02f
, 1.03f
, },
2899 { rout
, gout
, gout
, table
, &table
[180], &table
[180], 1.01f
, 1.03f
, 1.03f
, },
2900 { rout
, gout
, rout
, &table
[180], &table
[90], &table
[180], 1.03f
, 1.02f
, 1.03f
, },
2901 /* D3DXSHEvalDirectionaLight accepts NULL green or blue colour. */
2902 { rout
, NULL
, bout
, table
, NULL
, &table
[180], 1.01f
, 0.0f
, 1.03f
, },
2903 { rout
, gout
, NULL
, table
, &table
[90], NULL
, 1.01f
, 1.02f
, 0.0f
, },
2904 { rout
, NULL
, NULL
, table
, NULL
, NULL
, 1.01f
, 0.0f
, 0.0f
, },
2907 dir
.x
= 1.1f
; dir
.y
= 1.2f
; dir
.z
= 2.76f
;
2909 for (l
= 0; l
< sizeof( test
) / sizeof( test
[0] ); l
++)
2913 for (order
= D3DXSH_MINORDER
; order
<= D3DXSH_MAXORDER
; order
++)
2915 red_out
= test
[l
].red_in
;
2916 green_out
= test
[l
].green_in
;
2917 blue_out
= test
[l
].blue_in
;
2919 for (j
= 0; j
< 49; j
++)
2921 red_out
[j
] = 1.01f
+ j
;
2923 green_out
[j
] = 1.02f
+ j
;
2925 blue_out
[j
] = 1.03f
+ j
;
2928 hr
= D3DXSHEvalDirectionalLight(order
, &dir
, 1.7f
, 2.6f
, 3.5f
, red_out
, green_out
, blue_out
);
2929 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2931 for (j
= 0; j
< 49; j
++)
2933 if ( j
>= order
* order
)
2934 expected
= j
+ test
[l
].roffset
;
2936 expected
= test
[l
].red_out
[startindex
+ j
];
2937 equal
= compare_float(expected
, red_out
[j
], 8);
2938 ok(equal
, "Red: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
2939 l
, order
, j
, expected
, red_out
[j
]);
2943 if ( j
>= order
* order
)
2944 expected
= j
+ test
[l
].goffset
;
2946 expected
= test
[l
].green_out
[startindex
+ j
];
2947 equal
= compare_float(expected
, green_out
[j
], 8);
2948 ok(equal
, "Green: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
2949 l
, order
, j
, expected
, green_out
[j
]);
2954 if ( j
>= order
* order
)
2955 expected
= j
+ test
[l
].boffset
;
2957 expected
= test
[l
].blue_out
[startindex
+ j
];
2958 equal
= compare_float(expected
, blue_out
[j
], 4);
2959 ok(equal
, "Blue: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
2960 l
, order
, j
, expected
, blue_out
[j
]);
2964 startindex
+= order
* order
;
2968 /* D3DXSHEvalDirectionalLight accepts order < D3DXSH_MINORDER or order > D3DXSH_MAXORDER. But tests in native windows show that the colour outputs are not set*/
2969 hr
= D3DXSHEvalDirectionalLight(7, &dir
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
2970 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2971 hr
= D3DXSHEvalDirectionalLight(0, &dir
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
2972 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2973 hr
= D3DXSHEvalDirectionalLight(1, &dir
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
2974 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2977 static void test_D3DXSHEvalHemisphereLight(void)
2979 float bout
[49], expected
, gout
[49], rout
[49];
2980 unsigned int j
, l
, order
;
2981 D3DXCOLOR bottom
, top
;
2986 static const float table
[] =
2989 23.422981f
, 15.859521f
, -36.476898f
, 14.537894f
,
2991 19.966694f
, 6.096982f
, -14.023058f
, 5.588900f
,
2993 24.566214f
, 8.546826f
, -19.657701f
, 7.834591f
,
2997 float *red_received
, *green_received
, *blue_received
;
2998 const float *red_expected
, *green_expected
, *blue_expected
;
2999 const float roffset
, goffset
, boffset
;
3003 { rout
, gout
, bout
, table
, &table
[4], &table
[8], 1.01f
, 1.02f
, 1.03f
, },
3004 { rout
, rout
, rout
, &table
[8], &table
[8], &table
[8], 1.03f
, 1.03f
, 1.03f
, },
3005 { rout
, rout
, bout
, &table
[4], &table
[4], &table
[8], 1.02f
, 1.02f
, 1.03f
, },
3006 { rout
, gout
, gout
, table
, &table
[8], &table
[8], 1.01f
, 1.03f
, 1.03f
, },
3007 { rout
, gout
, rout
, &table
[8], &table
[4], &table
[8], 1.03f
, 1.02f
, 1.03f
, },
3008 /* D3DXSHEvalHemisphereLight accepts NULL green or blue colour. */
3009 { rout
, NULL
, bout
, table
, NULL
, &table
[8], 1.01f
, 1.02f
, 1.03f
, },
3010 { rout
, gout
, NULL
, table
, &table
[4], NULL
, 1.01f
, 1.02f
, 1.03f
, },
3011 { rout
, NULL
, NULL
, table
, NULL
, NULL
, 1.01f
, 1.02f
, 1.03f
, },
3014 dir
.x
= 1.1f
; dir
.y
= 1.2f
; dir
.z
= 2.76f
;
3015 top
.r
= 0.1f
; top
.g
= 2.1f
; top
.b
= 2.3f
; top
.a
= 4.3f
;
3016 bottom
.r
= 8.71f
; bottom
.g
= 5.41f
; bottom
.b
= 6.94f
; bottom
.a
= 8.43f
;
3018 for (l
= 0; l
< sizeof(test
) / sizeof(test
[0]); l
++)
3019 for (order
= D3DXSH_MINORDER
; order
<= D3DXSH_MAXORDER
+ 1; order
++)
3021 for (j
= 0; j
< 49; j
++)
3023 test
[l
].red_received
[j
] = 1.01f
+ j
;
3024 if (test
[l
].green_received
)
3025 test
[l
].green_received
[j
] = 1.02f
+ j
;
3026 if (test
[l
].blue_received
)
3027 test
[l
].blue_received
[j
] = 1.03f
+ j
;
3030 hr
= D3DXSHEvalHemisphereLight(order
, &dir
, top
, bottom
, test
[l
].red_received
, test
[l
].green_received
, test
[l
].blue_received
);
3031 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3033 for (j
= 0; j
< 49; j
++)
3036 expected
= test
[l
].red_expected
[j
];
3037 else if (j
< order
* order
)
3040 expected
= test
[l
].roffset
+ j
;
3041 equal
= compare_float(test
[l
].red_received
[j
], expected
, 4);
3042 ok(equal
, "Red: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3043 l
, order
, j
, expected
, test
[l
].red_received
[j
]);
3045 if (test
[l
].green_received
)
3048 expected
= test
[l
].green_expected
[j
];
3049 else if (j
< order
* order
)
3052 expected
= test
[l
].goffset
+ j
;
3053 equal
= compare_float(expected
, test
[l
].green_received
[j
], 4);
3054 ok(equal
, "Green: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3055 l
, order
, j
, expected
, test
[l
].green_received
[j
]);
3058 if (test
[l
].blue_received
)
3061 expected
= test
[l
].blue_expected
[j
];
3062 else if (j
< order
* order
)
3065 expected
= test
[l
].boffset
+ j
;
3066 equal
= compare_float(expected
, test
[l
].blue_received
[j
], 4);
3067 ok(equal
, "Blue: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3068 l
, order
, j
, expected
, test
[l
].blue_received
[j
]);
3074 static void test_D3DXSHEvalSphericalLight(void)
3077 FLOAT bout
[49], expected
, gout
[49], rout
[49];
3078 const FLOAT table
[] = {
3080 3.01317239f
, -0.97724032f
, 2.24765277f
, -0.89580363f
, 0.0f
, 0.0f
,
3081 0.0f
, 0.0f
, 0.0f
, 0.06292814f
, -0.42737406f
, 0.61921263f
,
3082 -0.30450898f
, 0.56761158f
, 0.03723336f
, -0.08191673f
, 0.0f
, 0.0f
,
3083 0.0f
, 0.0f
, 0.0f
, -0.0f
, 0.0f
, 0.0f
,
3084 0.0f
, 0.01249927f
, -0.01374878f
, -0.14810932f
, 0.43434596f
, -0.24598616f
,
3085 -0.15175794f
, -0.22548729f
, -0.03784076f
, 0.19280137f
, -0.07830712f
, 0.00797894f
,
3087 0.40251964f
, -0.24365333f
, 0.56040263f
, -0.22334887f
, 0.16204689f
, -0.40659040f
,
3088 0.44600141f
, -0.37270784f
, -0.01411773f
, -0.04319951f
, 0.29338786f
, -0.42508304f
,
3089 0.20904225f
, -0.38965943f
, -0.02556031f
, 0.05623499f
, -0.00468823f
, -0.07920021f
,
3090 0.33171222f
, -0.30782884f
, 0.00052908f
, -0.28217643f
, -0.02889918f
, 0.10309891f
,
3091 -0.02670213f
, 0.00724340f
, -0.00796750f
, -0.08583023f
, 0.25170606f
, -0.14255044f
,
3092 -0.08794463f
, -0.13067122f
, -0.02192894f
, 0.11172954f
, -0.04537944f
, 0.00462384f
,
3094 1.95445275f
, -0.85659367f
, 1.97016549f
, -0.78521085f
, 0.23103346f
, -0.57968396f
,
3095 0.63587302f
, -0.53137696f
, -0.02012792f
, 0.02111043f
, -0.14337072f
, 0.20772660f
,
3096 -0.10215330f
, 0.19041604f
, 0.01249063f
, -0.02748052f
, 0.00633162f
, 0.10696279f
,
3097 -0.44798949f
, 0.41573414f
, -0.00071454f
, 0.38108963f
, 0.03902940f
, -0.13923886f
,
3098 0.03606220f
, -0.00447360f
, 0.00492081f
, 0.05300967f
, -0.15545636f
, 0.08804068f
,
3099 0.05431554f
, 0.08070395f
, 0.01354355f
, -0.06900536f
, 0.02802683f
, -0.00285574f
,
3101 4.60838127f
, -1.49460280f
, 3.43758631f
, -1.37005258f
, 0.0f
, 0.0f
,
3102 0.0f
, 0.0f
, 0.0f
, 0.09624302f
, -0.65363091f
, 0.94703102f
,
3103 -0.46571958f
, 0.86811179f
, 0.05694513f
, -0.12528442f
, -0.0f
, 0.0f
,
3104 0.0f
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, 0.0f
,
3105 0.0f
, 0.01911653f
, -0.02102755f
, -0.22652012f
, 0.66429377f
, -0.37621412f
,
3106 -0.23210037f
, -0.34486291f
, -0.05787410f
, 0.29487267f
, -0.11976383f
, 0.01220309f
,
3108 0.61561823f
, -0.37264627f
, 0.85708636f
, -0.34159240f
, 0.24783641f
, -0.62184411f
,
3109 0.68211979f
, -0.57002378f
, -0.02159182f
, -0.06606984f
, 0.44871080f
, -0.65012693f
,
3110 0.31971166f
, -0.59594971f
, -0.03909224f
, 0.08600645f
, -0.00717023f
, -0.12112973f
,
3111 0.50732452f
, -0.47079703f
, 0.00080918f
, -0.43156394f
, -0.04419874f
, 0.15768069f
,
3112 -0.04083854f
, 0.01107814f
, -0.01218559f
, -0.13126975f
, 0.38496217f
, -0.21801829f
,
3113 -0.13450353f
, -0.19985008f
, -0.03353838f
, 0.17088045f
, -0.06940385f
, 0.00707176f
,
3115 2.98916292f
, -1.31008446f
, 3.01319408f
, -1.20091069f
, 0.35334525f
, -0.88657540f
,
3116 0.97251165f
, -0.81269407f
, -0.03078388f
, 0.03228654f
, -0.21927285f
, 0.31769949f
,
3117 -0.15623444f
, 0.29122451f
, 0.01910332f
, -0.04202903f
, 0.00968366f
, 0.16359015f
,
3118 -0.68516040f
, 0.63582867f
, -0.00109283f
, 0.58284295f
, 0.05969203f
, -0.21295355f
,
3119 0.05515395f
, -0.00684198f
, 0.00752595f
, 0.08107361f
, -0.23775679f
, 0.13465045f
,
3120 0.08307083f
, 0.12342957f
, 0.02071366f
, -0.10553761f
, 0.04286456f
, -0.00436760f
,
3122 6.20359039f
, -2.01196527f
, 4.62752008f
, -1.84430146f
, 0.0f
, 0.0f
,
3123 0.0f
, 0.0f
, 0.0f
, 0.12955792f
, -0.87988776f
, 1.27484941f
,
3124 -0.62693024f
, 1.16861200f
, 0.07665691f
, -0.16865209f
, 0.0f
, 0.0f
,
3125 0.0f
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, 0.0f
,
3126 0.0f
, 0.02573379f
, -0.02830632f
, -0.30493096f
, 0.89424169f
, -0.50644207f
,
3127 -0.31244281f
, -0.46423855f
, -0.07790744f
, 0.39694402f
, -0.16122055f
, 0.01642723f
,
3129 0.82871687f
, -0.50163919f
, 1.15377009f
, -0.45983589f
, 0.33362597f
, -0.83709794f
,
3130 0.91823828f
, -0.76733971f
, -0.02906591f
, -0.08894017f
, 0.60403383f
, -0.87517095f
,
3131 0.43038112f
, -0.80224001f
, -0.05262417f
, 0.11577792f
, -0.00965224f
, -0.16305926f
,
3132 0.68293691f
, -0.63376528f
, 0.00108928f
, -0.58095151f
, -0.05949831f
, 0.21226248f
,
3133 -0.05497497f
, 0.01491288f
, -0.01640368f
, -0.17670928f
, 0.51821834f
, -0.29348618f
,
3134 -0.18106246f
, -0.26902896f
, -0.04514782f
, 0.23003140f
, -0.09342826f
, 0.00951968f
,
3136 4.02387333f
, -1.76357520f
, 4.05622292f
, -1.61661065f
, 0.47565711f
, -1.19346702f
,
3137 1.30915034f
, -1.09401131f
, -0.04143983f
, 0.04346266f
, -0.29517499f
, 0.42767239f
,
3138 -0.21031560f
, 0.39203301f
, 0.02571601f
, -0.05657754f
, 0.01303570f
, 0.22021750f
,
3139 -0.92233127f
, 0.85592318f
, -0.00147112f
, 0.78459626f
, 0.08035465f
, -0.28666824f
,
3140 0.07424571f
, -0.00921036f
, 0.01013109f
, 0.10913756f
, -0.32005721f
, 0.18126021f
,
3141 0.11182612f
, 0.16615519f
, 0.02788378f
, -0.14206986f
, 0.05770230f
, -0.00587946f
, };
3144 FLOAT
*red_received
, *green_received
, *blue_received
;
3145 const FLOAT
*red_expected
, *green_expected
, *blue_expected
;
3146 FLOAT radius
, roffset
, goffset
, boffset
;
3148 { rout
, gout
, bout
, table
, &table
[108], &table
[216], 17.4f
, 1.01f
, 1.02f
, 1.03f
, },
3149 { rout
, gout
, bout
, &table
[36], &table
[144], &table
[252], 1.6f
, 1.01f
, 1.02f
, 1.03f
, },
3150 { rout
, gout
, bout
, &table
[72], &table
[180], &table
[288], -3.0f
, 1.01f
, 1.02f
, 1.03f
, },
3151 { rout
, rout
, rout
, &table
[216], &table
[216], &table
[216], 17.4f
, 1.03f
, 1.03f
, 1.03f
, },
3152 { rout
, rout
, bout
, &table
[108], &table
[108], &table
[216], 17.4, 1.02f
, 1.02f
, 1.03f
, },
3153 { rout
, gout
, gout
, table
, &table
[216], &table
[216], 17.4f
, 1.01f
, 1.03f
, 1.03f
, },
3154 { rout
, gout
, rout
, &table
[216], &table
[108], &table
[216], 17.4f
, 1.03f
, 1.02f
, 1.03f
, },
3155 /* D3DXSHEvalSphericalLight accepts NULL green or blue colour. */
3156 { rout
, NULL
, bout
, table
, NULL
, &table
[216], 17.4f
, 1.01f
, 0.0f
, 1.03f
, },
3157 { rout
, gout
, NULL
, table
, &table
[108], NULL
, 17.4f
, 1.01f
, 1.02f
, 0.0f
, },
3158 { rout
, NULL
, NULL
, table
, NULL
, NULL
, 17.4f
, 1.01f
, 0.0f
, 0.0f
, }, };
3160 unsigned int j
, l
, order
;
3162 dir
.x
= 1.1f
; dir
.y
= 1.2f
; dir
.z
= 2.76f
;
3164 for (l
= 0; l
< sizeof(test
) / sizeof(test
[0]); l
++)
3166 for (order
= D3DXSH_MINORDER
; order
<= D3DXSH_MAXORDER
; order
++)
3168 for (j
= 0; j
< 49; j
++)
3170 test
[l
].red_received
[j
] = 1.01f
+ j
;
3171 if (test
[l
].green_received
)
3172 test
[l
].green_received
[j
] = 1.02f
+ j
;
3173 if (test
[l
].blue_received
)
3174 test
[l
].blue_received
[j
] = 1.03f
+ j
;
3177 hr
= D3DXSHEvalSphericalLight(order
, &dir
, test
[l
].radius
, 1.7f
, 2.6f
, 3.5f
, test
[l
].red_received
, test
[l
].green_received
, test
[l
].blue_received
);
3178 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3180 for (j
= 0; j
< 49; j
++)
3182 if (j
>= order
* order
)
3183 expected
= j
+ test
[l
].roffset
;
3185 expected
= test
[l
].red_expected
[j
];
3186 ok(relative_error(expected
, test
[l
].red_received
[j
]) < 0.0005f
,
3187 "Red: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].red_received
[j
]);
3189 if (test
[l
].green_received
)
3191 if (j
>= order
* order
)
3192 expected
= j
+ test
[l
].goffset
;
3194 expected
= test
[l
].green_expected
[j
];
3195 ok(relative_error(expected
, test
[l
].green_received
[j
]) < 0.0005f
,
3196 "Green: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].green_received
[j
]);
3199 if (test
[l
].blue_received
)
3201 if (j
>= order
* order
)
3202 expected
= j
+ test
[l
].boffset
;
3204 expected
= test
[l
].blue_expected
[j
];
3205 ok(relative_error(expected
, test
[l
].blue_received
[j
]) < 0.0005f
,
3206 "Blue: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].blue_received
[j
]);
3212 /* D3DXSHEvalSphericalLight accepts order < D3DXSH_MINORDER or order > D3DXSH_MAXORDER. But tests in native windows show that the colour outputs are not set */
3213 hr
= D3DXSHEvalSphericalLight(7, &dir
, 17.4f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
3214 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3215 hr
= D3DXSHEvalSphericalLight(0, &dir
, 17.4f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
3216 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3217 hr
= D3DXSHEvalSphericalLight(1, &dir
, 17.4f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
3218 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3221 static void test_D3DXSHMultiply2(void)
3223 float a
[20], b
[20], c
[20];
3227 /* D3DXSHMultiply2() only modifies the first 4 elements of the array. */
3228 static const float expected
[20] =
3230 3.41859412f
, 1.69821072f
, 1.70385253f
, 1.70949447f
, 4.0f
, 5.0f
, 6.0f
,
3231 7.0f
, 8.0f
, 9.0f
, 10.0f
, 11.0f
, 12.0f
, 13.0f
,
3232 14.0f
, 15.0f
, 16.0f
, 17.0f
, 18.0f
, 19.0f
,
3235 for (i
= 0; i
< 20; i
++)
3237 a
[i
] = 1.0f
+ i
/ 100.0f
;
3238 b
[i
] = 3.0f
- i
/ 100.0f
;
3242 D3DXSHMultiply2(c
, a
, b
);
3243 for (i
= 0; i
< 20; i
++)
3245 equal
= compare_float(c
[i
], expected
[i
], 2);
3246 ok(equal
, "Expected[%u] = %.8e, received = %.8e.\n", i
, expected
[i
], c
[i
]);
3250 static void test_D3DXSHMultiply3(void)
3252 float a
[20], b
[20], c
[20];
3256 /* D3DXSHMultiply3() only modifies the first 9 elements of the array. */
3257 static const float expected
[20] =
3259 7.81391382e+00f
, 2.25605774e+00f
, 5.94839954e+00f
, 4.97089481e+00f
, 2.89985824e+00f
, 3.59894633e+00f
,
3260 1.72657156e+00f
, 5.57353783e+00f
, 6.22063160e-01f
, 9.00000000e+00f
, 1.00000000e+01f
, 1.10000000e+01f
,
3261 1.20000000e+01f
, 1.30000000e+01f
, 1.40000000e+01f
, 1.50000000e+01f
, 1.60000000e+01f
, 1.70000000e+01f
,
3262 1.80000000e+01f
, 1.90000000e+01f
,
3264 static const float expected_aliased
[20] =
3266 4.54092499e+02f
, 2.12640405e+00f
, 5.57040071e+00f
, 1.53303785e+01f
, 2.27960873e+01f
, 4.36041260e+01f
,
3267 4.27384138e+00f
, 1.75772034e+02f
, 2.37672729e+02f
, 1.09000003e+00f
, 1.10000002e+00f
, 1.11000001e+00f
,
3268 1.12000000e+00f
, 1.13000000e+00f
, 1.13999999e+00f
, 1.14999998e+00f
, 1.15999997e+00f
, 1.16999996e+00f
,
3269 1.17999995e+00f
, 1.19000006e+00f
,
3272 for (i
= 0; i
< 20; i
++)
3274 a
[i
] = 1.0f
+ i
/ 100.0f
;
3275 b
[i
] = 3.0f
- i
/ 100.0f
;
3279 D3DXSHMultiply3(c
, a
, b
);
3280 for (i
= 0; i
< 20; i
++)
3282 equal
= compare_float(c
[i
], expected
[i
], 4);
3283 ok(equal
, "Expected[%u] = %.8e, received = %.8e.\n", i
, expected
[i
], c
[i
]);
3286 memcpy(c
, a
, sizeof(c
));
3287 D3DXSHMultiply3(c
, c
, b
);
3288 for (i
= 0; i
< 20; i
++)
3290 equal
= compare_float(c
[i
], expected_aliased
[i
], 32);
3291 ok(equal
, "Expected[%u] = %.8e, received = %.8e.\n", i
, expected_aliased
[i
], c
[i
]);
3295 static void test_D3DXSHMultiply4(void)
3297 float a
[20], b
[20], c
[20];
3301 /* D3DXSHMultiply4() only modifies the first 16 elements of the array. */
3302 static const float expected
[] =
3305 1.41825991e+01f
, 2.61570334e+00f
, 1.28286009e+01f
, 9.82059574e+00f
, 3.03969646e+00f
, 4.53044176e+00f
,
3306 5.82058382e+00f
, 1.22498465e+01f
, 2.19434643e+00f
, 3.90015244e+00f
, 5.41660881e+00f
, 5.60181284e+00f
,
3307 9.59981740e-01f
, 7.03754997e+00f
, 3.62523031e+00f
, 4.63601470e-01f
, 1.60000000e+01f
, 1.70000000e+01f
,
3308 1.80000000e+01f
, 1.90000000e+01f
,
3310 -2.11441266e+05f
, -2.52915771e+03f
, -1.00233936e+04f
, -4.41277191e+02f
, -1.63994385e+02f
, -5.26305115e+02f
,
3311 2.96361875e+04f
, -3.93183081e+03f
, -1.35771113e+04f
, -3.97897388e+03f
, -1.03303418e+04f
, -1.37797871e+04f
,
3312 -1.66851094e+04f
, -4.49813750e+04f
, -7.32697422e+04f
, -9.52373359e+04f
, 1.60000000e+01f
, 1.70000000e+01f
,
3313 1.80000000e+01f
, 1.90000000e+01f
,
3315 2.36682415e-01f
, -7.17648506e-01f
, -1.80499524e-01f
, -7.71235973e-02f
, 1.44830629e-01f
, 5.73285699e-01f
,
3316 -3.37959230e-01f
, 5.56938872e-02f
, -4.42100227e-01f
, 1.47701755e-01f
, -5.51566519e-02f
, 8.43374059e-02f
,
3317 1.79876596e-01f
, 9.09878965e-03f
, 2.32199892e-01f
, 7.41420984e-02f
, 1.60000002e+00f
, 1.70000005e+00f
,
3318 1.80000007e+00f
, 1.89999998e+00f
,
3321 for (i
= 0; i
< 20; i
++)
3323 a
[i
] = 1.0f
+ i
/ 100.0f
;
3324 b
[i
] = 3.0f
- i
/ 100.0f
;
3328 D3DXSHMultiply4(c
, a
, b
);
3329 for (i
= 0; i
< 20; i
++)
3331 equal
= compare_float(c
[i
], expected
[i
], 16);
3332 ok(equal
, "Expected[%u] = %.8e, received = %.8e.\n", i
, expected
[i
], c
[i
]);
3335 for (i
= 0; i
< 20; i
++)
3337 b
[i
] = 3.0f
- i
/ 100.0f
;
3341 D3DXSHMultiply4(c
, c
, b
);
3342 for (i
= 0; i
< 20; i
++)
3344 equal
= compare_float(c
[i
], expected
[20 + i
], 32);
3345 ok(equal
, "Expected[%u] = %.8e, received = %.8e.\n", i
, expected
[20 + i
], c
[i
]);
3348 for (i
= 0; i
< 20; i
++)
3351 D3DXSHMultiply4(c
, c
, c
);
3352 for (i
= 0; i
< 20; i
++)
3354 equal
= compare_float(c
[i
], expected
[40 + i
], 8);
3355 ok(equal
, "Expected[%u] = %.8e, received = %.8e.\n", i
, expected
[40 + i
], c
[i
]);
3359 static void test_D3DXSHRotate(void)
3362 FLOAT expected
, in
[49], out
[49], *out_temp
, *received_ptr
;
3363 static const FLOAT table
[]=
3364 { /* Rotation around X-axis Pi/2 */
3365 1.01f
, -3.01f
, 2.01f
, 4.01f
, -8.01f
, -6.01f
,
3366 -11.307890f
, 5.01f
, -1.565839f
, 1.093598f
, -11.01f
, 19.833414f
,
3367 -15.268191f
, -19.004118f
, -3.364889f
, -9.562627f
, 12.099654f
, -0.272131f
,
3368 30.241013f
, 26.919991f
, 39.236877f
, -22.632446f
, 6.707388f
, -11.768282f
,
3369 3.443672f
, -6.07445f
, 11.61839f
, 1.527561f
, 37.89633f
, -56.9012f
,
3370 47.42289f
, 50.39153f
, 10.61819f
, 25.50101f
, 0.049241f
, 16.98330f
,
3372 1.01f
, -3.01f
, -3.01f
, 4.01f
, -8.01f
, -6.01f
, -11.307889f
, -8.01f
, 14.297919f
,
3373 /* Rotation around X-axis -Pi/2 */
3374 1.01f
, 3.01f
, -2.01f
, 4.01f
, 8.01f
, -6.01f
,
3375 -11.307890f
, -5.01f
, -1.565839f
, -1.093598f
, -11.01f
, -19.833414f
,
3376 15.268191f
, -19.004118f
, 3.364889f
, -9.562627f
, -12.099654f
, -0.272131f
,
3377 -30.241013f
, 26.919991f
, 39.236877f
, 22.632446f
, 6.707388f
, 11.768282f
,
3378 3.443672f
, 6.07445f
, 11.61839f
, -1.527561f
, 37.89633f
, 56.9012f
,
3379 -47.42289f
, 50.39153f
, -10.61819f
, 25.50101f
, -0.049248f
, 16.98330f
,
3381 1.01f
, 3.01f
, -3.01f
, 4.01f
, 8.01f
, -6.01f
, -11.307890f
, -8.01f
, 14.297919f
,
3382 /* Yaw Pi/3, Pitch Pi/4, Roll Pi/5 */
3383 1.01f
, 4.944899f
, 1.442301f
, 1.627281f
, 0.219220f
, 10.540824f
,
3384 -9.136903f
, 2.763750f
, -7.30904f
, -5.875721f
, 5.303124f
, -8.682154f
,
3385 -25.683384f
, 1.680279f
, -18.808388f
, 7.653656f
, 16.939133f
, -17.328018f
,
3386 14.629795f
, -54.467102f
, -12.231035f
, -4.089857f
, -9.444222f
, 3.056035f
,
3387 0.179257f
, -10.041875f
, 23.090092f
, -23.188709f
, 11.727098f
, -65.183090f
,
3388 48.671577f
, -15.073209f
, 38.793171f
, -26.039536f
, 6.192769f
, -17.672247f
,
3390 1.01f
, 4.944899f
, -0.891142f
, 4.607695f
, 0.219218f
, 10.773325f
,
3391 -8.204769f
, 13.563829f
, -12.007767f
,
3392 /* Rotation around Z-axis Pi/6 */
3393 1.01f
, 3.745711f
, 3.01f
, 2.467762f
, 10.307889f
, 9.209813f
,
3394 7.01f
, 3.931864f
, 0.166212f
, 16.01f
, 18.504042f
, 17.405966f
,
3395 13.01f
, 6.128016f
, -2.029941f
, -10.01f
, 13.154292f
, 24.01f
,
3396 29.432245f
, 28.334167f
, 21.01f
, 9.056221f
, -4.958143f
, -18.01f
,
3397 -27.236094f
, -4.520332f
, 16.814543f
, 34.01f
, 43.092495f
, 41.994423f
,
3398 31.01f
, 12.716471f
, -8.618400f
, -28.01f
, -40.896347f
, -44.190571,
3400 1.01f
, 3.745711f
, 3.01f
, 1.599906f
, 10.307889f
, 9.209813f
,
3401 7.01f
, 2.331957f
, -4.421894f
, };
3402 unsigned int i
, j
, l
, order
;
3404 D3DXMatrixRotationX(&m
[0], -D3DX_PI
/ 2.0f
);
3405 D3DXMatrixRotationX(&m
[1], D3DX_PI
/ 2.0f
);
3406 D3DXMatrixRotationYawPitchRoll(&m
[2], D3DX_PI
/ 3.0f
, D3DX_PI
/ 4.0f
, D3DX_PI
/ 5.0f
);
3407 D3DXMatrixRotationZ(&m
[3], D3DX_PI
/ 6.0f
);
3409 for (l
= 0; l
< 2; l
++)
3416 for (j
= 0; j
< 4; j
++)
3418 for (order
= 0; order
<= D3DXSH_MAXORDER
; order
++)
3420 for (i
= 0; i
< 49; i
++)
3422 out
[i
] = ( i
+ 1.0f
) * ( i
+ 1.0f
);
3426 received_ptr
= D3DXSHRotate(out_temp
, order
, &m
[j
], in
);
3427 ok(received_ptr
== out_temp
, "Order %u, expected %p, received %p\n", order
, out
, received_ptr
);
3429 for (i
= 0; i
< 49; i
++)
3431 if ((i
> 0) && ((i
>= order
* order
) || (order
> D3DXSH_MAXORDER
)))
3434 expected
= ( i
+ 1.0f
) * ( i
+ 1.0f
);
3436 expected
= i
+ 1.01f
;
3438 else if ((l
== 0) || (order
> 3))
3439 expected
= table
[45 * j
+ i
];
3441 expected
= table
[45 * j
+ 36 +i
];
3442 ok(relative_error(out_temp
[i
], expected
) < admitted_error
,
3443 "Order %u index %u, expected %f, received %f\n", order
, i
, expected
, out_temp
[i
]);
3450 static void test_D3DXSHRotateZ(void)
3452 unsigned int end
, i
, j
, l
, order
, square
;
3453 FLOAT expected
, in
[49], out
[49], *out_temp
, *received_ptr
;
3454 const FLOAT angle
[] = { D3DX_PI
/ 3.0f
, -D3DX_PI
/ 3.0f
, 4.0f
* D3DX_PI
/ 3.0f
, }, table
[] =
3455 { /* Angle = D3DX_PI / 3.0f */
3456 1.01f
, 4.477762f
, 3.010000f
, 0.264289f
, 5.297888f
, 9.941864f
,
3457 7.010000f
, -1.199813f
, -8.843789f
, -10.010002f
, 7.494040f
, 18.138016f
,
3458 13.010000, -3.395966f
, -17.039942f
, -16.009998f
, -30.164297f
, -18.010004f
,
3459 10.422242f
, 29.066219f
, 21.010000f
, -6.324171f
, -27.968145f
, -24.009998f
,
3460 2.226099f
, -18.180565, -43.824551f
, -28.010004f
, 14.082493f
, 42.726471f
,
3461 31.010000f
, -9.984426f
, -41.628399f
, -34.009995f
, 5.886358f
, 40.530331f
,
3463 1.01f
, 4.477762f
, 0.0f
, -5.816784f
, 5.297888f
, 6.936864f
,
3464 0.0f
, -9.011250f
, -2.294052f
, -10.010002f
, 12.999042f
, 12.133017f
,
3465 0.0f
, -15.761250f
, -5.628748f
, 0.0f
, -30.164297f
, 0.0f
,
3466 19.927244f
, 19.061220f
, 0.0f
, -24.761251f
, -8.628748f
, 0.0f
,
3467 -13.061530f
, -18.180565f
, -30.319553f
, 0.0f
, 28.587496f
, 27.721474f
,
3468 0.0f
, -36.011253f
, -12.378746f
, 0.0f
, -13.128758f
, -23.617250f
,
3470 1.010000f
, 3.977762f
, 3.977762f
, 1.114195f
, 7.245791f
, 10.559759f
,
3471 10.559759f
, -0.995160f
, -0.467341f
, 0.467339f
, 12.765371f
, 18.515701f
,
3472 18.515701f
, -1.797287f
, 0.493916f
, -0.493916f
, -21.412342f
, 21.412338f
,
3473 9.221072f
, 23.671757f
, 23.671757f
, 3.850195f
, -20.468727f
, 20.468723f
,
3474 -10.662103f
, -36.516628f
, -12.061245f
, 12.061240f
, 22.556875f
, 38.999908f
,
3475 38.999908f
, -0.034875f
, -10.427902f
, 10.427900f
, -36.838284f
, -27.652803f
,
3476 /* Angle = -D3DX_PI / 3.0f */
3477 1.01f
, -2.467762f
, 3.010000f
, 3.745711f
, -10.307890f
, -3.931864f
,
3478 7.010000f
, 9.209813f
, -0.166214f
, -10.010002f
, -18.504044f
, -6.128017f
,
3479 13.010000f
, 17.405966f
, 2.029938f
, -16.009998f
, 13.154303f
, -18.010004f
,
3480 -29.432247f
, -9.056221f
, 21.010000f
, 28.334169f
, 4.958139f
, -24.010002f
,
3481 -27.236092f
, 44.190582f
, 16.814558f
, -28.009996f
, -43.092499f
, -12.716474f
,
3482 31.010000f
, 41.994423f
, 8.618393f
, -34.010002f
, -40.896347f
, -4.520310f
,
3484 1.01f
, -2.467762f
, 0.0f
, -3.205718f
, -10.307890f
, -6.936864f
,
3485 0.0f
, -9.011250f
, -4.463446f
, -10.009998f
, -12.999042f
, -12.133017f
,
3486 0.0f
, -15.761250f
, -5.628748f
, 0.0f
, 13.154303f
, 0.0f
,
3487 -19.927244f
, -19.061220f
, 0.0f
, -24.761251f
, -8.628748f
, 0.0f
,
3488 -5.695983f
, 44.190582f
, 30.319553f
, 0.0f
, -28.587496f
, -27.721474f
,
3489 0.0f
, -36.011253f
, -12.378746f
, 0.0f
, -13.128758f
, -57.405258f
,
3491 1.010000f
, -2.967762f
, -2.967762f
, -0.609195f
, -7.498291f
, -10.686009f
,
3492 -10.686009f
, -11.836716f
, 5.390780f
, -5.390779f
, -10.303651f
, -17.284842f
,
3493 -17.284842f
, -17.565643f
, 4.114273f
, -4.114273f
, 23.716436f
, -23.716433f
,
3494 -8.069025f
, -23.095732f
, -23.095732f
, -18.535847f
, -11.271107f
, 11.271104f
,
3495 -2.072484f
, 30.149330f
, 15.244893f
, -15.244888f
, -20.965050f
, -38.203999f
,
3496 -38.203999f
, -37.258266f
, 5.426677f
, -5.426679f
, -23.396751f
, -9.903559f
,
3497 /* Angle = 4.0f * D3DX_PI / 3.0f */
3498 1.01f
, -4.477762f
, 3.010000f
, -0.264289f
, 5.297887f
, -9.941864f
,
3499 7.010000f
, 1.199814f
, -8.843788f
, 10.010004f
, 7.494038f
, -18.138016f
,
3500 13.010000f
, 3.395967f
, -17.039940f
, 16.009996f
, -30.164293f
, 18.010006f
,
3501 10.422239f
, -29.066219f
, 21.010000f
, 6.324172f
, -27.968143f
, 24.009993f
,
3502 2.226105f
, 18.180552f
, -43.824543f
, 28.010008f
, 14.082489f
, -42.726471f
,
3503 31.010000f
, 9.984427f
, -41.628399f
, 34.009987f
, 5.886366f
, -40.530327f
,
3505 1.01f
, -4.477762f
, 0.0f
, -1.938928f
, 5.297887f
, -6.936864f
,
3506 0.0f
, -3.003751f
, -2.294051f
, 10.010004f
, 12.999040f
, -12.133017f
,
3507 0.0f
, -5.253751f
, -5.628747f
, 0.0f
, -30.164293f
, 0.0f
,
3508 19.927242f
, -19.061220f
, 0.0f
, -8.253753f
, -8.628746f
, 0.0f
,
3509 -13.061535f
, 18.180552f
, -30.319553f
, 0.0f
, 28.587492f
, -27.721474f
,
3510 0.0f
, -12.003753f
, -12.378742f
, 0.0f
, -13.128765f
, -7.872400f
,
3512 1.010000f
, -3.977762f
, -3.977762f
, 2.863566f
, 6.371104f
, -10.122416f
,
3513 -10.122416f
, 10.578746f
, -7.769295f
, -7.769290f
, 16.883686f
, -20.574858f
,
3514 -20.574858f
, 24.909130f
, -5.726166f
, -5.726164f
, -18.796221f
, -18.796211f
,
3515 29.325350f
, -33.723892f
, -33.723892f
, 42.258442f
, -4.851232f
, -4.851226f
,
3516 -2.533393f
, 32.452259f
, -46.545670f
, -46.545654f
, 51.860325f
, -53.651630f
,
3517 -53.651630f
, 71.738174f
, 4.440616f
, 4.440629f
, 25.884174f
, -10.748116f
, };
3519 for (l
= 0; l
< 3; l
++)
3524 out_temp
= &in
[l
- 1];
3531 for (j
= 0; j
< 3; j
++)
3533 for (order
= 0; order
<= D3DXSH_MAXORDER
+ 1; order
++)
3535 for (i
= 0; i
< 49; i
++)
3537 out
[i
] = ( i
+ 1.0f
) * ( i
+ 1.0f
);
3541 received_ptr
= D3DXSHRotateZ(out_temp
, order
, angle
[j
], in
);
3542 ok(received_ptr
== out_temp
, "angle %f, order %u, expected %p, received %p\n", angle
[j
], order
, out_temp
, received_ptr
);
3544 for (i
= 0; i
< end
; i
++)
3546 /* order = 0 or order = 1 behaves like order = D3DXSH_MINORDER */
3547 square
= (order
<= D3DXSH_MINORDER
) ? D3DXSH_MINORDER
* D3DXSH_MINORDER
: order
* order
;
3548 if (i
>= square
|| ((order
>= D3DXSH_MAXORDER
) && (i
>= D3DXSH_MAXORDER
* D3DXSH_MAXORDER
)))
3550 expected
= i
+ l
+ 0.01f
;
3552 expected
= ( i
+ 1.0f
) * ( i
+ 1.0f
);
3554 expected
= table
[36 * (l
+ 3 * j
) + i
];
3555 ok(relative_error(expected
, out_temp
[i
]) < admitted_error
, "angle %f, order %u index %u, expected %f, received %f\n", angle
[j
], order
, i
, expected
, out_temp
[i
]);
3562 static void test_D3DXSHScale(void)
3564 unsigned int i
, order
;
3565 FLOAT a
[49], b
[49], expected
, *received_array
;
3567 for (i
= 0; i
< 49; i
++)
3573 for (order
= 0; order
<= D3DXSH_MAXORDER
+ 1; order
++)
3575 received_array
= D3DXSHScale(b
, order
, a
, 5.0f
);
3576 ok(received_array
== b
, "Expected %p, received %p\n", b
, received_array
);
3578 for (i
= 0; i
< 49; i
++)
3580 if (i
< order
* order
)
3581 expected
= 5.0f
* a
[i
];
3582 /* D3DXSHScale does not modify the elements of the array after the order * order-th element */
3585 ok(relative_error(b
[i
], expected
) < admitted_error
, "order %d, element %d, expected %f, received %f\n", order
, i
, expected
, b
[i
]);
3596 D3DXQuaternionTest();
3600 test_matrix_stack();
3601 test_Matrix_AffineTransformation2D();
3602 test_Matrix_Decompose();
3603 test_Matrix_Transformation2D();
3604 test_D3DXVec_Array();
3605 test_D3DXFloat_Array();
3608 test_D3DXSHEvalConeLight();
3609 test_D3DXSHEvalDirection();
3610 test_D3DXSHEvalDirectionalLight();
3611 test_D3DXSHEvalHemisphereLight();
3612 test_D3DXSHEvalSphericalLight();
3613 test_D3DXSHMultiply2();
3614 test_D3DXSHMultiply3();
3615 test_D3DXSHMultiply4();
3616 test_D3DXSHRotate();
3617 test_D3DXSHRotateZ();