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
;
155 FLOAT angle
, expectedfloat
, gotfloat
;
157 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
158 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
159 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
160 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
161 U(mat
).m
[0][0] = 10.0f
; U(mat
).m
[1][1] = 20.0f
; U(mat
).m
[2][2] = 30.0f
;
162 U(mat
).m
[3][3] = -40.0f
;
164 mat2
.m
[0][0] = 1.0f
; mat2
.m
[1][0] = 2.0f
; mat2
.m
[2][0] = 3.0f
;
165 mat2
.m
[3][0] = 4.0f
; mat2
.m
[0][1] = 5.0f
; mat2
.m
[1][1] = 6.0f
;
166 mat2
.m
[2][1] = 7.0f
; mat2
.m
[3][1] = 8.0f
; mat2
.m
[0][2] = -8.0f
;
167 mat2
.m
[1][2] = -7.0f
; mat2
.m
[2][2] = -6.0f
; mat2
.m
[3][2] = -5.0f
;
168 mat2
.m
[0][3] = -4.0f
; mat2
.m
[1][3] = -3.0f
; mat2
.m
[2][3] = -2.0f
;
169 mat2
.m
[3][3] = -1.0f
;
171 q
.x
= 1.0f
; q
.y
= -4.0f
; q
.z
=7.0f
; q
.w
= -11.0f
;
173 axis
.x
= 1.0f
; axis
.y
= -3.0f
; axis
.z
= 7.0f
;
175 angle
= D3DX_PI
/3.0f
;
177 /*____________D3DXMatrixfDeterminant_____________*/
178 expectedfloat
= -147888.0f
;
179 gotfloat
= D3DXMatrixfDeterminant(&mat
);
180 ok(fabs( gotfloat
- expectedfloat
) < admitted_error
, "Expected: %f, Got: %f\n", expectedfloat
, gotfloat
);
182 /*____________D3DXMatrixIsIdentity______________*/
184 got
= D3DXMatrixIsIdentity(&mat3
);
185 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
186 D3DXMatrixIdentity(&mat3
);
188 got
= D3DXMatrixIsIdentity(&mat3
);
189 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
190 U(mat3
).m
[0][0] = 0.000009f
;
192 got
= D3DXMatrixIsIdentity(&mat3
);
193 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
194 /* Test the NULL case */
196 got
= D3DXMatrixIsIdentity(NULL
);
197 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
199 /*____________D3DXMatrixMultiply______________*/
200 expectedmat
.m
[0][0] = 73.0f
; expectedmat
.m
[0][1] = 193.0f
; expectedmat
.m
[0][2] = -197.0f
; expectedmat
.m
[0][3] = -77.0f
;
201 expectedmat
.m
[1][0] = 231.0f
; expectedmat
.m
[1][1] = 551.0f
; expectedmat
.m
[1][2] = -489.0f
; expectedmat
.m
[1][3] = -169.0;
202 expectedmat
.m
[2][0] = 239.0f
; expectedmat
.m
[2][1] = 523.0f
; expectedmat
.m
[2][2] = -400.0f
; expectedmat
.m
[2][3] = -116.0f
;
203 expectedmat
.m
[3][0] = -164.0f
; expectedmat
.m
[3][1] = -320.0f
; expectedmat
.m
[3][2] = 187.0f
; expectedmat
.m
[3][3] = 31.0f
;
204 D3DXMatrixMultiply(&gotmat
,&mat
,&mat2
);
205 expect_mat(expectedmat
,gotmat
);
207 /*____________D3DXMatrixRotationRotationAxis_____*/
208 expectedmat
.m
[0][0] = 0.508475f
; expectedmat
.m
[0][1] = 0.763805f
; expectedmat
.m
[0][2] = 0.397563f
; expectedmat
.m
[0][3] = 0.0f
;
209 expectedmat
.m
[1][0] = -0.814652f
; expectedmat
.m
[1][1] = 0.576271f
; expectedmat
.m
[1][2] = -0.065219f
; expectedmat
.m
[1][3] = 0.0f
;
210 expectedmat
.m
[2][0] = -0.278919f
; expectedmat
.m
[2][1] = -0.290713f
; expectedmat
.m
[2][2] = 0.915254f
; expectedmat
.m
[2][3] = 0.0f
;
211 expectedmat
.m
[3][0] = 0.0f
; expectedmat
.m
[3][1] = 0.0f
; expectedmat
.m
[3][2] = 0.0f
; expectedmat
.m
[3][3] = 1.0f
;
212 D3DXMatrixRotationAxis(&gotmat
,&axis
,angle
);
213 expect_mat(expectedmat
,gotmat
);
215 /*____________D3DXMatrixRotationQuaternion______________*/
216 expectedmat
.m
[0][0] = -129.0f
; expectedmat
.m
[0][1] = -162.0f
; expectedmat
.m
[0][2] = -74.0f
; expectedmat
.m
[0][3] = 0.0f
;
217 expectedmat
.m
[1][0] = 146.0f
; expectedmat
.m
[1][1] = -99.0f
; expectedmat
.m
[1][2] = -78.0f
; expectedmat
.m
[1][3] = 0.0f
;
218 expectedmat
.m
[2][0] = 102.0f
; expectedmat
.m
[2][1] = -34.0f
; expectedmat
.m
[2][2] = -33.0f
; expectedmat
.m
[2][3] = 0.0f
;
219 expectedmat
.m
[3][0] = 0.0f
; expectedmat
.m
[3][1] = 0.0f
; expectedmat
.m
[3][2] = 0.0f
; expectedmat
.m
[3][3] = 1.0f
;
220 D3DXMatrixRotationQuaternion(&gotmat
,&q
);
221 expect_mat(expectedmat
,gotmat
);
223 /*____________D3DXMatrixRotationX______________*/
224 expectedmat
.m
[0][0] = 1.0f
; expectedmat
.m
[0][1] = 0.0f
; expectedmat
.m
[0][2] = 0.0f
; expectedmat
.m
[0][3] = 0.0f
;
225 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
;
226 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
;
227 expectedmat
.m
[3][0] = 0.0f
; expectedmat
.m
[3][1] = 0.0f
; expectedmat
.m
[3][2] = 0.0f
; expectedmat
.m
[3][3] = 1.0f
;
228 D3DXMatrixRotationX(&gotmat
,angle
);
229 expect_mat(expectedmat
,gotmat
);
231 /*____________D3DXMatrixRotationY______________*/
232 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
;
233 expectedmat
.m
[1][0] = 0.0; expectedmat
.m
[1][1] = 1.0f
; expectedmat
.m
[1][2] = 0.0f
; expectedmat
.m
[1][3] = 0.0f
;
234 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
;
235 expectedmat
.m
[3][0] = 0.0f
; expectedmat
.m
[3][1] = 0.0f
; expectedmat
.m
[3][2] = 0.0f
; expectedmat
.m
[3][3] = 1.0f
;
236 D3DXMatrixRotationY(&gotmat
,angle
);
237 expect_mat(expectedmat
,gotmat
);
239 /*____________D3DXMatrixRotationYawPitchRoll____*/
240 expectedmat
.m
[0][0] = 0.888777f
; expectedmat
.m
[0][1] = 0.091875f
; expectedmat
.m
[0][2] = -0.449037f
; expectedmat
.m
[0][3] = 0.0f
;
241 expectedmat
.m
[1][0] = 0.351713f
; expectedmat
.m
[1][1] = 0.491487f
; expectedmat
.m
[1][2] = 0.796705f
; expectedmat
.m
[1][3] = 0.0f
;
242 expectedmat
.m
[2][0] = 0.293893f
; expectedmat
.m
[2][1] = -0.866025f
; expectedmat
.m
[2][2] = 0.404509f
; expectedmat
.m
[2][3] = 0.0f
;
243 expectedmat
.m
[3][0] = 0.0f
; expectedmat
.m
[3][1] = 0.0f
; expectedmat
.m
[3][2] = 0.0f
; expectedmat
.m
[3][3] = 1.0f
;
244 D3DXMatrixRotationYawPitchRoll(&gotmat
, 3.0f
*angle
/5.0f
, angle
, 3.0f
*angle
/17.0f
);
245 expect_mat(expectedmat
,gotmat
);
247 /*____________D3DXMatrixRotationZ______________*/
248 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
;
249 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
;
250 expectedmat
.m
[2][0] = 0.0f
; expectedmat
.m
[2][1] = 0.0f
; expectedmat
.m
[2][2] = 1.0f
; expectedmat
.m
[2][3] = 0.0f
;
251 expectedmat
.m
[3][0] = 0.0f
; expectedmat
.m
[3][1] = 0.0f
; expectedmat
.m
[3][2] = 0.0f
; expectedmat
.m
[3][3] = 1.0f
;
252 D3DXMatrixRotationZ(&gotmat
,angle
);
253 expect_mat(expectedmat
,gotmat
);
255 /*____________D3DXMatrixScaling______________*/
256 expectedmat
.m
[0][0] = 0.69f
; expectedmat
.m
[0][1] = 0.0f
; expectedmat
.m
[0][2] = 0.0f
; expectedmat
.m
[0][3] = 0.0f
;
257 expectedmat
.m
[1][0] = 0.0; expectedmat
.m
[1][1] = 0.53f
; expectedmat
.m
[1][2] = 0.0f
; expectedmat
.m
[1][3] = 0.0f
;
258 expectedmat
.m
[2][0] = 0.0f
; expectedmat
.m
[2][1] = 0.0f
; expectedmat
.m
[2][2] = 4.11f
; expectedmat
.m
[2][3] = 0.0f
;
259 expectedmat
.m
[3][0] = 0.0f
; expectedmat
.m
[3][1] = 0.0f
; expectedmat
.m
[3][2] = 0.0f
; expectedmat
.m
[3][3] = 1.0f
;
260 D3DXMatrixScaling(&gotmat
,0.69f
,0.53f
,4.11f
);
261 expect_mat(expectedmat
,gotmat
);
263 /*____________D3DXMatrixTranslation______________*/
264 expectedmat
.m
[0][0] = 1.0f
; expectedmat
.m
[0][1] = 0.0f
; expectedmat
.m
[0][2] = 0.0f
; expectedmat
.m
[0][3] = 0.0f
;
265 expectedmat
.m
[1][0] = 0.0; expectedmat
.m
[1][1] = 1.0f
; expectedmat
.m
[1][2] = 0.0f
; expectedmat
.m
[1][3] = 0.0f
;
266 expectedmat
.m
[2][0] = 0.0f
; expectedmat
.m
[2][1] = 0.0f
; expectedmat
.m
[2][2] = 1.0f
; expectedmat
.m
[2][3] = 0.0f
;
267 expectedmat
.m
[3][0] = 0.69f
; expectedmat
.m
[3][1] = 0.53f
; expectedmat
.m
[3][2] = 4.11f
; expectedmat
.m
[3][3] = 1.0f
;
268 D3DXMatrixTranslation(&gotmat
,0.69f
,0.53f
,4.11f
);
269 expect_mat(expectedmat
,gotmat
);
271 /*____________D3DXMatrixTranspose______________*/
272 expectedmat
.m
[0][0] = 10.0f
; expectedmat
.m
[0][1] = 11.0f
; expectedmat
.m
[0][2] = 19.0f
; expectedmat
.m
[0][3] = 2.0f
;
273 expectedmat
.m
[1][0] = 5.0; expectedmat
.m
[1][1] = 20.0f
; expectedmat
.m
[1][2] = -21.0f
; expectedmat
.m
[1][3] = 3.0f
;
274 expectedmat
.m
[2][0] = 7.0f
; expectedmat
.m
[2][1] = 16.0f
; expectedmat
.m
[2][2] = 30.f
; expectedmat
.m
[2][3] = -4.0f
;
275 expectedmat
.m
[3][0] = 8.0f
; expectedmat
.m
[3][1] = 33.0f
; expectedmat
.m
[3][2] = 43.0f
; expectedmat
.m
[3][3] = -40.0f
;
276 D3DXMatrixTranspose(&gotmat
,&mat
);
277 expect_mat(expectedmat
,gotmat
);
280 static void D3DXPlaneTest(void)
286 plane
.a
= -3.0f
; plane
.b
= -1.0f
; plane
.c
= 4.0f
; plane
.d
= 7.0f
;
287 vec
.x
= 2.0f
; vec
.y
= 5.0f
; vec
.z
= -6.0f
; vec
.w
= 11.0f
;
289 /*_______________D3DXPlaneDot________________*/
291 got
= D3DXPlaneDot(&plane
,&vec
),
292 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
294 got
= D3DXPlaneDot(NULL
,&vec
),
295 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
297 got
= D3DXPlaneDot(NULL
,NULL
),
298 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
300 /*_______________D3DXPlaneDotCoord________________*/
302 got
= D3DXPlaneDotCoord(&plane
,&vec
),
303 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
305 got
= D3DXPlaneDotCoord(NULL
,&vec
),
306 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
308 got
= D3DXPlaneDotCoord(NULL
,NULL
),
309 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
311 /*_______________D3DXPlaneDotNormal______________*/
313 got
= D3DXPlaneDotNormal(&plane
,&vec
),
314 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
316 got
= D3DXPlaneDotNormal(NULL
,&vec
),
317 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
319 got
= D3DXPlaneDotNormal(NULL
,NULL
),
320 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
323 static void D3X8QuaternionTest(void)
325 D3DXQUATERNION expectedquat
, gotquat
, nul
, q
, r
, s
;
326 LPD3DXQUATERNION funcpointer
;
328 BOOL expectedbool
, gotbool
;
330 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
; nul
.w
= 0.0f
;
331 q
.x
= 1.0f
, q
.y
= 2.0f
; q
.z
= 4.0f
; q
.w
= 10.0f
;
332 r
.x
= -3.0f
; r
.y
= 4.0f
; r
.z
= -5.0f
; r
.w
= 7.0;
334 /*_______________D3DXQuaternionConjugate________________*/
335 expectedquat
.x
= -1.0f
; expectedquat
.y
= -2.0f
; expectedquat
.z
= -4.0f
; expectedquat
.w
= 10.0f
;
336 D3DXQuaternionConjugate(&gotquat
,&q
);
337 expect_vec4(expectedquat
,gotquat
);
338 /* Test the NULL case */
339 funcpointer
= D3DXQuaternionConjugate(&gotquat
,NULL
);
340 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
341 funcpointer
= D3DXQuaternionConjugate(NULL
,NULL
);
342 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
344 /*_______________D3DXQuaternionDot______________________*/
346 got
= D3DXQuaternionDot(&q
,&r
);
347 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
348 /* Tests the case NULL */
350 got
= D3DXQuaternionDot(NULL
,&r
);
351 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
353 got
= D3DXQuaternionDot(NULL
,NULL
);
354 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
356 /*_______________D3DXQuaternionIdentity________________*/
357 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 1.0f
;
358 D3DXQuaternionIdentity(&gotquat
);
359 expect_vec4(expectedquat
,gotquat
);
360 /* Test the NULL case */
361 funcpointer
= D3DXQuaternionIdentity(NULL
);
362 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
364 /*_______________D3DXQuaternionIsIdentity________________*/
365 s
.x
= 0.0f
; s
.y
= 0.0f
; s
.z
= 0.0f
; s
.w
= 1.0f
;
367 gotbool
= D3DXQuaternionIsIdentity(&s
);
368 ok( expectedbool
== gotbool
, "Expected boolean : %d, Got bool : %d\n", expectedbool
, gotbool
);
369 s
.x
= 2.3f
; s
.y
= -4.2f
; s
.z
= 1.2f
; s
.w
=0.2f
;
370 expectedbool
= FALSE
;
371 gotbool
= D3DXQuaternionIsIdentity(&q
);
372 ok( expectedbool
== gotbool
, "Expected boolean : %d, Got bool : %d\n", expectedbool
, gotbool
);
373 /* Test the NULL case */
374 gotbool
= D3DXQuaternionIsIdentity(NULL
);
375 ok(gotbool
== FALSE
, "Expected boolean: %d, Got boolean: %d\n", FALSE
, gotbool
);
377 /*_______________D3DXQuaternionLength__________________________*/
379 got
= D3DXQuaternionLength(&q
);
380 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
381 /* Tests the case NULL */
383 got
= D3DXQuaternionLength(NULL
);
384 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
386 /*_______________D3DXQuaternionLengthSq________________________*/
388 got
= D3DXQuaternionLengthSq(&q
);
389 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
390 /* Tests the case NULL */
392 got
= D3DXQuaternionLengthSq(NULL
);
393 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
395 /*_______________D3DXQuaternionNormalize________________________*/
396 expectedquat
.x
= 1.0f
/11.0f
; expectedquat
.y
= 2.0f
/11.0f
; expectedquat
.z
= 4.0f
/11.0f
; expectedquat
.w
= 10.0f
/11.0f
;
397 D3DXQuaternionNormalize(&gotquat
,&q
);
398 expect_vec4(expectedquat
,gotquat
);
399 /* Test the nul quaternion */
400 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.0f
;
401 D3DXQuaternionNormalize(&gotquat
,&nul
);
402 expect_vec4(expectedquat
,gotquat
);
405 static void D3X8Vector2Test(void)
407 D3DXVECTOR2 expectedvec
, gotvec
, nul
, nulproj
, u
, v
, w
, x
;
408 LPD3DXVECTOR2 funcpointer
;
409 D3DXVECTOR4 expectedtrans
, gottrans
;
411 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
413 nul
.x
= 0.0f
; nul
.y
= 0.0f
;
414 u
.x
= 3.0f
; u
.y
= 4.0f
;
415 v
.x
= -7.0f
; v
.y
= 9.0f
;
416 w
.x
= 4.0f
; w
.y
= -3.0f
;
417 x
.x
= 2.0f
; x
.y
= -11.0f
;
419 mat
.m
[0][0] = 1.0f
; mat
.m
[0][1] = 2.0f
; mat
.m
[0][2] = 3.0f
; mat
.m
[0][3] = 4.0f
;
420 mat
.m
[1][0] = 5.0f
; mat
.m
[1][1] = 6.0f
; mat
.m
[1][2] = 7.0f
; mat
.m
[1][3] = 8.0f
;
421 mat
.m
[2][0] = 9.0f
; mat
.m
[2][1] = 10.0f
; mat
.m
[2][2] = 11.0f
; mat
.m
[2][3] = 12.0f
;
422 mat
.m
[3][0] = 13.0f
; mat
.m
[3][1] = 14.0f
; mat
.m
[3][2] = 15.0f
; mat
.m
[3][3] = 16.0f
;
424 coeff1
= 2.0f
; coeff2
= 5.0f
;
427 /*_______________D3DXVec2Add__________________________*/
428 expectedvec
.x
= -4.0f
; expectedvec
.y
= 13.0f
;
429 D3DXVec2Add(&gotvec
,&u
,&v
);
430 expect_vec(expectedvec
,gotvec
);
431 /* Tests the case NULL */
432 funcpointer
= D3DXVec2Add(&gotvec
,NULL
,&v
);
433 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
434 funcpointer
= D3DXVec2Add(NULL
,NULL
,NULL
);
435 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
437 /*_______________D3DXVec2BaryCentric___________________*/
438 expectedvec
.x
= -12.0f
; expectedvec
.y
= -21.0f
;
439 D3DXVec2BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
440 expect_vec(expectedvec
,gotvec
);
442 /*_______________D3DXVec2CatmullRom____________________*/
443 expectedvec
.x
= 5820.25f
; expectedvec
.y
= -3654.5625f
;
444 D3DXVec2CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
445 expect_vec(expectedvec
,gotvec
);
447 /*_______________D3DXVec2CCW__________________________*/
449 got
= D3DXVec2CCW(&u
,&v
);
450 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
451 /* Tests the case NULL */
453 got
= D3DXVec2CCW(NULL
,&v
);
454 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
456 got
= D3DXVec2CCW(NULL
,NULL
);
457 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
459 /*_______________D3DXVec2Dot__________________________*/
461 got
= D3DXVec2Dot(&u
,&v
);
462 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
463 /* Tests the case NULL */
465 got
= D3DXVec2Dot(NULL
,&v
);
466 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
468 got
= D3DXVec2Dot(NULL
,NULL
);
469 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
471 /*_______________D3DXVec2Hermite__________________________*/
472 expectedvec
.x
= 2604.625f
; expectedvec
.y
= -4533.0f
;
473 D3DXVec2Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
474 expect_vec(expectedvec
,gotvec
);
476 /*_______________D3DXVec2Length__________________________*/
478 got
= D3DXVec2Length(&u
);
479 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
480 /* Tests the case NULL */
482 got
= D3DXVec2Length(NULL
);
483 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
485 /*_______________D3DXVec2LengthSq________________________*/
487 got
= D3DXVec2LengthSq(&u
);
488 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
489 /* Tests the case NULL */
491 got
= D3DXVec2LengthSq(NULL
);
492 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
494 /*_______________D3DXVec2Lerp__________________________*/
495 expectedvec
.x
= 68.0f
; expectedvec
.y
= -28.5f
;
496 D3DXVec2Lerp(&gotvec
,&u
,&v
,scale
);
497 expect_vec(expectedvec
,gotvec
);
498 /* Tests the case NULL */
499 funcpointer
= D3DXVec2Lerp(&gotvec
,NULL
,&v
,scale
);
500 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
501 funcpointer
= D3DXVec2Lerp(NULL
,NULL
,NULL
,scale
);
502 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
504 /*_______________D3DXVec2Maximize__________________________*/
505 expectedvec
.x
= 3.0f
; expectedvec
.y
= 9.0f
;
506 D3DXVec2Maximize(&gotvec
,&u
,&v
);
507 expect_vec(expectedvec
,gotvec
);
508 /* Tests the case NULL */
509 funcpointer
= D3DXVec2Maximize(&gotvec
,NULL
,&v
);
510 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
511 funcpointer
= D3DXVec2Maximize(NULL
,NULL
,NULL
);
512 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
514 /*_______________D3DXVec2Minimize__________________________*/
515 expectedvec
.x
= -7.0f
; expectedvec
.y
= 4.0f
;
516 D3DXVec2Minimize(&gotvec
,&u
,&v
);
517 expect_vec(expectedvec
,gotvec
);
518 /* Tests the case NULL */
519 funcpointer
= D3DXVec2Minimize(&gotvec
,NULL
,&v
);
520 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
521 funcpointer
= D3DXVec2Minimize(NULL
,NULL
,NULL
);
522 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
524 /*_______________D3DXVec2Normalize_________________________*/
525 expectedvec
.x
= 0.6f
; expectedvec
.y
= 0.8f
;
526 D3DXVec2Normalize(&gotvec
,&u
);
527 expect_vec(expectedvec
,gotvec
);
528 /* Test the nul vector */
529 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
;
530 D3DXVec2Normalize(&gotvec
,&nul
);
531 expect_vec(expectedvec
,gotvec
);
533 /*_______________D3DXVec2Scale____________________________*/
534 expectedvec
.x
= -19.5f
; expectedvec
.y
= -26.0f
;
535 D3DXVec2Scale(&gotvec
,&u
,scale
);
536 expect_vec(expectedvec
,gotvec
);
537 /* Tests the case NULL */
538 funcpointer
= D3DXVec2Scale(&gotvec
,NULL
,scale
);
539 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
540 funcpointer
= D3DXVec2Scale(NULL
,NULL
,scale
);
541 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
543 /*_______________D3DXVec2Subtract__________________________*/
544 expectedvec
.x
= 10.0f
; expectedvec
.y
= -5.0f
;
545 D3DXVec2Subtract(&gotvec
,&u
,&v
);
546 expect_vec(expectedvec
,gotvec
);
547 /* Tests the case NULL */
548 funcpointer
= D3DXVec2Subtract(&gotvec
,NULL
,&v
);
549 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
550 funcpointer
= D3DXVec2Subtract(NULL
,NULL
,NULL
);
551 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
553 /*_______________D3DXVec2Transform_______________________*/
554 expectedtrans
.x
= 36.0f
; expectedtrans
.y
= 44.0f
; expectedtrans
.z
= 52.0f
; expectedtrans
.w
= 60.0f
;
555 D3DXVec2Transform(&gottrans
,&u
,&mat
);
556 expect_vec4(expectedtrans
,gottrans
);
558 /*_______________D3DXVec2TransformCoord_______________________*/
559 expectedvec
.x
= 0.6f
; expectedvec
.y
= 11.0f
/15.0f
;
560 D3DXVec2TransformCoord(&gotvec
,&u
,&mat
);
561 expect_vec(expectedvec
,gotvec
);
562 /* Test the nul projected vector */
563 nulproj
.x
= -2.0f
; nulproj
.y
= -1.0f
;
564 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
;
565 D3DXVec2TransformCoord(&gotvec
,&nulproj
,&mat
);
566 expect_vec(expectedvec
,gotvec
);
568 /*_______________D3DXVec2TransformNormal______________________*/
569 expectedvec
.x
= 23.0f
; expectedvec
.y
= 30.0f
;
570 D3DXVec2TransformNormal(&gotvec
,&u
,&mat
);
571 expect_vec(expectedvec
,gotvec
);
574 static void D3X8Vector3Test(void)
576 D3DXVECTOR3 expectedvec
, gotvec
, nul
, nulproj
, u
, v
, w
, x
;
577 LPD3DXVECTOR3 funcpointer
;
578 D3DXVECTOR4 expectedtrans
, gottrans
;
580 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
582 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
;
583 u
.x
= 9.0f
; u
.y
= 6.0f
; u
.z
= 2.0f
;
584 v
.x
= 2.0f
; v
.y
= -3.0f
; v
.z
= -4.0;
585 w
.x
= 3.0f
; w
.y
= -5.0f
; w
.z
= 7.0f
;
586 x
.x
= 4.0f
; x
.y
= 1.0f
; x
.z
= 11.0f
;
588 mat
.m
[0][0] = 1.0f
; mat
.m
[0][1] = 2.0f
; mat
.m
[0][2] = 3.0f
; mat
.m
[0][3] = 4.0f
;
589 mat
.m
[1][0] = 5.0f
; mat
.m
[1][1] = 6.0f
; mat
.m
[1][2] = 7.0f
; mat
.m
[1][3] = 8.0f
;
590 mat
.m
[2][0] = 9.0f
; mat
.m
[2][1] = 10.0f
; mat
.m
[2][2] = 11.0f
; mat
.m
[2][3] = 12.0f
;
591 mat
.m
[3][0] = 13.0f
; mat
.m
[3][1] = 14.0f
; mat
.m
[3][2] = 15.0f
; mat
.m
[3][3] = 16.0f
;
593 coeff1
= 2.0f
; coeff2
= 5.0f
;
596 /*_______________D3DXVec3Add__________________________*/
597 expectedvec
.x
= 11.0f
; expectedvec
.y
= 3.0f
; expectedvec
.z
= -2.0f
;
598 D3DXVec3Add(&gotvec
,&u
,&v
);
599 expect_vec3(expectedvec
,gotvec
);
600 /* Tests the case NULL */
601 funcpointer
= D3DXVec3Add(&gotvec
,NULL
,&v
);
602 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
603 funcpointer
= D3DXVec3Add(NULL
,NULL
,NULL
);
604 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
606 /*_______________D3DXVec3BaryCentric___________________*/
607 expectedvec
.x
= -35.0f
; expectedvec
.y
= -67.0; expectedvec
.z
= 15.0f
;
608 D3DXVec3BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
610 expect_vec3(expectedvec
,gotvec
);
612 /*_______________D3DXVec3CatmullRom____________________*/
613 expectedvec
.x
= 1458.0f
; expectedvec
.y
= 22.1875f
; expectedvec
.z
= 4141.375f
;
614 D3DXVec3CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
615 expect_vec3(expectedvec
,gotvec
);
617 /*_______________D3DXVec3Cross________________________*/
618 expectedvec
.x
= -18.0f
; expectedvec
.y
= 40.0f
; expectedvec
.z
= -39.0f
;
619 D3DXVec3Cross(&gotvec
,&u
,&v
);
620 expect_vec3(expectedvec
,gotvec
);
621 /* Tests the case NULL */
622 funcpointer
= D3DXVec3Cross(&gotvec
,NULL
,&v
);
623 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
624 funcpointer
= D3DXVec3Cross(NULL
,NULL
,NULL
);
625 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
627 /*_______________D3DXVec3Dot__________________________*/
629 got
= D3DXVec3Dot(&u
,&v
);
630 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
631 /* Tests the case NULL */
633 got
= D3DXVec3Dot(NULL
,&v
);
634 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
636 got
= D3DXVec3Dot(NULL
,NULL
);
637 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
639 /*_______________D3DXVec3Hermite__________________________*/
640 expectedvec
.x
= -6045.75f
; expectedvec
.y
= -6650.0f
; expectedvec
.z
= 1358.875f
;
641 D3DXVec3Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
642 expect_vec3(expectedvec
,gotvec
);
644 /*_______________D3DXVec3Length__________________________*/
646 got
= D3DXVec3Length(&u
);
647 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
648 /* Tests the case NULL */
650 got
= D3DXVec3Length(NULL
);
651 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
653 /*_______________D3DXVec3LengthSq________________________*/
655 got
= D3DXVec3LengthSq(&u
);
656 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
657 /* Tests the case NULL */
659 got
= D3DXVec3LengthSq(NULL
);
660 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
662 /*_______________D3DXVec3Lerp__________________________*/
663 expectedvec
.x
= 54.5f
; expectedvec
.y
= 64.5f
, expectedvec
.z
= 41.0f
;
664 D3DXVec3Lerp(&gotvec
,&u
,&v
,scale
);
665 expect_vec3(expectedvec
,gotvec
);
666 /* Tests the case NULL */
667 funcpointer
= D3DXVec3Lerp(&gotvec
,NULL
,&v
,scale
);
668 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
669 funcpointer
= D3DXVec3Lerp(NULL
,NULL
,NULL
,scale
);
670 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
672 /*_______________D3DXVec3Maximize__________________________*/
673 expectedvec
.x
= 9.0f
; expectedvec
.y
= 6.0f
; expectedvec
.z
= 2.0f
;
674 D3DXVec3Maximize(&gotvec
,&u
,&v
);
675 expect_vec3(expectedvec
,gotvec
);
676 /* Tests the case NULL */
677 funcpointer
= D3DXVec3Maximize(&gotvec
,NULL
,&v
);
678 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
679 funcpointer
= D3DXVec3Maximize(NULL
,NULL
,NULL
);
680 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
682 /*_______________D3DXVec3Minimize__________________________*/
683 expectedvec
.x
= 2.0f
; expectedvec
.y
= -3.0f
; expectedvec
.z
= -4.0f
;
684 D3DXVec3Minimize(&gotvec
,&u
,&v
);
685 expect_vec3(expectedvec
,gotvec
);
686 /* Tests the case NULL */
687 funcpointer
= D3DXVec3Minimize(&gotvec
,NULL
,&v
);
688 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
689 funcpointer
= D3DXVec3Minimize(NULL
,NULL
,NULL
);
690 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
692 /*_______________D3DXVec3Normalize_________________________*/
693 expectedvec
.x
= 9.0f
/11.0f
; expectedvec
.y
= 6.0f
/11.0f
; expectedvec
.z
= 2.0f
/11.0f
;
694 D3DXVec3Normalize(&gotvec
,&u
);
695 expect_vec3(expectedvec
,gotvec
);
696 /* Test the nul vector */
697 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
;
698 D3DXVec3Normalize(&gotvec
,&nul
);
699 expect_vec3(expectedvec
,gotvec
);
701 /*_______________D3DXVec3Scale____________________________*/
702 expectedvec
.x
= -58.5f
; expectedvec
.y
= -39.0f
; expectedvec
.z
= -13.0f
;
703 D3DXVec3Scale(&gotvec
,&u
,scale
);
704 expect_vec3(expectedvec
,gotvec
);
705 /* Tests the case NULL */
706 funcpointer
= D3DXVec3Scale(&gotvec
,NULL
,scale
);
707 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
708 funcpointer
= D3DXVec3Scale(NULL
,NULL
,scale
);
709 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
711 /*_______________D3DXVec3Subtract_______________________*/
712 expectedvec
.x
= 7.0f
; expectedvec
.y
= 9.0f
; expectedvec
.z
= 6.0f
;
713 D3DXVec3Subtract(&gotvec
,&u
,&v
);
714 expect_vec3(expectedvec
,gotvec
);
715 /* Tests the case NULL */
716 funcpointer
= D3DXVec3Subtract(&gotvec
,NULL
,&v
);
717 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
718 funcpointer
= D3DXVec3Subtract(NULL
,NULL
,NULL
);
719 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
721 /*_______________D3DXVec3Transform_______________________*/
722 expectedtrans
.x
= 70.0f
; expectedtrans
.y
= 88.0f
; expectedtrans
.z
= 106.0f
; expectedtrans
.w
= 124.0f
;
723 D3DXVec3Transform(&gottrans
,&u
,&mat
);
724 expect_vec4(expectedtrans
,gottrans
);
726 /*_______________D3DXVec3TransformCoord_______________________*/
727 expectedvec
.x
= 70.0f
/124.0f
; expectedvec
.y
= 88.0f
/124.0f
; expectedvec
.z
= 106.0f
/124.0f
;
728 D3DXVec3TransformCoord(&gotvec
,&u
,&mat
);
729 expect_vec3(expectedvec
,gotvec
);
730 /* Test the nul projected vector */
731 nulproj
.x
= 1.0f
; nulproj
.y
= -1.0f
, nulproj
.z
= -1.0f
;
732 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
;
733 D3DXVec3TransformCoord(&gotvec
,&nulproj
,&mat
);
734 expect_vec3(expectedvec
,gotvec
);
736 /*_______________D3DXVec3TransformNormal______________________*/
737 expectedvec
.x
= 57.0f
; expectedvec
.y
= 74.0f
; expectedvec
.z
= 91.0f
;
738 D3DXVec3TransformNormal(&gotvec
,&u
,&mat
);
739 expect_vec3(expectedvec
,gotvec
);
742 static void D3X8Vector4Test(void)
744 D3DXVECTOR4 expectedvec
, gotvec
, nul
, u
, v
, w
, x
;
745 LPD3DXVECTOR4 funcpointer
;
746 D3DXVECTOR4 expectedtrans
, gottrans
;
748 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
750 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
; nul
.w
= 0.0f
;
751 u
.x
= 1.0f
; u
.y
= 2.0f
; u
.z
= 4.0f
; u
.w
= 10.0;
752 v
.x
= -3.0f
; v
.y
= 4.0f
; v
.z
= -5.0f
; v
.w
= 7.0;
753 w
.x
= 4.0f
; w
.y
=6.0f
; w
.z
= -2.0f
; w
.w
= 1.0f
;
754 x
.x
= 6.0f
; x
.y
= -7.0f
; x
.z
=8.0f
; x
.w
= -9.0f
;
756 mat
.m
[0][0] = 1.0f
; mat
.m
[0][1] = 2.0f
; mat
.m
[0][2] = 3.0f
; mat
.m
[0][3] = 4.0f
;
757 mat
.m
[1][0] = 5.0f
; mat
.m
[1][1] = 6.0f
; mat
.m
[1][2] = 7.0f
; mat
.m
[1][3] = 8.0f
;
758 mat
.m
[2][0] = 9.0f
; mat
.m
[2][1] = 10.0f
; mat
.m
[2][2] = 11.0f
; mat
.m
[2][3] = 12.0f
;
759 mat
.m
[3][0] = 13.0f
; mat
.m
[3][1] = 14.0f
; mat
.m
[3][2] = 15.0f
; mat
.m
[3][3] = 16.0f
;
761 coeff1
= 2.0f
; coeff2
= 5.0;
764 /*_______________D3DXVec4Add__________________________*/
765 expectedvec
.x
= -2.0f
; expectedvec
.y
= 6.0f
; expectedvec
.z
= -1.0f
; expectedvec
.w
= 17.0f
;
766 D3DXVec4Add(&gotvec
,&u
,&v
);
767 expect_vec4(expectedvec
,gotvec
);
768 /* Tests the case NULL */
769 funcpointer
= D3DXVec4Add(&gotvec
,NULL
,&v
);
770 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
771 funcpointer
= D3DXVec4Add(NULL
,NULL
,NULL
);
772 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
774 /*_______________D3DXVec4BaryCentric____________________*/
775 expectedvec
.x
= 8.0f
; expectedvec
.y
= 26.0; expectedvec
.z
= -44.0f
; expectedvec
.w
= -41.0f
;
776 D3DXVec4BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
777 expect_vec4(expectedvec
,gotvec
);
779 /*_______________D3DXVec4CatmullRom____________________*/
780 expectedvec
.x
= 2754.625f
; expectedvec
.y
= 2367.5625f
; expectedvec
.z
= 1060.1875f
; expectedvec
.w
= 131.3125f
;
781 D3DXVec4CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
782 expect_vec4(expectedvec
,gotvec
);
784 /*_______________D3DXVec4Cross_________________________*/
785 expectedvec
.x
= 390.0f
; expectedvec
.y
= -393.0f
; expectedvec
.z
= -316.0f
; expectedvec
.w
= 166.0f
;
786 D3DXVec4Cross(&gotvec
,&u
,&v
,&w
);
787 expect_vec4(expectedvec
,gotvec
);
789 /*_______________D3DXVec4Dot__________________________*/
791 got
= D3DXVec4Dot(&u
,&v
);
792 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
793 /* Tests the case NULL */
795 got
= D3DXVec4Dot(NULL
,&v
);
796 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
798 got
= D3DXVec4Dot(NULL
,NULL
);
799 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
801 /*_______________D3DXVec4Hermite_________________________*/
802 expectedvec
.x
= 1224.625f
; expectedvec
.y
= 3461.625f
; expectedvec
.z
= -4758.875f
; expectedvec
.w
= -5781.5f
;
803 D3DXVec4Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
804 expect_vec4(expectedvec
,gotvec
);
806 /*_______________D3DXVec4Length__________________________*/
808 got
= D3DXVec4Length(&u
);
809 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
810 /* Tests the case NULL */
812 got
= D3DXVec4Length(NULL
);
813 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
815 /*_______________D3DXVec4LengthSq________________________*/
817 got
= D3DXVec4LengthSq(&u
);
818 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
819 /* Tests the case NULL */
821 got
= D3DXVec4LengthSq(NULL
);
822 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
824 /*_______________D3DXVec4Lerp__________________________*/
825 expectedvec
.x
= 27.0f
; expectedvec
.y
= -11.0f
; expectedvec
.z
= 62.5; expectedvec
.w
= 29.5;
826 D3DXVec4Lerp(&gotvec
,&u
,&v
,scale
);
827 expect_vec4(expectedvec
,gotvec
);
828 /* Tests the case NULL */
829 funcpointer
= D3DXVec4Lerp(&gotvec
,NULL
,&v
,scale
);
830 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
831 funcpointer
= D3DXVec4Lerp(NULL
,NULL
,NULL
,scale
);
832 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
834 /*_______________D3DXVec4Maximize__________________________*/
835 expectedvec
.x
= 1.0f
; expectedvec
.y
= 4.0f
; expectedvec
.z
= 4.0f
; expectedvec
.w
= 10.0;
836 D3DXVec4Maximize(&gotvec
,&u
,&v
);
837 expect_vec4(expectedvec
,gotvec
);
838 /* Tests the case NULL */
839 funcpointer
= D3DXVec4Maximize(&gotvec
,NULL
,&v
);
840 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
841 funcpointer
= D3DXVec4Maximize(NULL
,NULL
,NULL
);
842 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
844 /*_______________D3DXVec4Minimize__________________________*/
845 expectedvec
.x
= -3.0f
; expectedvec
.y
= 2.0f
; expectedvec
.z
= -5.0f
; expectedvec
.w
= 7.0;
846 D3DXVec4Minimize(&gotvec
,&u
,&v
);
847 expect_vec4(expectedvec
,gotvec
);
848 /* Tests the case NULL */
849 funcpointer
= D3DXVec4Minimize(&gotvec
,NULL
,&v
);
850 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
851 funcpointer
= D3DXVec4Minimize(NULL
,NULL
,NULL
);
852 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
854 /*_______________D3DXVec4Normalize_________________________*/
855 expectedvec
.x
= 1.0f
/11.0f
; expectedvec
.y
= 2.0f
/11.0f
; expectedvec
.z
= 4.0f
/11.0f
; expectedvec
.w
= 10.0f
/11.0f
;
856 D3DXVec4Normalize(&gotvec
,&u
);
857 expect_vec4(expectedvec
,gotvec
);
858 /* Test the nul vector */
859 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
; expectedvec
.w
= 0.0f
;
860 D3DXVec4Normalize(&gotvec
,&nul
);
861 expect_vec4(expectedvec
,gotvec
);
863 /*_______________D3DXVec4Scale____________________________*/
864 expectedvec
.x
= -6.5f
; expectedvec
.y
= -13.0f
; expectedvec
.z
= -26.0f
; expectedvec
.w
= -65.0f
;
865 D3DXVec4Scale(&gotvec
,&u
,scale
);
866 expect_vec4(expectedvec
,gotvec
);
867 /* Tests the case NULL */
868 funcpointer
= D3DXVec4Scale(&gotvec
,NULL
,scale
);
869 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
870 funcpointer
= D3DXVec4Scale(NULL
,NULL
,scale
);
871 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
873 /*_______________D3DXVec4Subtract__________________________*/
874 expectedvec
.x
= 4.0f
; expectedvec
.y
= -2.0f
; expectedvec
.z
= 9.0f
; expectedvec
.w
= 3.0f
;
875 D3DXVec4Subtract(&gotvec
,&u
,&v
);
876 expect_vec4(expectedvec
,gotvec
);
877 /* Tests the case NULL */
878 funcpointer
= D3DXVec4Subtract(&gotvec
,NULL
,&v
);
879 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
880 funcpointer
= D3DXVec4Subtract(NULL
,NULL
,NULL
);
881 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
883 /*_______________D3DXVec4Transform_______________________*/
884 expectedtrans
.x
= 177.0f
; expectedtrans
.y
= 194.0f
; expectedtrans
.z
= 211.0f
; expectedtrans
.w
= 228.0f
;
885 D3DXVec4Transform(&gottrans
,&u
,&mat
);
886 expect_vec4(expectedtrans
,gottrans
);
894 D3X8QuaternionTest();