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_mat(expectedmat,gotmat)\
35 if (fabs(expectedmat.m[i][j]-gotmat.m[i][j])>admitted_error)\
41 ok(equal, "Expected matrix=\n(%f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n)\n\n" \
42 "Got matrix=\n(%f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f)\n", \
43 expectedmat.m[0][0],expectedmat.m[0][1],expectedmat.m[0][2],expectedmat.m[0][3], \
44 expectedmat.m[1][0],expectedmat.m[1][1],expectedmat.m[1][2],expectedmat.m[1][3], \
45 expectedmat.m[2][0],expectedmat.m[2][1],expectedmat.m[2][2],expectedmat.m[2][3], \
46 expectedmat.m[3][0],expectedmat.m[3][1],expectedmat.m[3][2],expectedmat.m[3][3], \
47 gotmat.m[0][0],gotmat.m[0][1],gotmat.m[0][2],gotmat.m[0][3], \
48 gotmat.m[1][0],gotmat.m[1][1],gotmat.m[1][2],gotmat.m[1][3], \
49 gotmat.m[2][0],gotmat.m[2][1],gotmat.m[2][2],gotmat.m[2][3], \
50 gotmat.m[3][0],gotmat.m[3][1],gotmat.m[3][2],gotmat.m[3][3]); \
53 #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);
55 #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);
57 #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);
59 static void D3DXColorTest(void)
61 D3DXCOLOR color
, color1
, color2
, expected
, got
;
62 LPD3DXCOLOR funcpointer
;
65 color
.r
= 0.2f
; color
.g
= 0.75f
; color
.b
= 0.41f
; color
.a
= 0.93f
;
66 color1
.r
= 0.6f
; color1
.g
= 0.55f
; color1
.b
= 0.23f
; color1
.a
= 0.82f
;
67 color2
.r
= 0.3f
; color2
.g
= 0.5f
; color2
.b
= 0.76f
; color2
.a
= 0.11f
;
70 /*_______________D3DXColorAdd________________*/
71 expected
.r
= 0.9f
; expected
.g
= 1.05f
; expected
.b
= 0.99f
, expected
.a
= 0.93f
;
72 D3DXColorAdd(&got
,&color1
,&color2
);
73 expect_color(expected
,got
);
74 /* Test the NULL case */
75 funcpointer
= D3DXColorAdd(&got
,NULL
,&color2
);
76 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
77 funcpointer
= D3DXColorAdd(NULL
,NULL
,&color2
);
78 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
79 funcpointer
= D3DXColorAdd(NULL
,NULL
,NULL
);
80 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
82 /*_______________D3DXColorLerp________________*/
83 expected
.r
= 0.32f
; expected
.g
= 0.69f
; expected
.b
= 0.356f
; expected
.a
= 0.897f
;
84 D3DXColorLerp(&got
,&color
,&color1
,scale
);
85 expect_color(expected
,got
);
86 /* Test the NULL case */
87 funcpointer
= D3DXColorLerp(&got
,NULL
,&color1
,scale
);
88 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
89 funcpointer
= D3DXColorLerp(NULL
,NULL
,&color1
,scale
);
90 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
91 funcpointer
= D3DXColorLerp(NULL
,NULL
,NULL
,scale
);
92 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
94 /*_______________D3DXColorModulate________________*/
95 expected
.r
= 0.18f
; expected
.g
= 0.275f
; expected
.b
= 0.1748f
; expected
.a
= 0.0902f
;
96 D3DXColorModulate(&got
,&color1
,&color2
);
97 expect_color(expected
,got
);
98 /* Test the NULL case */
99 funcpointer
= D3DXColorModulate(&got
,NULL
,&color2
);
100 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
101 funcpointer
= D3DXColorModulate(NULL
,NULL
,&color2
);
102 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
103 funcpointer
= D3DXColorModulate(NULL
,NULL
,NULL
);
104 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
106 /*_______________D3DXColorNegative________________*/
107 expected
.r
= 0.8f
; expected
.g
= 0.25f
; expected
.b
= 0.59f
; expected
.a
= 0.93f
;
108 D3DXColorNegative(&got
,&color
);
109 expect_color(got
,expected
);
110 /* Test the greater than 1 case */
111 color1
.r
= 0.2f
; color1
.g
= 1.75f
; color1
.b
= 0.41f
; color1
.a
= 0.93f
;
112 expected
.r
= 0.8f
; expected
.g
= -0.75f
; expected
.b
= 0.59f
; expected
.a
= 0.93f
;
113 D3DXColorNegative(&got
,&color1
);
114 expect_color(got
,expected
);
115 /* Test the negative case */
116 color1
.r
= 0.2f
; color1
.g
= -0.75f
; color1
.b
= 0.41f
; color1
.a
= 0.93f
;
117 expected
.r
= 0.8f
; expected
.g
= 1.75f
; expected
.b
= 0.59f
; expected
.a
= 0.93f
;
118 D3DXColorNegative(&got
,&color1
);
119 expect_color(got
,expected
);
120 /* Test the NULL case */
121 funcpointer
= D3DXColorNegative(&got
,NULL
);
122 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
123 funcpointer
= D3DXColorNegative(NULL
,NULL
);
124 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
126 /*_______________D3DXColorScale________________*/
127 expected
.r
= 0.06f
; expected
.g
= 0.225f
; expected
.b
= 0.123f
; expected
.a
= 0.279f
;
128 D3DXColorScale(&got
,&color
,scale
);
129 expect_color(expected
,got
);
130 /* Test the NULL case */
131 funcpointer
= D3DXColorScale(&got
,NULL
,scale
);
132 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
133 funcpointer
= D3DXColorScale(NULL
,NULL
,scale
);
134 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
136 /*_______________D3DXColorSubtract_______________*/
137 expected
.r
= -0.1f
; expected
.g
= 0.25f
; expected
.b
= -0.35f
, expected
.a
= 0.82f
;
138 D3DXColorSubtract(&got
,&color
,&color2
);
139 expect_color(expected
,got
);
140 /* Test the NULL case */
141 funcpointer
= D3DXColorSubtract(&got
,NULL
,&color2
);
142 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
143 funcpointer
= D3DXColorSubtract(NULL
,NULL
,&color2
);
144 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
145 funcpointer
= D3DXColorSubtract(NULL
,NULL
,NULL
);
146 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
149 static void D3DXMatrixTest(void)
151 D3DXMATRIX expectedmat
, gotmat
, mat
, mat2
, mat3
;
154 FLOAT angle
, expectedfloat
, gotfloat
;
156 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
157 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
158 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
159 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
160 U(mat
).m
[0][0] = 10.0f
; U(mat
).m
[1][1] = 20.0f
; U(mat
).m
[2][2] = 30.0f
;
161 U(mat
).m
[3][3] = -40.0f
;
163 mat2
.m
[0][0] = 1.0f
; mat2
.m
[1][0] = 2.0f
; mat2
.m
[2][0] = 3.0f
;
164 mat2
.m
[3][0] = 4.0f
; mat2
.m
[0][1] = 5.0f
; mat2
.m
[1][1] = 6.0f
;
165 mat2
.m
[2][1] = 7.0f
; mat2
.m
[3][1] = 8.0f
; mat2
.m
[0][2] = -8.0f
;
166 mat2
.m
[1][2] = -7.0f
; mat2
.m
[2][2] = -6.0f
; mat2
.m
[3][2] = -5.0f
;
167 mat2
.m
[0][3] = -4.0f
; mat2
.m
[1][3] = -3.0f
; mat2
.m
[2][3] = -2.0f
;
168 mat2
.m
[3][3] = -1.0f
;
170 axis
.x
= 1.0f
; axis
.y
= -3.0f
; axis
.z
= 7.0f
;
172 angle
= D3DX_PI
/3.0f
;
174 /*____________D3DXMatrixfDeterminant_____________*/
175 expectedfloat
= -147888.0f
;
176 gotfloat
= D3DXMatrixfDeterminant(&mat
);
177 ok(fabs( gotfloat
- expectedfloat
) < admitted_error
, "Expected: %f, Got: %f\n", expectedfloat
, gotfloat
);
179 /*____________D3DXMatrixIsIdentity______________*/
181 got
= D3DXMatrixIsIdentity(&mat3
);
182 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
183 D3DXMatrixIdentity(&mat3
);
185 got
= D3DXMatrixIsIdentity(&mat3
);
186 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
187 U(mat3
).m
[0][0] = 0.000009f
;
189 got
= D3DXMatrixIsIdentity(&mat3
);
190 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
191 /* Test the NULL case */
193 got
= D3DXMatrixIsIdentity(NULL
);
194 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
196 /*____________D3DXMatrixMultiply______________*/
197 expectedmat
.m
[0][0] = 73.0f
; expectedmat
.m
[0][1] = 193.0f
; expectedmat
.m
[0][2] = -197.0f
; expectedmat
.m
[0][3] = -77.0f
;
198 expectedmat
.m
[1][0] = 231.0f
; expectedmat
.m
[1][1] = 551.0f
; expectedmat
.m
[1][2] = -489.0f
; expectedmat
.m
[1][3] = -169.0;
199 expectedmat
.m
[2][0] = 239.0f
; expectedmat
.m
[2][1] = 523.0f
; expectedmat
.m
[2][2] = -400.0f
; expectedmat
.m
[2][3] = -116.0f
;
200 expectedmat
.m
[3][0] = -164.0f
; expectedmat
.m
[3][1] = -320.0f
; expectedmat
.m
[3][2] = 187.0f
; expectedmat
.m
[3][3] = 31.0f
;
201 D3DXMatrixMultiply(&gotmat
,&mat
,&mat2
);
202 expect_mat(expectedmat
,gotmat
);
204 /*____________D3DXMatrixRotationRotationAxis_____*/
205 expectedmat
.m
[0][0] = 0.508475f
; expectedmat
.m
[0][1] = 0.763805f
; expectedmat
.m
[0][2] = 0.397563f
; expectedmat
.m
[0][3] = 0.0f
;
206 expectedmat
.m
[1][0] = -0.814652f
; expectedmat
.m
[1][1] = 0.576271f
; expectedmat
.m
[1][2] = -0.065219f
; expectedmat
.m
[1][3] = 0.0f
;
207 expectedmat
.m
[2][0] = -0.278919f
; expectedmat
.m
[2][1] = -0.290713f
; expectedmat
.m
[2][2] = 0.915254f
; expectedmat
.m
[2][3] = 0.0f
;
208 expectedmat
.m
[3][0] = 0.0f
; expectedmat
.m
[3][1] = 0.0f
; expectedmat
.m
[3][2] = 0.0f
; expectedmat
.m
[3][3] = 1.0f
;
209 D3DXMatrixRotationAxis(&gotmat
,&axis
,angle
);
210 expect_mat(expectedmat
,gotmat
);
212 /*____________D3DXMatrixRotationX______________*/
213 expectedmat
.m
[0][0] = 1.0f
; expectedmat
.m
[0][1] = 0.0f
; expectedmat
.m
[0][2] = 0.0f
; expectedmat
.m
[0][3] = 0.0f
;
214 expectedmat
.m
[1][0] = 0.0; expectedmat
.m
[1][1] = 0.5f
; expectedmat
.m
[1][2] = sqrt(3.0f
)/2.0f
; expectedmat
.m
[1][3] = 0.0f
;
215 expectedmat
.m
[2][0] = 0.0f
; expectedmat
.m
[2][1] = -sqrt(3.0f
)/2.0f
; expectedmat
.m
[2][2] = 0.5f
; expectedmat
.m
[2][3] = 0.0f
;
216 expectedmat
.m
[3][0] = 0.0f
; expectedmat
.m
[3][1] = 0.0f
; expectedmat
.m
[3][2] = 0.0f
; expectedmat
.m
[3][3] = 1.0f
;
217 D3DXMatrixRotationX(&gotmat
,angle
);
218 expect_mat(expectedmat
,gotmat
);
220 /*____________D3DXMatrixRotationY______________*/
221 expectedmat
.m
[0][0] = 0.5f
; expectedmat
.m
[0][1] = 0.0f
; expectedmat
.m
[0][2] = -sqrt(3.0f
)/2.0f
; expectedmat
.m
[0][3] = 0.0f
;
222 expectedmat
.m
[1][0] = 0.0; expectedmat
.m
[1][1] = 1.0f
; expectedmat
.m
[1][2] = 0.0f
; expectedmat
.m
[1][3] = 0.0f
;
223 expectedmat
.m
[2][0] = sqrt(3.0f
)/2.0f
; expectedmat
.m
[2][1] = 0.0f
; expectedmat
.m
[2][2] = 0.5f
; expectedmat
.m
[2][3] = 0.0f
;
224 expectedmat
.m
[3][0] = 0.0f
; expectedmat
.m
[3][1] = 0.0f
; expectedmat
.m
[3][2] = 0.0f
; expectedmat
.m
[3][3] = 1.0f
;
225 D3DXMatrixRotationY(&gotmat
,angle
);
226 expect_mat(expectedmat
,gotmat
);
228 /*____________D3DXMatrixRotationZ______________*/
229 expectedmat
.m
[0][0] = 0.5f
; expectedmat
.m
[0][1] = sqrt(3.0f
)/2.0f
; expectedmat
.m
[0][2] = 0.0f
; expectedmat
.m
[0][3] = 0.0f
;
230 expectedmat
.m
[1][0] = -sqrt(3.0f
)/2.0f
; expectedmat
.m
[1][1] = 0.5f
; expectedmat
.m
[1][2] = 0.0f
; expectedmat
.m
[1][3] = 0.0f
;
231 expectedmat
.m
[2][0] = 0.0f
; expectedmat
.m
[2][1] = 0.0f
; expectedmat
.m
[2][2] = 1.0f
; expectedmat
.m
[2][3] = 0.0f
;
232 expectedmat
.m
[3][0] = 0.0f
; expectedmat
.m
[3][1] = 0.0f
; expectedmat
.m
[3][2] = 0.0f
; expectedmat
.m
[3][3] = 1.0f
;
233 D3DXMatrixRotationZ(&gotmat
,angle
);
234 expect_mat(expectedmat
,gotmat
);
236 /*____________D3DXMatrixScaling______________*/
237 expectedmat
.m
[0][0] = 0.69f
; expectedmat
.m
[0][1] = 0.0f
; expectedmat
.m
[0][2] = 0.0f
; expectedmat
.m
[0][3] = 0.0f
;
238 expectedmat
.m
[1][0] = 0.0; expectedmat
.m
[1][1] = 0.53f
; expectedmat
.m
[1][2] = 0.0f
; expectedmat
.m
[1][3] = 0.0f
;
239 expectedmat
.m
[2][0] = 0.0f
; expectedmat
.m
[2][1] = 0.0f
; expectedmat
.m
[2][2] = 4.11f
; expectedmat
.m
[2][3] = 0.0f
;
240 expectedmat
.m
[3][0] = 0.0f
; expectedmat
.m
[3][1] = 0.0f
; expectedmat
.m
[3][2] = 0.0f
; expectedmat
.m
[3][3] = 1.0f
;
241 D3DXMatrixScaling(&gotmat
,0.69f
,0.53f
,4.11f
);
242 expect_mat(expectedmat
,gotmat
);
244 /*____________D3DXMatrixTranslation______________*/
245 expectedmat
.m
[0][0] = 1.0f
; expectedmat
.m
[0][1] = 0.0f
; expectedmat
.m
[0][2] = 0.0f
; expectedmat
.m
[0][3] = 0.0f
;
246 expectedmat
.m
[1][0] = 0.0; expectedmat
.m
[1][1] = 1.0f
; expectedmat
.m
[1][2] = 0.0f
; expectedmat
.m
[1][3] = 0.0f
;
247 expectedmat
.m
[2][0] = 0.0f
; expectedmat
.m
[2][1] = 0.0f
; expectedmat
.m
[2][2] = 1.0f
; expectedmat
.m
[2][3] = 0.0f
;
248 expectedmat
.m
[3][0] = 0.69f
; expectedmat
.m
[3][1] = 0.53f
; expectedmat
.m
[3][2] = 4.11f
; expectedmat
.m
[3][3] = 1.0f
;
249 D3DXMatrixTranslation(&gotmat
,0.69f
,0.53f
,4.11f
);
250 expect_mat(expectedmat
,gotmat
);
252 /*____________D3DXMatrixTranspose______________*/
253 expectedmat
.m
[0][0] = 10.0f
; expectedmat
.m
[0][1] = 11.0f
; expectedmat
.m
[0][2] = 19.0f
; expectedmat
.m
[0][3] = 2.0f
;
254 expectedmat
.m
[1][0] = 5.0; expectedmat
.m
[1][1] = 20.0f
; expectedmat
.m
[1][2] = -21.0f
; expectedmat
.m
[1][3] = 3.0f
;
255 expectedmat
.m
[2][0] = 7.0f
; expectedmat
.m
[2][1] = 16.0f
; expectedmat
.m
[2][2] = 30.f
; expectedmat
.m
[2][3] = -4.0f
;
256 expectedmat
.m
[3][0] = 8.0f
; expectedmat
.m
[3][1] = 33.0f
; expectedmat
.m
[3][2] = 43.0f
; expectedmat
.m
[3][3] = -40.0f
;
257 D3DXMatrixTranspose(&gotmat
,&mat
);
258 expect_mat(expectedmat
,gotmat
);
261 static void D3DXPlaneTest(void)
267 plane
.a
= -3.0f
; plane
.b
= -1.0f
; plane
.c
= 4.0f
; plane
.d
= 7.0f
;
268 vec
.x
= 2.0f
; vec
.y
= 5.0f
; vec
.z
= -6.0f
; vec
.w
= 11.0f
;
270 /*_______________D3DXPlaneDot________________*/
272 got
= D3DXPlaneDot(&plane
,&vec
),
273 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
275 got
= D3DXPlaneDot(NULL
,&vec
),
276 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
278 got
= D3DXPlaneDot(NULL
,NULL
),
279 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
281 /*_______________D3DXPlaneDotCoord________________*/
283 got
= D3DXPlaneDotCoord(&plane
,&vec
),
284 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
286 got
= D3DXPlaneDotCoord(NULL
,&vec
),
287 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
289 got
= D3DXPlaneDotCoord(NULL
,NULL
),
290 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
292 /*_______________D3DXPlaneDotNormal______________*/
294 got
= D3DXPlaneDotNormal(&plane
,&vec
),
295 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
297 got
= D3DXPlaneDotNormal(NULL
,&vec
),
298 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
300 got
= D3DXPlaneDotNormal(NULL
,NULL
),
301 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
304 static void D3X8QuaternionTest(void)
306 D3DXQUATERNION expectedquat
, gotquat
, nul
, q
, r
, s
;
307 LPD3DXQUATERNION funcpointer
;
309 BOOL expectedbool
, gotbool
;
311 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
; nul
.w
= 0.0f
;
312 q
.x
= 1.0f
, q
.y
= 2.0f
; q
.z
= 4.0f
; q
.w
= 10.0f
;
313 r
.x
= -3.0f
; r
.y
= 4.0f
; r
.z
= -5.0f
; r
.w
= 7.0;
315 /*_______________D3DXQuaternionConjugate________________*/
316 expectedquat
.x
= -1.0f
; expectedquat
.y
= -2.0f
; expectedquat
.z
= -4.0f
; expectedquat
.w
= 10.0f
;
317 D3DXQuaternionConjugate(&gotquat
,&q
);
318 expect_vec4(expectedquat
,gotquat
);
319 /* Test the NULL case */
320 funcpointer
= D3DXQuaternionConjugate(&gotquat
,NULL
);
321 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
322 funcpointer
= D3DXQuaternionConjugate(NULL
,NULL
);
323 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
325 /*_______________D3DXQuaternionDot______________________*/
327 got
= D3DXQuaternionDot(&q
,&r
);
328 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
329 /* Tests the case NULL */
331 got
= D3DXQuaternionDot(NULL
,&r
);
332 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
334 got
= D3DXQuaternionDot(NULL
,NULL
);
335 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
337 /*_______________D3DXQuaternionIdentity________________*/
338 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 1.0f
;
339 D3DXQuaternionIdentity(&gotquat
);
340 expect_vec4(expectedquat
,gotquat
);
341 /* Test the NULL case */
342 funcpointer
= D3DXQuaternionIdentity(NULL
);
343 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
345 /*_______________D3DXQuaternionIsIdentity________________*/
346 s
.x
= 0.0f
; s
.y
= 0.0f
; s
.z
= 0.0f
; s
.w
= 1.0f
;
348 gotbool
= D3DXQuaternionIsIdentity(&s
);
349 ok( expectedbool
== gotbool
, "Expected boolean : %d, Got bool : %d\n", expectedbool
, gotbool
);
350 s
.x
= 2.3f
; s
.y
= -4.2f
; s
.z
= 1.2f
; s
.w
=0.2f
;
351 expectedbool
= FALSE
;
352 gotbool
= D3DXQuaternionIsIdentity(&q
);
353 ok( expectedbool
== gotbool
, "Expected boolean : %d, Got bool : %d\n", expectedbool
, gotbool
);
354 /* Test the NULL case */
355 gotbool
= D3DXQuaternionIsIdentity(NULL
);
356 ok(gotbool
== FALSE
, "Expected boolean: %d, Got boolean: %d\n", FALSE
, gotbool
);
358 /*_______________D3DXQuaternionLength__________________________*/
360 got
= D3DXQuaternionLength(&q
);
361 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
362 /* Tests the case NULL */
364 got
= D3DXQuaternionLength(NULL
);
365 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
367 /*_______________D3DXQuaternionLengthSq________________________*/
369 got
= D3DXQuaternionLengthSq(&q
);
370 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
371 /* Tests the case NULL */
373 got
= D3DXQuaternionLengthSq(NULL
);
374 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
376 /*_______________D3DXQuaternionNormalize________________________*/
377 expectedquat
.x
= 1.0f
/11.0f
; expectedquat
.y
= 2.0f
/11.0f
; expectedquat
.z
= 4.0f
/11.0f
; expectedquat
.w
= 10.0f
/11.0f
;
378 D3DXQuaternionNormalize(&gotquat
,&q
);
379 expect_vec4(expectedquat
,gotquat
);
380 /* Test the nul quaternion */
381 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.0f
;
382 D3DXQuaternionNormalize(&gotquat
,&nul
);
383 expect_vec4(expectedquat
,gotquat
);
386 static void D3X8Vector2Test(void)
388 D3DXVECTOR2 expectedvec
, gotvec
, nul
, nulproj
, u
, v
, w
, x
;
389 LPD3DXVECTOR2 funcpointer
;
390 D3DXVECTOR4 expectedtrans
, gottrans
;
392 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
394 nul
.x
= 0.0f
; nul
.y
= 0.0f
;
395 u
.x
= 3.0f
; u
.y
= 4.0f
;
396 v
.x
= -7.0f
; v
.y
= 9.0f
;
397 w
.x
= 4.0f
; w
.y
= -3.0f
;
398 x
.x
= 2.0f
; x
.y
= -11.0f
;
400 mat
.m
[0][0] = 1.0f
; mat
.m
[0][1] = 2.0f
; mat
.m
[0][2] = 3.0f
; mat
.m
[0][3] = 4.0f
;
401 mat
.m
[1][0] = 5.0f
; mat
.m
[1][1] = 6.0f
; mat
.m
[1][2] = 7.0f
; mat
.m
[1][3] = 8.0f
;
402 mat
.m
[2][0] = 9.0f
; mat
.m
[2][1] = 10.0f
; mat
.m
[2][2] = 11.0f
; mat
.m
[2][3] = 12.0f
;
403 mat
.m
[3][0] = 13.0f
; mat
.m
[3][1] = 14.0f
; mat
.m
[3][2] = 15.0f
; mat
.m
[3][3] = 16.0f
;
405 coeff1
= 2.0f
; coeff2
= 5.0f
;
408 /*_______________D3DXVec2Add__________________________*/
409 expectedvec
.x
= -4.0f
; expectedvec
.y
= 13.0f
;
410 D3DXVec2Add(&gotvec
,&u
,&v
);
411 expect_vec(expectedvec
,gotvec
);
412 /* Tests the case NULL */
413 funcpointer
= D3DXVec2Add(&gotvec
,NULL
,&v
);
414 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
415 funcpointer
= D3DXVec2Add(NULL
,NULL
,NULL
);
416 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
418 /*_______________D3DXVec2BaryCentric___________________*/
419 expectedvec
.x
= -12.0f
; expectedvec
.y
= -21.0f
;
420 D3DXVec2BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
421 expect_vec(expectedvec
,gotvec
);
423 /*_______________D3DXVec2CatmullRom____________________*/
424 expectedvec
.x
= 5820.25f
; expectedvec
.y
= -3654.5625f
;
425 D3DXVec2CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
426 expect_vec(expectedvec
,gotvec
);
428 /*_______________D3DXVec2CCW__________________________*/
430 got
= D3DXVec2CCW(&u
,&v
);
431 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
432 /* Tests the case NULL */
434 got
= D3DXVec2CCW(NULL
,&v
);
435 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
437 got
= D3DXVec2CCW(NULL
,NULL
);
438 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
440 /*_______________D3DXVec2Dot__________________________*/
442 got
= D3DXVec2Dot(&u
,&v
);
443 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
444 /* Tests the case NULL */
446 got
= D3DXVec2Dot(NULL
,&v
);
447 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
449 got
= D3DXVec2Dot(NULL
,NULL
);
450 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
452 /*_______________D3DXVec2Hermite__________________________*/
453 expectedvec
.x
= 2604.625f
; expectedvec
.y
= -4533.0f
;
454 D3DXVec2Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
455 expect_vec(expectedvec
,gotvec
);
457 /*_______________D3DXVec2Length__________________________*/
459 got
= D3DXVec2Length(&u
);
460 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
461 /* Tests the case NULL */
463 got
= D3DXVec2Length(NULL
);
464 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
466 /*_______________D3DXVec2LengthSq________________________*/
468 got
= D3DXVec2LengthSq(&u
);
469 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
470 /* Tests the case NULL */
472 got
= D3DXVec2LengthSq(NULL
);
473 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
475 /*_______________D3DXVec2Lerp__________________________*/
476 expectedvec
.x
= 68.0f
; expectedvec
.y
= -28.5f
;
477 D3DXVec2Lerp(&gotvec
,&u
,&v
,scale
);
478 expect_vec(expectedvec
,gotvec
);
479 /* Tests the case NULL */
480 funcpointer
= D3DXVec2Lerp(&gotvec
,NULL
,&v
,scale
);
481 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
482 funcpointer
= D3DXVec2Lerp(NULL
,NULL
,NULL
,scale
);
483 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
485 /*_______________D3DXVec2Maximize__________________________*/
486 expectedvec
.x
= 3.0f
; expectedvec
.y
= 9.0f
;
487 D3DXVec2Maximize(&gotvec
,&u
,&v
);
488 expect_vec(expectedvec
,gotvec
);
489 /* Tests the case NULL */
490 funcpointer
= D3DXVec2Maximize(&gotvec
,NULL
,&v
);
491 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
492 funcpointer
= D3DXVec2Maximize(NULL
,NULL
,NULL
);
493 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
495 /*_______________D3DXVec2Minimize__________________________*/
496 expectedvec
.x
= -7.0f
; expectedvec
.y
= 4.0f
;
497 D3DXVec2Minimize(&gotvec
,&u
,&v
);
498 expect_vec(expectedvec
,gotvec
);
499 /* Tests the case NULL */
500 funcpointer
= D3DXVec2Minimize(&gotvec
,NULL
,&v
);
501 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
502 funcpointer
= D3DXVec2Minimize(NULL
,NULL
,NULL
);
503 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
505 /*_______________D3DXVec2Normalize_________________________*/
506 expectedvec
.x
= 0.6f
; expectedvec
.y
= 0.8f
;
507 D3DXVec2Normalize(&gotvec
,&u
);
508 expect_vec(expectedvec
,gotvec
);
509 /* Test the nul vector */
510 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
;
511 D3DXVec2Normalize(&gotvec
,&nul
);
512 expect_vec(expectedvec
,gotvec
);
514 /*_______________D3DXVec2Scale____________________________*/
515 expectedvec
.x
= -19.5f
; expectedvec
.y
= -26.0f
;
516 D3DXVec2Scale(&gotvec
,&u
,scale
);
517 expect_vec(expectedvec
,gotvec
);
518 /* Tests the case NULL */
519 funcpointer
= D3DXVec2Scale(&gotvec
,NULL
,scale
);
520 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
521 funcpointer
= D3DXVec2Scale(NULL
,NULL
,scale
);
522 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
524 /*_______________D3DXVec2Subtract__________________________*/
525 expectedvec
.x
= 10.0f
; expectedvec
.y
= -5.0f
;
526 D3DXVec2Subtract(&gotvec
,&u
,&v
);
527 expect_vec(expectedvec
,gotvec
);
528 /* Tests the case NULL */
529 funcpointer
= D3DXVec2Subtract(&gotvec
,NULL
,&v
);
530 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
531 funcpointer
= D3DXVec2Subtract(NULL
,NULL
,NULL
);
532 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
534 /*_______________D3DXVec2Transform_______________________*/
535 expectedtrans
.x
= 36.0f
; expectedtrans
.y
= 44.0f
; expectedtrans
.z
= 52.0f
; expectedtrans
.w
= 60.0f
;
536 D3DXVec2Transform(&gottrans
,&u
,&mat
);
537 expect_vec4(expectedtrans
,gottrans
);
539 /*_______________D3DXVec2TransformCoord_______________________*/
540 expectedvec
.x
= 0.6f
; expectedvec
.y
= 11.0f
/15.0f
;
541 D3DXVec2TransformCoord(&gotvec
,&u
,&mat
);
542 expect_vec(expectedvec
,gotvec
);
543 /* Test the nul projected vector */
544 nulproj
.x
= -2.0f
; nulproj
.y
= -1.0f
;
545 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
;
546 D3DXVec2TransformCoord(&gotvec
,&nulproj
,&mat
);
547 expect_vec(expectedvec
,gotvec
);
549 /*_______________D3DXVec2TransformNormal______________________*/
550 expectedvec
.x
= 23.0f
; expectedvec
.y
= 30.0f
;
551 D3DXVec2TransformNormal(&gotvec
,&u
,&mat
);
552 expect_vec(expectedvec
,gotvec
);
555 static void D3X8Vector3Test(void)
557 D3DXVECTOR3 expectedvec
, gotvec
, nul
, nulproj
, u
, v
, w
, x
;
558 LPD3DXVECTOR3 funcpointer
;
559 D3DXVECTOR4 expectedtrans
, gottrans
;
561 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
563 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
;
564 u
.x
= 9.0f
; u
.y
= 6.0f
; u
.z
= 2.0f
;
565 v
.x
= 2.0f
; v
.y
= -3.0f
; v
.z
= -4.0;
566 w
.x
= 3.0f
; w
.y
= -5.0f
; w
.z
= 7.0f
;
567 x
.x
= 4.0f
; x
.y
= 1.0f
; x
.z
= 11.0f
;
569 mat
.m
[0][0] = 1.0f
; mat
.m
[0][1] = 2.0f
; mat
.m
[0][2] = 3.0f
; mat
.m
[0][3] = 4.0f
;
570 mat
.m
[1][0] = 5.0f
; mat
.m
[1][1] = 6.0f
; mat
.m
[1][2] = 7.0f
; mat
.m
[1][3] = 8.0f
;
571 mat
.m
[2][0] = 9.0f
; mat
.m
[2][1] = 10.0f
; mat
.m
[2][2] = 11.0f
; mat
.m
[2][3] = 12.0f
;
572 mat
.m
[3][0] = 13.0f
; mat
.m
[3][1] = 14.0f
; mat
.m
[3][2] = 15.0f
; mat
.m
[3][3] = 16.0f
;
574 coeff1
= 2.0f
; coeff2
= 5.0f
;
577 /*_______________D3DXVec3Add__________________________*/
578 expectedvec
.x
= 11.0f
; expectedvec
.y
= 3.0f
; expectedvec
.z
= -2.0f
;
579 D3DXVec3Add(&gotvec
,&u
,&v
);
580 expect_vec3(expectedvec
,gotvec
);
581 /* Tests the case NULL */
582 funcpointer
= D3DXVec3Add(&gotvec
,NULL
,&v
);
583 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
584 funcpointer
= D3DXVec3Add(NULL
,NULL
,NULL
);
585 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
587 /*_______________D3DXVec3BaryCentric___________________*/
588 expectedvec
.x
= -35.0f
; expectedvec
.y
= -67.0; expectedvec
.z
= 15.0f
;
589 D3DXVec3BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
591 expect_vec3(expectedvec
,gotvec
);
593 /*_______________D3DXVec3CatmullRom____________________*/
594 expectedvec
.x
= 1458.0f
; expectedvec
.y
= 22.1875f
; expectedvec
.z
= 4141.375f
;
595 D3DXVec3CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
596 expect_vec3(expectedvec
,gotvec
);
598 /*_______________D3DXVec3Cross________________________*/
599 expectedvec
.x
= -18.0f
; expectedvec
.y
= 40.0f
; expectedvec
.z
= -39.0f
;
600 D3DXVec3Cross(&gotvec
,&u
,&v
);
601 expect_vec3(expectedvec
,gotvec
);
602 /* Tests the case NULL */
603 funcpointer
= D3DXVec3Cross(&gotvec
,NULL
,&v
);
604 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
605 funcpointer
= D3DXVec3Cross(NULL
,NULL
,NULL
);
606 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
608 /*_______________D3DXVec3Dot__________________________*/
610 got
= D3DXVec3Dot(&u
,&v
);
611 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
612 /* Tests the case NULL */
614 got
= D3DXVec3Dot(NULL
,&v
);
615 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
617 got
= D3DXVec3Dot(NULL
,NULL
);
618 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
620 /*_______________D3DXVec3Hermite__________________________*/
621 expectedvec
.x
= -6045.75f
; expectedvec
.y
= -6650.0f
; expectedvec
.z
= 1358.875f
;
622 D3DXVec3Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
623 expect_vec3(expectedvec
,gotvec
);
625 /*_______________D3DXVec3Length__________________________*/
627 got
= D3DXVec3Length(&u
);
628 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
629 /* Tests the case NULL */
631 got
= D3DXVec3Length(NULL
);
632 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
634 /*_______________D3DXVec3LengthSq________________________*/
636 got
= D3DXVec3LengthSq(&u
);
637 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
638 /* Tests the case NULL */
640 got
= D3DXVec3LengthSq(NULL
);
641 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
643 /*_______________D3DXVec3Lerp__________________________*/
644 expectedvec
.x
= 54.5f
; expectedvec
.y
= 64.5f
, expectedvec
.z
= 41.0f
;
645 D3DXVec3Lerp(&gotvec
,&u
,&v
,scale
);
646 expect_vec3(expectedvec
,gotvec
);
647 /* Tests the case NULL */
648 funcpointer
= D3DXVec3Lerp(&gotvec
,NULL
,&v
,scale
);
649 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
650 funcpointer
= D3DXVec3Lerp(NULL
,NULL
,NULL
,scale
);
651 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
653 /*_______________D3DXVec3Maximize__________________________*/
654 expectedvec
.x
= 9.0f
; expectedvec
.y
= 6.0f
; expectedvec
.z
= 2.0f
;
655 D3DXVec3Maximize(&gotvec
,&u
,&v
);
656 expect_vec3(expectedvec
,gotvec
);
657 /* Tests the case NULL */
658 funcpointer
= D3DXVec3Maximize(&gotvec
,NULL
,&v
);
659 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
660 funcpointer
= D3DXVec3Maximize(NULL
,NULL
,NULL
);
661 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
663 /*_______________D3DXVec3Minimize__________________________*/
664 expectedvec
.x
= 2.0f
; expectedvec
.y
= -3.0f
; expectedvec
.z
= -4.0f
;
665 D3DXVec3Minimize(&gotvec
,&u
,&v
);
666 expect_vec3(expectedvec
,gotvec
);
667 /* Tests the case NULL */
668 funcpointer
= D3DXVec3Minimize(&gotvec
,NULL
,&v
);
669 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
670 funcpointer
= D3DXVec3Minimize(NULL
,NULL
,NULL
);
671 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
673 /*_______________D3DXVec3Normalize_________________________*/
674 expectedvec
.x
= 9.0f
/11.0f
; expectedvec
.y
= 6.0f
/11.0f
; expectedvec
.z
= 2.0f
/11.0f
;
675 D3DXVec3Normalize(&gotvec
,&u
);
676 expect_vec3(expectedvec
,gotvec
);
677 /* Test the nul vector */
678 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
;
679 D3DXVec3Normalize(&gotvec
,&nul
);
680 expect_vec3(expectedvec
,gotvec
);
682 /*_______________D3DXVec3Scale____________________________*/
683 expectedvec
.x
= -58.5f
; expectedvec
.y
= -39.0f
; expectedvec
.z
= -13.0f
;
684 D3DXVec3Scale(&gotvec
,&u
,scale
);
685 expect_vec3(expectedvec
,gotvec
);
686 /* Tests the case NULL */
687 funcpointer
= D3DXVec3Scale(&gotvec
,NULL
,scale
);
688 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
689 funcpointer
= D3DXVec3Scale(NULL
,NULL
,scale
);
690 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
692 /*_______________D3DXVec3Subtract_______________________*/
693 expectedvec
.x
= 7.0f
; expectedvec
.y
= 9.0f
; expectedvec
.z
= 6.0f
;
694 D3DXVec3Subtract(&gotvec
,&u
,&v
);
695 expect_vec3(expectedvec
,gotvec
);
696 /* Tests the case NULL */
697 funcpointer
= D3DXVec3Subtract(&gotvec
,NULL
,&v
);
698 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
699 funcpointer
= D3DXVec3Subtract(NULL
,NULL
,NULL
);
700 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
702 /*_______________D3DXVec3Transform_______________________*/
703 expectedtrans
.x
= 70.0f
; expectedtrans
.y
= 88.0f
; expectedtrans
.z
= 106.0f
; expectedtrans
.w
= 124.0f
;
704 D3DXVec3Transform(&gottrans
,&u
,&mat
);
705 expect_vec4(expectedtrans
,gottrans
);
707 /*_______________D3DXVec3TransformCoord_______________________*/
708 expectedvec
.x
= 70.0f
/124.0f
; expectedvec
.y
= 88.0f
/124.0f
; expectedvec
.z
= 106.0f
/124.0f
;
709 D3DXVec3TransformCoord(&gotvec
,&u
,&mat
);
710 expect_vec3(expectedvec
,gotvec
);
711 /* Test the nul projected vector */
712 nulproj
.x
= 1.0f
; nulproj
.y
= -1.0f
, nulproj
.z
= -1.0f
;
713 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
;
714 D3DXVec3TransformCoord(&gotvec
,&nulproj
,&mat
);
715 expect_vec3(expectedvec
,gotvec
);
717 /*_______________D3DXVec3TransformNormal______________________*/
718 expectedvec
.x
= 57.0f
; expectedvec
.y
= 74.0f
; expectedvec
.z
= 91.0f
;
719 D3DXVec3TransformNormal(&gotvec
,&u
,&mat
);
720 expect_vec3(expectedvec
,gotvec
);
723 static void D3X8Vector4Test(void)
725 D3DXVECTOR4 expectedvec
, gotvec
, nul
, u
, v
, w
, x
;
726 LPD3DXVECTOR4 funcpointer
;
727 D3DXVECTOR4 expectedtrans
, gottrans
;
729 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
731 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
; nul
.w
= 0.0f
;
732 u
.x
= 1.0f
; u
.y
= 2.0f
; u
.z
= 4.0f
; u
.w
= 10.0;
733 v
.x
= -3.0f
; v
.y
= 4.0f
; v
.z
= -5.0f
; v
.w
= 7.0;
734 w
.x
= 4.0f
; w
.y
=6.0f
; w
.z
= -2.0f
; w
.w
= 1.0f
;
735 x
.x
= 6.0f
; x
.y
= -7.0f
; x
.z
=8.0f
; x
.w
= -9.0f
;
737 mat
.m
[0][0] = 1.0f
; mat
.m
[0][1] = 2.0f
; mat
.m
[0][2] = 3.0f
; mat
.m
[0][3] = 4.0f
;
738 mat
.m
[1][0] = 5.0f
; mat
.m
[1][1] = 6.0f
; mat
.m
[1][2] = 7.0f
; mat
.m
[1][3] = 8.0f
;
739 mat
.m
[2][0] = 9.0f
; mat
.m
[2][1] = 10.0f
; mat
.m
[2][2] = 11.0f
; mat
.m
[2][3] = 12.0f
;
740 mat
.m
[3][0] = 13.0f
; mat
.m
[3][1] = 14.0f
; mat
.m
[3][2] = 15.0f
; mat
.m
[3][3] = 16.0f
;
742 coeff1
= 2.0f
; coeff2
= 5.0;
745 /*_______________D3DXVec4Add__________________________*/
746 expectedvec
.x
= -2.0f
; expectedvec
.y
= 6.0f
; expectedvec
.z
= -1.0f
; expectedvec
.w
= 17.0f
;
747 D3DXVec4Add(&gotvec
,&u
,&v
);
748 expect_vec4(expectedvec
,gotvec
);
749 /* Tests the case NULL */
750 funcpointer
= D3DXVec4Add(&gotvec
,NULL
,&v
);
751 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
752 funcpointer
= D3DXVec4Add(NULL
,NULL
,NULL
);
753 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
755 /*_______________D3DXVec4BaryCentric____________________*/
756 expectedvec
.x
= 8.0f
; expectedvec
.y
= 26.0; expectedvec
.z
= -44.0f
; expectedvec
.w
= -41.0f
;
757 D3DXVec4BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
758 expect_vec4(expectedvec
,gotvec
);
760 /*_______________D3DXVec4CatmullRom____________________*/
761 expectedvec
.x
= 2754.625f
; expectedvec
.y
= 2367.5625f
; expectedvec
.z
= 1060.1875f
; expectedvec
.w
= 131.3125f
;
762 D3DXVec4CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
763 expect_vec4(expectedvec
,gotvec
);
765 /*_______________D3DXVec4Cross_________________________*/
766 expectedvec
.x
= 390.0f
; expectedvec
.y
= -393.0f
; expectedvec
.z
= -316.0f
; expectedvec
.w
= 166.0f
;
767 D3DXVec4Cross(&gotvec
,&u
,&v
,&w
);
768 expect_vec4(expectedvec
,gotvec
);
770 /*_______________D3DXVec4Dot__________________________*/
772 got
= D3DXVec4Dot(&u
,&v
);
773 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
774 /* Tests the case NULL */
776 got
= D3DXVec4Dot(NULL
,&v
);
777 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
779 got
= D3DXVec4Dot(NULL
,NULL
);
780 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
782 /*_______________D3DXVec4Hermite_________________________*/
783 expectedvec
.x
= 1224.625f
; expectedvec
.y
= 3461.625f
; expectedvec
.z
= -4758.875f
; expectedvec
.w
= -5781.5f
;
784 D3DXVec4Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
785 expect_vec4(expectedvec
,gotvec
);
787 /*_______________D3DXVec4Length__________________________*/
789 got
= D3DXVec4Length(&u
);
790 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
791 /* Tests the case NULL */
793 got
= D3DXVec4Length(NULL
);
794 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
796 /*_______________D3DXVec4LengthSq________________________*/
798 got
= D3DXVec4LengthSq(&u
);
799 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
800 /* Tests the case NULL */
802 got
= D3DXVec4LengthSq(NULL
);
803 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
805 /*_______________D3DXVec4Lerp__________________________*/
806 expectedvec
.x
= 27.0f
; expectedvec
.y
= -11.0f
; expectedvec
.z
= 62.5; expectedvec
.w
= 29.5;
807 D3DXVec4Lerp(&gotvec
,&u
,&v
,scale
);
808 expect_vec4(expectedvec
,gotvec
);
809 /* Tests the case NULL */
810 funcpointer
= D3DXVec4Lerp(&gotvec
,NULL
,&v
,scale
);
811 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
812 funcpointer
= D3DXVec4Lerp(NULL
,NULL
,NULL
,scale
);
813 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
815 /*_______________D3DXVec4Maximize__________________________*/
816 expectedvec
.x
= 1.0f
; expectedvec
.y
= 4.0f
; expectedvec
.z
= 4.0f
; expectedvec
.w
= 10.0;
817 D3DXVec4Maximize(&gotvec
,&u
,&v
);
818 expect_vec4(expectedvec
,gotvec
);
819 /* Tests the case NULL */
820 funcpointer
= D3DXVec4Maximize(&gotvec
,NULL
,&v
);
821 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
822 funcpointer
= D3DXVec4Maximize(NULL
,NULL
,NULL
);
823 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
825 /*_______________D3DXVec4Minimize__________________________*/
826 expectedvec
.x
= -3.0f
; expectedvec
.y
= 2.0f
; expectedvec
.z
= -5.0f
; expectedvec
.w
= 7.0;
827 D3DXVec4Minimize(&gotvec
,&u
,&v
);
828 expect_vec4(expectedvec
,gotvec
);
829 /* Tests the case NULL */
830 funcpointer
= D3DXVec4Minimize(&gotvec
,NULL
,&v
);
831 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
832 funcpointer
= D3DXVec4Minimize(NULL
,NULL
,NULL
);
833 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
835 /*_______________D3DXVec4Normalize_________________________*/
836 expectedvec
.x
= 1.0f
/11.0f
; expectedvec
.y
= 2.0f
/11.0f
; expectedvec
.z
= 4.0f
/11.0f
; expectedvec
.w
= 10.0f
/11.0f
;
837 D3DXVec4Normalize(&gotvec
,&u
);
838 expect_vec4(expectedvec
,gotvec
);
839 /* Test the nul vector */
840 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
; expectedvec
.w
= 0.0f
;
841 D3DXVec4Normalize(&gotvec
,&nul
);
842 expect_vec4(expectedvec
,gotvec
);
844 /*_______________D3DXVec4Scale____________________________*/
845 expectedvec
.x
= -6.5f
; expectedvec
.y
= -13.0f
; expectedvec
.z
= -26.0f
; expectedvec
.w
= -65.0f
;
846 D3DXVec4Scale(&gotvec
,&u
,scale
);
847 expect_vec4(expectedvec
,gotvec
);
848 /* Tests the case NULL */
849 funcpointer
= D3DXVec4Scale(&gotvec
,NULL
,scale
);
850 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
851 funcpointer
= D3DXVec4Scale(NULL
,NULL
,scale
);
852 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
854 /*_______________D3DXVec4Subtract__________________________*/
855 expectedvec
.x
= 4.0f
; expectedvec
.y
= -2.0f
; expectedvec
.z
= 9.0f
; expectedvec
.w
= 3.0f
;
856 D3DXVec4Subtract(&gotvec
,&u
,&v
);
857 expect_vec4(expectedvec
,gotvec
);
858 /* Tests the case NULL */
859 funcpointer
= D3DXVec4Subtract(&gotvec
,NULL
,&v
);
860 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
861 funcpointer
= D3DXVec4Subtract(NULL
,NULL
,NULL
);
862 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
864 /*_______________D3DXVec4Transform_______________________*/
865 expectedtrans
.x
= 177.0f
; expectedtrans
.y
= 194.0f
; expectedtrans
.z
= 211.0f
; expectedtrans
.w
= 228.0f
;
866 D3DXVec4Transform(&gottrans
,&u
,&mat
);
867 expect_vec4(expectedtrans
,gottrans
);
875 D3X8QuaternionTest();