2 * Copyright 2007 David Adam
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/test.h"
24 #define admitted_error 0.00001f
26 #define expect_color(expectedcolor,gotcolor) ok((fabs(expectedcolor.r-gotcolor.r)<admitted_error)&&(fabs(expectedcolor.g-gotcolor.g)<admitted_error)&&(fabs(expectedcolor.b-gotcolor.b)<admitted_error)&&(fabs(expectedcolor.a-gotcolor.a)<admitted_error),"Expected Color= (%f, %f, %f, %f)\n , Got Color= (%f, %f, %f, %f)\n", expectedcolor.r, expectedcolor.g, expectedcolor.b, expectedcolor.a, gotcolor.r, gotcolor.g, gotcolor.b, gotcolor.a);
28 #define expect_vec(expectedvec,gotvec) ok((fabs(expectedvec.x-gotvec.x)<admitted_error)&&(fabs(expectedvec.y-gotvec.y)<admitted_error),"Expected Vector= (%f, %f)\n , Got Vector= (%f, %f)\n", expectedvec.x, expectedvec.y, gotvec.x, gotvec.y);
30 #define expect_vec3(expectedvec,gotvec) ok((fabs(expectedvec.x-gotvec.x)<admitted_error)&&(fabs(expectedvec.y-gotvec.y)<admitted_error)&&(fabs(expectedvec.z-gotvec.z)<admitted_error),"Expected Vector= (%f, %f, %f)\n , Got Vector= (%f, %f, %f)\n", expectedvec.x, expectedvec.y, expectedvec.z, gotvec.x, gotvec.y, gotvec.z);
32 #define expect_vec4(expectedvec,gotvec) ok((fabs(expectedvec.x-gotvec.x)<admitted_error)&&(fabs(expectedvec.y-gotvec.y)<admitted_error)&&(fabs(expectedvec.z-gotvec.z)<admitted_error)&&(fabs(expectedvec.w-gotvec.w)<admitted_error),"Expected Vector= (%f, %f, %f, %f)\n , Got Vector= (%f, %f, %f, %f)\n", expectedvec.x, expectedvec.y, expectedvec.z, expectedvec.w, gotvec.x, gotvec.y, gotvec.z, gotvec.w);
34 static void D3DXColorTest(void)
36 D3DXCOLOR color
, color1
, color2
, expected
, got
;
37 LPD3DXCOLOR funcpointer
;
40 color
.r
= 0.2f
; color
.g
= 0.75f
; color
.b
= 0.41f
; color
.a
= 0.93f
;
41 color1
.r
= 0.6f
; color1
.g
= 0.55f
; color1
.b
= 0.23f
; color1
.a
= 0.82f
;
42 color2
.r
= 0.3f
; color2
.g
= 0.5f
; color2
.b
= 0.76f
; color2
.a
= 0.11f
;
45 /*_______________D3DXColorAdd________________*/
46 expected
.r
= 0.9f
; expected
.g
= 1.05f
; expected
.b
= 0.99f
, expected
.a
= 0.93f
;
47 D3DXColorAdd(&got
,&color1
,&color2
);
48 expect_color(expected
,got
);
49 /* Test the NULL case */
50 funcpointer
= D3DXColorAdd(&got
,NULL
,&color2
);
51 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
52 funcpointer
= D3DXColorAdd(NULL
,NULL
,&color2
);
53 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
54 funcpointer
= D3DXColorAdd(NULL
,NULL
,NULL
);
55 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
57 /*_______________D3DXColorLerp________________*/
58 expected
.r
= 0.32f
; expected
.g
= 0.69f
; expected
.b
= 0.356f
; expected
.a
= 0.897f
;
59 D3DXColorLerp(&got
,&color
,&color1
,scale
);
60 expect_color(expected
,got
);
61 /* Test the NULL case */
62 funcpointer
= D3DXColorLerp(&got
,NULL
,&color1
,scale
);
63 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
64 funcpointer
= D3DXColorLerp(NULL
,NULL
,&color1
,scale
);
65 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
66 funcpointer
= D3DXColorLerp(NULL
,NULL
,NULL
,scale
);
67 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
69 /*_______________D3DXColorModulate________________*/
70 expected
.r
= 0.18f
; expected
.g
= 0.275f
; expected
.b
= 0.1748f
; expected
.a
= 0.0902f
;
71 D3DXColorModulate(&got
,&color1
,&color2
);
72 expect_color(expected
,got
);
73 /* Test the NULL case */
74 funcpointer
= D3DXColorModulate(&got
,NULL
,&color2
);
75 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
76 funcpointer
= D3DXColorModulate(NULL
,NULL
,&color2
);
77 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
78 funcpointer
= D3DXColorModulate(NULL
,NULL
,NULL
);
79 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
81 /*_______________D3DXColorNegative________________*/
82 expected
.r
= 0.8f
; expected
.g
= 0.25f
; expected
.b
= 0.59f
; expected
.a
= 0.93f
;
83 D3DXColorNegative(&got
,&color
);
84 expect_color(got
,expected
);
85 /* Test the greater than 1 case */
86 color1
.r
= 0.2f
; color1
.g
= 1.75f
; color1
.b
= 0.41f
; color1
.a
= 0.93f
;
87 expected
.r
= 0.8f
; expected
.g
= -0.75f
; expected
.b
= 0.59f
; expected
.a
= 0.93f
;
88 D3DXColorNegative(&got
,&color1
);
89 expect_color(got
,expected
);
90 /* Test the negative case */
91 color1
.r
= 0.2f
; color1
.g
= -0.75f
; color1
.b
= 0.41f
; color1
.a
= 0.93f
;
92 expected
.r
= 0.8f
; expected
.g
= 1.75f
; expected
.b
= 0.59f
; expected
.a
= 0.93f
;
93 D3DXColorNegative(&got
,&color1
);
94 expect_color(got
,expected
);
95 /* Test the NULL case */
96 funcpointer
= D3DXColorNegative(&got
,NULL
);
97 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
98 funcpointer
= D3DXColorNegative(NULL
,NULL
);
99 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
101 /*_______________D3DXColorScale________________*/
102 expected
.r
= 0.06f
; expected
.g
= 0.225f
; expected
.b
= 0.123f
; expected
.a
= 0.279f
;
103 D3DXColorScale(&got
,&color
,scale
);
104 expect_color(expected
,got
);
105 /* Test the NULL case */
106 funcpointer
= D3DXColorScale(&got
,NULL
,scale
);
107 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
108 funcpointer
= D3DXColorScale(NULL
,NULL
,scale
);
109 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
111 /*_______________D3DXColorSubtract_______________*/
112 expected
.r
= -0.1f
; expected
.g
= 0.25f
; expected
.b
= -0.35f
, expected
.a
= 0.82f
;
113 D3DXColorSubtract(&got
,&color
,&color2
);
114 expect_color(expected
,got
);
115 /* Test the NULL case */
116 funcpointer
= D3DXColorSubtract(&got
,NULL
,&color2
);
117 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
118 funcpointer
= D3DXColorSubtract(NULL
,NULL
,&color2
);
119 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
120 funcpointer
= D3DXColorSubtract(NULL
,NULL
,NULL
);
121 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
124 static void D3DXMatrixTest(void)
129 /*____________D3DXMatrixIsIdentity______________*/
130 U(mat
).m
[0][1] = 0.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
131 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 0.0f
; U(mat
).m
[1][3] = 0.0f
;
132 U(mat
).m
[2][0] = 0.0f
; U(mat
).m
[2][1] = 0.0f
; U(mat
).m
[2][3] = 0.0f
;
133 U(mat
).m
[3][0] = 0.0f
; U(mat
).m
[3][1] = 0.0f
; U(mat
).m
[3][2] = 0.0f
;
134 U(mat
).m
[0][0] = 1.0f
; U(mat
).m
[1][1] = 1.0f
; U(mat
).m
[2][2] = 1.0f
;
135 U(mat
).m
[3][3] = 1.0f
;
137 got
= D3DXMatrixIsIdentity(&mat
);
138 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
139 D3DXMatrixIdentity(&mat
);
141 got
= D3DXMatrixIsIdentity(&mat
);
142 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
143 /* Test the NULL case */
145 got
= D3DXMatrixIsIdentity(NULL
);
146 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
149 static void D3DXPlaneTest(void)
155 plane
.a
= -3.0f
; plane
.b
= -1.0f
; plane
.c
= 4.0f
; plane
.d
= 7.0f
;
156 vec
.x
= 2.0f
; vec
.y
= 5.0f
; vec
.z
= -6.0f
; vec
.w
= 11.0f
;
158 /*_______________D3DXPlaneDot________________*/
160 got
= D3DXPlaneDot(&plane
,&vec
),
161 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
163 got
= D3DXPlaneDot(NULL
,&vec
),
164 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
166 got
= D3DXPlaneDot(NULL
,NULL
),
167 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
169 /*_______________D3DXPlaneDotCoord________________*/
171 got
= D3DXPlaneDotCoord(&plane
,&vec
),
172 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
174 got
= D3DXPlaneDotCoord(NULL
,&vec
),
175 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
177 got
= D3DXPlaneDotCoord(NULL
,NULL
),
178 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
180 /*_______________D3DXPlaneDotNormal______________*/
182 got
= D3DXPlaneDotNormal(&plane
,&vec
),
183 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
185 got
= D3DXPlaneDotNormal(NULL
,&vec
),
186 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
188 got
= D3DXPlaneDotNormal(NULL
,NULL
),
189 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
192 static void D3X8QuaternionTest(void)
194 D3DXQUATERNION expectedquat
, gotquat
, nul
, q
, r
, s
;
195 LPD3DXQUATERNION funcpointer
;
197 BOOL expectedbool
, gotbool
;
199 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
; nul
.w
= 0.0f
;
200 q
.x
= 1.0f
, q
.y
= 2.0f
; q
.z
= 4.0f
; q
.w
= 10.0f
;
201 r
.x
= -3.0f
; r
.y
= 4.0f
; r
.z
= -5.0f
; r
.w
= 7.0;
203 /*_______________D3DXQuaternionConjugate________________*/
204 expectedquat
.x
= -1.0f
; expectedquat
.y
= -2.0f
; expectedquat
.z
= -4.0f
; expectedquat
.w
= 10.0f
;
205 D3DXQuaternionConjugate(&gotquat
,&q
);
206 expect_vec4(expectedquat
,gotquat
);
207 /* Test the NULL case */
208 funcpointer
= D3DXQuaternionConjugate(&gotquat
,NULL
);
209 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
210 funcpointer
= D3DXQuaternionConjugate(NULL
,NULL
);
211 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
213 /*_______________D3DXQuaternionDot______________________*/
215 got
= D3DXQuaternionDot(&q
,&r
);
216 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
217 /* Tests the case NULL */
219 got
= D3DXQuaternionDot(NULL
,&r
);
220 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
222 got
= D3DXQuaternionDot(NULL
,NULL
);
223 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
225 /*_______________D3DXQuaternionIdentity________________*/
226 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 1.0f
;
227 D3DXQuaternionIdentity(&gotquat
);
228 expect_vec4(expectedquat
,gotquat
);
229 /* Test the NULL case */
230 funcpointer
= D3DXQuaternionIdentity(NULL
);
231 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
233 /*_______________D3DXQuaternionIsIdentity________________*/
234 s
.x
= 0.0f
; s
.y
= 0.0f
; s
.z
= 0.0f
; s
.w
= 1.0f
;
236 gotbool
= D3DXQuaternionIsIdentity(&s
);
237 ok( expectedbool
== gotbool
, "Expected boolean : %d, Got bool : %d\n", expectedbool
, gotbool
);
238 s
.x
= 2.3f
; s
.y
= -4.2f
; s
.z
= 1.2f
; s
.w
=0.2f
;
239 expectedbool
= FALSE
;
240 gotbool
= D3DXQuaternionIsIdentity(&q
);
241 ok( expectedbool
== gotbool
, "Expected boolean : %d, Got bool : %d\n", expectedbool
, gotbool
);
242 /* Test the NULL case */
243 gotbool
= D3DXQuaternionIsIdentity(NULL
);
244 ok(gotbool
== FALSE
, "Expected boolean: %d, Got boolean: %d\n", FALSE
, gotbool
);
246 /*_______________D3DXQuaternionLength__________________________*/
248 got
= D3DXQuaternionLength(&q
);
249 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
250 /* Tests the case NULL */
252 got
= D3DXQuaternionLength(NULL
);
253 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
255 /*_______________D3DXQuaternionLengthSq________________________*/
257 got
= D3DXQuaternionLengthSq(&q
);
258 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
259 /* Tests the case NULL */
261 got
= D3DXQuaternionLengthSq(NULL
);
262 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
264 /*_______________D3DXQuaternionNormalize________________________*/
265 expectedquat
.x
= 1.0f
/11.0f
; expectedquat
.y
= 2.0f
/11.0f
; expectedquat
.z
= 4.0f
/11.0f
; expectedquat
.w
= 10.0f
/11.0f
;
266 D3DXQuaternionNormalize(&gotquat
,&q
);
267 expect_vec4(expectedquat
,gotquat
);
268 /* Test the nul quaternion */
269 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.0f
;
270 D3DXQuaternionNormalize(&gotquat
,&nul
);
271 expect_vec4(expectedquat
,gotquat
);
274 static void D3X8Vector2Test(void)
276 D3DXVECTOR2 expectedvec
, gotvec
, nul
, u
, v
, w
, x
;
277 LPD3DXVECTOR2 funcpointer
;
278 D3DXVECTOR4 expectedtrans
, gottrans
;
280 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
282 nul
.x
= 0.0f
; nul
.y
= 0.0f
;
283 u
.x
= 3.0f
; u
.y
= 4.0f
;
284 v
.x
= -7.0f
; v
.y
= 9.0f
;
285 w
.x
= 4.0f
; w
.y
= -3.0f
;
286 x
.x
= 2.0f
; x
.y
= -11.0f
;
288 mat
.m
[0][0] = 1.0f
; mat
.m
[0][1] = 2.0f
; mat
.m
[0][2] = 3.0f
; mat
.m
[0][3] = 4.0f
;
289 mat
.m
[1][0] = 5.0f
; mat
.m
[1][1] = 6.0f
; mat
.m
[1][2] = 7.0f
; mat
.m
[1][3] = 8.0f
;
290 mat
.m
[2][0] = 9.0f
; mat
.m
[2][1] = 10.0f
; mat
.m
[2][2] = 11.0f
; mat
.m
[2][3] = 12.0f
;
291 mat
.m
[3][0] = 13.0f
; mat
.m
[3][1] = 14.0f
; mat
.m
[3][2] = 15.0f
; mat
.m
[3][3] = 16.0f
;
293 coeff1
= 2.0f
; coeff2
= 5.0f
;
296 /*_______________D3DXVec2Add__________________________*/
297 expectedvec
.x
= -4.0f
; expectedvec
.y
= 13.0f
;
298 D3DXVec2Add(&gotvec
,&u
,&v
);
299 expect_vec(expectedvec
,gotvec
);
300 /* Tests the case NULL */
301 funcpointer
= D3DXVec2Add(&gotvec
,NULL
,&v
);
302 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
303 funcpointer
= D3DXVec2Add(NULL
,NULL
,NULL
);
304 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
306 /*_______________D3DXVec2BaryCentric___________________*/
307 expectedvec
.x
= -12.0f
; expectedvec
.y
= -21.0f
;
308 D3DXVec2BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
309 expect_vec(expectedvec
,gotvec
);
311 /*_______________D3DXVec2CatmullRom____________________*/
312 expectedvec
.x
= 5820.25f
; expectedvec
.y
= -3654.5625f
;
313 D3DXVec2CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
314 expect_vec(expectedvec
,gotvec
);
316 /*_______________D3DXVec2CCW__________________________*/
318 got
= D3DXVec2CCW(&u
,&v
);
319 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
320 /* Tests the case NULL */
322 got
= D3DXVec2CCW(NULL
,&v
);
323 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
325 got
= D3DXVec2CCW(NULL
,NULL
);
326 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
328 /*_______________D3DXVec2Dot__________________________*/
330 got
= D3DXVec2Dot(&u
,&v
);
331 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
332 /* Tests the case NULL */
334 got
= D3DXVec2Dot(NULL
,&v
);
335 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
337 got
= D3DXVec2Dot(NULL
,NULL
);
338 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
340 /*_______________D3DXVec2Hermite__________________________*/
341 expectedvec
.x
= 2604.625f
; expectedvec
.y
= -4533.0f
;
342 D3DXVec2Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
343 expect_vec(expectedvec
,gotvec
);
345 /*_______________D3DXVec2Length__________________________*/
347 got
= D3DXVec2Length(&u
);
348 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
349 /* Tests the case NULL */
351 got
= D3DXVec2Length(NULL
);
352 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
354 /*_______________D3DXVec2LengthSq________________________*/
356 got
= D3DXVec2LengthSq(&u
);
357 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
358 /* Tests the case NULL */
360 got
= D3DXVec2LengthSq(NULL
);
361 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
363 /*_______________D3DXVec2Lerp__________________________*/
364 expectedvec
.x
= 68.0f
; expectedvec
.y
= -28.5f
;
365 D3DXVec2Lerp(&gotvec
,&u
,&v
,scale
);
366 expect_vec(expectedvec
,gotvec
);
367 /* Tests the case NULL */
368 funcpointer
= D3DXVec2Lerp(&gotvec
,NULL
,&v
,scale
);
369 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
370 funcpointer
= D3DXVec2Lerp(NULL
,NULL
,NULL
,scale
);
371 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
373 /*_______________D3DXVec2Maximize__________________________*/
374 expectedvec
.x
= 3.0f
; expectedvec
.y
= 9.0f
;
375 D3DXVec2Maximize(&gotvec
,&u
,&v
);
376 expect_vec(expectedvec
,gotvec
);
377 /* Tests the case NULL */
378 funcpointer
= D3DXVec2Maximize(&gotvec
,NULL
,&v
);
379 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
380 funcpointer
= D3DXVec2Maximize(NULL
,NULL
,NULL
);
381 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
383 /*_______________D3DXVec2Minimize__________________________*/
384 expectedvec
.x
= -7.0f
; expectedvec
.y
= 4.0f
;
385 D3DXVec2Minimize(&gotvec
,&u
,&v
);
386 expect_vec(expectedvec
,gotvec
);
387 /* Tests the case NULL */
388 funcpointer
= D3DXVec2Minimize(&gotvec
,NULL
,&v
);
389 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
390 funcpointer
= D3DXVec2Minimize(NULL
,NULL
,NULL
);
391 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
393 /*_______________D3DXVec2Normalize_________________________*/
394 expectedvec
.x
= 0.6f
; expectedvec
.y
= 0.8f
;
395 D3DXVec2Normalize(&gotvec
,&u
);
396 expect_vec(expectedvec
,gotvec
);
397 /* Test the nul vector */
398 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
;
399 D3DXVec2Normalize(&gotvec
,&nul
);
400 expect_vec(expectedvec
,gotvec
);
402 /*_______________D3DXVec2Scale____________________________*/
403 expectedvec
.x
= -19.5f
; expectedvec
.y
= -26.0f
;
404 D3DXVec2Scale(&gotvec
,&u
,scale
);
405 expect_vec(expectedvec
,gotvec
);
406 /* Tests the case NULL */
407 funcpointer
= D3DXVec2Scale(&gotvec
,NULL
,scale
);
408 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
409 funcpointer
= D3DXVec2Scale(NULL
,NULL
,scale
);
410 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
412 /*_______________D3DXVec2Subtract__________________________*/
413 expectedvec
.x
= 10.0f
; expectedvec
.y
= -5.0f
;
414 D3DXVec2Subtract(&gotvec
,&u
,&v
);
415 expect_vec(expectedvec
,gotvec
);
416 /* Tests the case NULL */
417 funcpointer
= D3DXVec2Subtract(&gotvec
,NULL
,&v
);
418 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
419 funcpointer
= D3DXVec2Subtract(NULL
,NULL
,NULL
);
420 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
422 /*_______________D3DXVec2Transform_______________________*/
423 expectedtrans
.x
= 36.0f
; expectedtrans
.y
= 44.0f
; expectedtrans
.z
= 52.0f
; expectedtrans
.w
= 60.0f
;
424 D3DXVec2Transform(&gottrans
,&u
,&mat
);
425 expect_vec4(expectedtrans
,gottrans
);
428 static void D3X8Vector3Test(void)
430 D3DXVECTOR3 expectedvec
, gotvec
, nul
, u
, v
, w
, x
;
431 LPD3DXVECTOR3 funcpointer
;
432 D3DXVECTOR4 expectedtrans
, gottrans
;
434 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
436 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
;
437 u
.x
= 9.0f
; u
.y
= 6.0f
; u
.z
= 2.0f
;
438 v
.x
= 2.0f
; v
.y
= -3.0f
; v
.z
= -4.0;
439 w
.x
= 3.0f
; w
.y
= -5.0f
; w
.z
= 7.0f
;
440 x
.x
= 4.0f
; x
.y
= 1.0f
; x
.z
= 11.0f
;
442 mat
.m
[0][0] = 1.0f
; mat
.m
[0][1] = 2.0f
; mat
.m
[0][2] = 3.0f
; mat
.m
[0][3] = 4.0f
;
443 mat
.m
[1][0] = 5.0f
; mat
.m
[1][1] = 6.0f
; mat
.m
[1][2] = 7.0f
; mat
.m
[1][3] = 8.0f
;
444 mat
.m
[2][0] = 9.0f
; mat
.m
[2][1] = 10.0f
; mat
.m
[2][2] = 11.0f
; mat
.m
[2][3] = 12.0f
;
445 mat
.m
[3][0] = 13.0f
; mat
.m
[3][1] = 14.0f
; mat
.m
[3][2] = 15.0f
; mat
.m
[3][3] = 16.0f
;
447 coeff1
= 2.0f
; coeff2
= 5.0f
;
450 /*_______________D3DXVec3Add__________________________*/
451 expectedvec
.x
= 11.0f
; expectedvec
.y
= 3.0f
; expectedvec
.z
= -2.0f
;
452 D3DXVec3Add(&gotvec
,&u
,&v
);
453 expect_vec3(expectedvec
,gotvec
);
454 /* Tests the case NULL */
455 funcpointer
= D3DXVec3Add(&gotvec
,NULL
,&v
);
456 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
457 funcpointer
= D3DXVec3Add(NULL
,NULL
,NULL
);
458 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
460 /*_______________D3DXVec3BaryCentric___________________*/
461 expectedvec
.x
= -35.0f
; expectedvec
.y
= -67.0; expectedvec
.z
= 15.0f
;
462 D3DXVec3BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
464 expect_vec3(expectedvec
,gotvec
);
466 /*_______________D3DXVec3CatmullRom____________________*/
467 expectedvec
.x
= 1458.0f
; expectedvec
.y
= 22.1875f
; expectedvec
.z
= 4141.375f
;
468 D3DXVec3CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
469 expect_vec3(expectedvec
,gotvec
);
471 /*_______________D3DXVec3Cross________________________*/
472 expectedvec
.x
= -18.0f
; expectedvec
.y
= 40.0f
; expectedvec
.z
= -39.0f
;
473 D3DXVec3Cross(&gotvec
,&u
,&v
);
474 expect_vec3(expectedvec
,gotvec
);
475 /* Tests the case NULL */
476 funcpointer
= D3DXVec3Cross(&gotvec
,NULL
,&v
);
477 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
478 funcpointer
= D3DXVec3Cross(NULL
,NULL
,NULL
);
479 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
481 /*_______________D3DXVec3Dot__________________________*/
483 got
= D3DXVec3Dot(&u
,&v
);
484 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
485 /* Tests the case NULL */
487 got
= D3DXVec3Dot(NULL
,&v
);
488 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
490 got
= D3DXVec3Dot(NULL
,NULL
);
491 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
493 /*_______________D3DXVec3Hermite__________________________*/
494 expectedvec
.x
= -6045.75f
; expectedvec
.y
= -6650.0f
; expectedvec
.z
= 1358.875f
;
495 D3DXVec3Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
496 expect_vec3(expectedvec
,gotvec
);
498 /*_______________D3DXVec3Length__________________________*/
500 got
= D3DXVec3Length(&u
);
501 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
502 /* Tests the case NULL */
504 got
= D3DXVec3Length(NULL
);
505 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
507 /*_______________D3DXVec3LengthSq________________________*/
509 got
= D3DXVec3LengthSq(&u
);
510 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
511 /* Tests the case NULL */
513 got
= D3DXVec3LengthSq(NULL
);
514 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
516 /*_______________D3DXVec3Lerp__________________________*/
517 expectedvec
.x
= 54.5f
; expectedvec
.y
= 64.5f
, expectedvec
.z
= 41.0f
;
518 D3DXVec3Lerp(&gotvec
,&u
,&v
,scale
);
519 expect_vec3(expectedvec
,gotvec
);
520 /* Tests the case NULL */
521 funcpointer
= D3DXVec3Lerp(&gotvec
,NULL
,&v
,scale
);
522 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
523 funcpointer
= D3DXVec3Lerp(NULL
,NULL
,NULL
,scale
);
524 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
526 /*_______________D3DXVec3Maximize__________________________*/
527 expectedvec
.x
= 9.0f
; expectedvec
.y
= 6.0f
; expectedvec
.z
= 2.0f
;
528 D3DXVec3Maximize(&gotvec
,&u
,&v
);
529 expect_vec3(expectedvec
,gotvec
);
530 /* Tests the case NULL */
531 funcpointer
= D3DXVec3Maximize(&gotvec
,NULL
,&v
);
532 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
533 funcpointer
= D3DXVec3Maximize(NULL
,NULL
,NULL
);
534 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
536 /*_______________D3DXVec3Minimize__________________________*/
537 expectedvec
.x
= 2.0f
; expectedvec
.y
= -3.0f
; expectedvec
.z
= -4.0f
;
538 D3DXVec3Minimize(&gotvec
,&u
,&v
);
539 expect_vec3(expectedvec
,gotvec
);
540 /* Tests the case NULL */
541 funcpointer
= D3DXVec3Minimize(&gotvec
,NULL
,&v
);
542 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
543 funcpointer
= D3DXVec3Minimize(NULL
,NULL
,NULL
);
544 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
546 /*_______________D3DXVec3Normalize_________________________*/
547 expectedvec
.x
= 9.0f
/11.0f
; expectedvec
.y
= 6.0f
/11.0f
; expectedvec
.z
= 2.0f
/11.0f
;
548 D3DXVec3Normalize(&gotvec
,&u
);
549 expect_vec3(expectedvec
,gotvec
);
550 /* Test the nul vector */
551 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
;
552 D3DXVec3Normalize(&gotvec
,&nul
);
553 expect_vec3(expectedvec
,gotvec
);
555 /*_______________D3DXVec3Scale____________________________*/
556 expectedvec
.x
= -58.5f
; expectedvec
.y
= -39.0f
; expectedvec
.z
= -13.0f
;
557 D3DXVec3Scale(&gotvec
,&u
,scale
);
558 expect_vec3(expectedvec
,gotvec
);
559 /* Tests the case NULL */
560 funcpointer
= D3DXVec3Scale(&gotvec
,NULL
,scale
);
561 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
562 funcpointer
= D3DXVec3Scale(NULL
,NULL
,scale
);
563 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
565 /*_______________D3DXVec3Subtract_______________________*/
566 expectedvec
.x
= 7.0f
; expectedvec
.y
= 9.0f
; expectedvec
.z
= 6.0f
;
567 D3DXVec3Subtract(&gotvec
,&u
,&v
);
568 expect_vec3(expectedvec
,gotvec
);
569 /* Tests the case NULL */
570 funcpointer
= D3DXVec3Subtract(&gotvec
,NULL
,&v
);
571 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
572 funcpointer
= D3DXVec3Subtract(NULL
,NULL
,NULL
);
573 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
575 /*_______________D3DXVec3Transform_______________________*/
576 expectedtrans
.x
= 70.0f
; expectedtrans
.y
= 88.0f
; expectedtrans
.z
= 106.0f
; expectedtrans
.w
= 124.0f
;
577 D3DXVec3Transform(&gottrans
,&u
,&mat
);
578 expect_vec4(expectedtrans
,gottrans
);
581 static void D3X8Vector4Test(void)
583 D3DXVECTOR4 expectedvec
, gotvec
, nul
, u
, v
, w
, x
;
584 LPD3DXVECTOR4 funcpointer
;
585 D3DXVECTOR4 expectedtrans
, gottrans
;
587 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
589 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
; nul
.w
= 0.0f
;
590 u
.x
= 1.0f
; u
.y
= 2.0f
; u
.z
= 4.0f
; u
.w
= 10.0;
591 v
.x
= -3.0f
; v
.y
= 4.0f
; v
.z
= -5.0f
; v
.w
= 7.0;
592 w
.x
= 4.0f
; w
.y
=6.0f
; w
.z
= -2.0f
; w
.w
= 1.0f
;
593 x
.x
= 6.0f
; x
.y
= -7.0f
; x
.z
=8.0f
; x
.w
= -9.0f
;
595 mat
.m
[0][0] = 1.0f
; mat
.m
[0][1] = 2.0f
; mat
.m
[0][2] = 3.0f
; mat
.m
[0][3] = 4.0f
;
596 mat
.m
[1][0] = 5.0f
; mat
.m
[1][1] = 6.0f
; mat
.m
[1][2] = 7.0f
; mat
.m
[1][3] = 8.0f
;
597 mat
.m
[2][0] = 9.0f
; mat
.m
[2][1] = 10.0f
; mat
.m
[2][2] = 11.0f
; mat
.m
[2][3] = 12.0f
;
598 mat
.m
[3][0] = 13.0f
; mat
.m
[3][1] = 14.0f
; mat
.m
[3][2] = 15.0f
; mat
.m
[3][3] = 16.0f
;
600 coeff1
= 2.0f
; coeff2
= 5.0;
603 /*_______________D3DXVec4Add__________________________*/
604 expectedvec
.x
= -2.0f
; expectedvec
.y
= 6.0f
; expectedvec
.z
= -1.0f
; expectedvec
.w
= 17.0f
;
605 D3DXVec4Add(&gotvec
,&u
,&v
);
606 expect_vec4(expectedvec
,gotvec
);
607 /* Tests the case NULL */
608 funcpointer
= D3DXVec4Add(&gotvec
,NULL
,&v
);
609 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
610 funcpointer
= D3DXVec4Add(NULL
,NULL
,NULL
);
611 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
613 /*_______________D3DXVec4BaryCentric____________________*/
614 expectedvec
.x
= 8.0f
; expectedvec
.y
= 26.0; expectedvec
.z
= -44.0f
; expectedvec
.w
= -41.0f
;
615 D3DXVec4BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
616 expect_vec4(expectedvec
,gotvec
);
618 /*_______________D3DXVec4CatmullRom____________________*/
619 expectedvec
.x
= 2754.625f
; expectedvec
.y
= 2367.5625f
; expectedvec
.z
= 1060.1875f
; expectedvec
.w
= 131.3125f
;
620 D3DXVec4CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
621 expect_vec4(expectedvec
,gotvec
);
623 /*_______________D3DXVec4Dot__________________________*/
625 got
= D3DXVec4Dot(&u
,&v
);
626 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
627 /* Tests the case NULL */
629 got
= D3DXVec4Dot(NULL
,&v
);
630 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
632 got
= D3DXVec4Dot(NULL
,NULL
);
633 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
635 /*_______________D3DXVec4Hermite_________________________*/
636 expectedvec
.x
= 1224.625f
; expectedvec
.y
= 3461.625f
; expectedvec
.z
= -4758.875f
; expectedvec
.w
= -5781.5f
;
637 D3DXVec4Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
638 expect_vec4(expectedvec
,gotvec
);
640 /*_______________D3DXVec4Length__________________________*/
642 got
= D3DXVec4Length(&u
);
643 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
644 /* Tests the case NULL */
646 got
= D3DXVec4Length(NULL
);
647 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
649 /*_______________D3DXVec4LengthSq________________________*/
651 got
= D3DXVec4LengthSq(&u
);
652 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
653 /* Tests the case NULL */
655 got
= D3DXVec4LengthSq(NULL
);
656 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
658 /*_______________D3DXVec4Lerp__________________________*/
659 expectedvec
.x
= 27.0f
; expectedvec
.y
= -11.0f
; expectedvec
.z
= 62.5; expectedvec
.w
= 29.5;
660 D3DXVec4Lerp(&gotvec
,&u
,&v
,scale
);
661 expect_vec4(expectedvec
,gotvec
);
662 /* Tests the case NULL */
663 funcpointer
= D3DXVec4Lerp(&gotvec
,NULL
,&v
,scale
);
664 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
665 funcpointer
= D3DXVec4Lerp(NULL
,NULL
,NULL
,scale
);
666 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
668 /*_______________D3DXVec4Maximize__________________________*/
669 expectedvec
.x
= 1.0f
; expectedvec
.y
= 4.0f
; expectedvec
.z
= 4.0f
; expectedvec
.w
= 10.0;
670 D3DXVec4Maximize(&gotvec
,&u
,&v
);
671 expect_vec4(expectedvec
,gotvec
);
672 /* Tests the case NULL */
673 funcpointer
= D3DXVec4Maximize(&gotvec
,NULL
,&v
);
674 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
675 funcpointer
= D3DXVec4Maximize(NULL
,NULL
,NULL
);
676 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
678 /*_______________D3DXVec4Minimize__________________________*/
679 expectedvec
.x
= -3.0f
; expectedvec
.y
= 2.0f
; expectedvec
.z
= -5.0f
; expectedvec
.w
= 7.0;
680 D3DXVec4Minimize(&gotvec
,&u
,&v
);
681 expect_vec4(expectedvec
,gotvec
);
682 /* Tests the case NULL */
683 funcpointer
= D3DXVec4Minimize(&gotvec
,NULL
,&v
);
684 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
685 funcpointer
= D3DXVec4Minimize(NULL
,NULL
,NULL
);
686 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
688 /*_______________D3DXVec4Normalize_________________________*/
689 expectedvec
.x
= 1.0f
/11.0f
; expectedvec
.y
= 2.0f
/11.0f
; expectedvec
.z
= 4.0f
/11.0f
; expectedvec
.w
= 10.0f
/11.0f
;
690 D3DXVec4Normalize(&gotvec
,&u
);
691 expect_vec4(expectedvec
,gotvec
);
692 /* Test the nul vector */
693 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
; expectedvec
.w
= 0.0f
;
694 D3DXVec4Normalize(&gotvec
,&nul
);
695 expect_vec4(expectedvec
,gotvec
);
697 /*_______________D3DXVec4Scale____________________________*/
698 expectedvec
.x
= -6.5f
; expectedvec
.y
= -13.0f
; expectedvec
.z
= -26.0f
; expectedvec
.w
= -65.0f
;
699 D3DXVec4Scale(&gotvec
,&u
,scale
);
700 expect_vec4(expectedvec
,gotvec
);
701 /* Tests the case NULL */
702 funcpointer
= D3DXVec4Scale(&gotvec
,NULL
,scale
);
703 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
704 funcpointer
= D3DXVec4Scale(NULL
,NULL
,scale
);
705 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
707 /*_______________D3DXVec4Subtract__________________________*/
708 expectedvec
.x
= 4.0f
; expectedvec
.y
= -2.0f
; expectedvec
.z
= 9.0f
; expectedvec
.w
= 3.0f
;
709 D3DXVec4Subtract(&gotvec
,&u
,&v
);
710 expect_vec4(expectedvec
,gotvec
);
711 /* Tests the case NULL */
712 funcpointer
= D3DXVec4Subtract(&gotvec
,NULL
,&v
);
713 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
714 funcpointer
= D3DXVec4Subtract(NULL
,NULL
,NULL
);
715 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
717 /*_______________D3DXVec4Transform_______________________*/
718 expectedtrans
.x
= 177.0f
; expectedtrans
.y
= 194.0f
; expectedtrans
.z
= 211.0f
; expectedtrans
.w
= 228.0f
;
719 D3DXVec4Transform(&gottrans
,&u
,&mat
);
720 expect_vec4(expectedtrans
,gottrans
);
728 D3X8QuaternionTest();