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
;
153 D3DXVECTOR3 at
, axis
, eye
;
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 at
.x
= -2.0f
; at
.y
= 13.0f
; at
.z
= -9.0f
;
174 axis
.x
= 1.0f
; axis
.y
= -3.0f
; axis
.z
= 7.0f
;
175 eye
.x
= 8.0f
; eye
.y
= -5.0f
; eye
.z
= 5.75f
;
177 angle
= D3DX_PI
/3.0f
;
179 /*____________D3DXMatrixfDeterminant_____________*/
180 expectedfloat
= -147888.0f
;
181 gotfloat
= D3DXMatrixfDeterminant(&mat
);
182 ok(fabs( gotfloat
- expectedfloat
) < admitted_error
, "Expected: %f, Got: %f\n", expectedfloat
, gotfloat
);
184 /*____________D3DXMatrixIsIdentity______________*/
186 got
= D3DXMatrixIsIdentity(&mat3
);
187 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
188 D3DXMatrixIdentity(&mat3
);
190 got
= D3DXMatrixIsIdentity(&mat3
);
191 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
192 U(mat3
).m
[0][0] = 0.000009f
;
194 got
= D3DXMatrixIsIdentity(&mat3
);
195 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
196 /* Test the NULL case */
198 got
= D3DXMatrixIsIdentity(NULL
);
199 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
201 /*____________D3DXMatrixLookatLH_______________*/
202 expectedmat
.m
[0][0] = -0.822465f
; expectedmat
.m
[0][1] = -0.409489f
; expectedmat
.m
[0][2] = -0.394803f
; expectedmat
.m
[0][3] = 0.0f
;
203 expectedmat
.m
[1][0] = -0.555856f
; expectedmat
.m
[1][1] = 0.431286f
; expectedmat
.m
[1][2] = 0.710645f
; expectedmat
.m
[1][3] = 0.0f
;
204 expectedmat
.m
[2][0] = -0.120729f
; expectedmat
.m
[2][1] = 0.803935f
; expectedmat
.m
[2][2] = -0.582335f
; expectedmat
.m
[2][3] = 0.0f
;
205 expectedmat
.m
[3][0] = 4.494634f
; expectedmat
.m
[3][1] = 0.809719f
; expectedmat
.m
[3][2] = 10.060076f
; expectedmat
.m
[3][3] = 1.0f
;
206 D3DXMatrixLookAtLH(&gotmat
,&eye
,&at
,&axis
);
207 expect_mat(expectedmat
,gotmat
);
209 /*____________D3DXMatrixLookatRH_______________*/
210 expectedmat
.m
[0][0] = 0.822465f
; expectedmat
.m
[0][1] = -0.409489f
; expectedmat
.m
[0][2] = 0.394803f
; expectedmat
.m
[0][3] = 0.0f
;
211 expectedmat
.m
[1][0] = 0.555856f
; expectedmat
.m
[1][1] = 0.431286f
; expectedmat
.m
[1][2] = -0.710645f
; expectedmat
.m
[1][3] = 0.0f
;
212 expectedmat
.m
[2][0] = 0.120729f
; expectedmat
.m
[2][1] = 0.803935f
; expectedmat
.m
[2][2] = 0.582335f
; expectedmat
.m
[2][3] = 0.0f
;
213 expectedmat
.m
[3][0] = -4.494634f
; expectedmat
.m
[3][1] = 0.809719f
; expectedmat
.m
[3][2] = -10.060076f
; expectedmat
.m
[3][3] = 1.0f
;
214 D3DXMatrixLookAtRH(&gotmat
,&eye
,&at
,&axis
);
215 expect_mat(expectedmat
,gotmat
);
217 /*____________D3DXMatrixMultiply______________*/
218 expectedmat
.m
[0][0] = 73.0f
; expectedmat
.m
[0][1] = 193.0f
; expectedmat
.m
[0][2] = -197.0f
; expectedmat
.m
[0][3] = -77.0f
;
219 expectedmat
.m
[1][0] = 231.0f
; expectedmat
.m
[1][1] = 551.0f
; expectedmat
.m
[1][2] = -489.0f
; expectedmat
.m
[1][3] = -169.0;
220 expectedmat
.m
[2][0] = 239.0f
; expectedmat
.m
[2][1] = 523.0f
; expectedmat
.m
[2][2] = -400.0f
; expectedmat
.m
[2][3] = -116.0f
;
221 expectedmat
.m
[3][0] = -164.0f
; expectedmat
.m
[3][1] = -320.0f
; expectedmat
.m
[3][2] = 187.0f
; expectedmat
.m
[3][3] = 31.0f
;
222 D3DXMatrixMultiply(&gotmat
,&mat
,&mat2
);
223 expect_mat(expectedmat
,gotmat
);
225 /*____________D3DXMatrixPerspectiveFovLH_______________*/
226 expectedmat
.m
[0][0] = 13.288858f
; expectedmat
.m
[0][1] = 0.0f
; expectedmat
.m
[0][2] = 0.0f
; expectedmat
.m
[0][3] = 0.0f
;
227 expectedmat
.m
[1][0] = 0.0f
; expectedmat
.m
[1][1] = 9.966644f
; expectedmat
.m
[1][2] = 0.0; expectedmat
.m
[1][3] = 0.0f
;
228 expectedmat
.m
[2][0] = 0.0f
; expectedmat
.m
[2][1] = 0.0f
; expectedmat
.m
[2][2] = 0.783784f
; expectedmat
.m
[2][3] = 1.0f
;
229 expectedmat
.m
[3][0] = 0.0f
; expectedmat
.m
[3][1] = 0.0f
; expectedmat
.m
[3][2] = 1.881081f
; expectedmat
.m
[3][3] = 0.0f
;
230 D3DXMatrixPerspectiveFovLH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
);
231 expect_mat(expectedmat
,gotmat
);
233 /*____________D3DXMatrixPerspectiveFovRH_______________*/
234 expectedmat
.m
[0][0] = 13.288858f
; expectedmat
.m
[0][1] = 0.0f
; expectedmat
.m
[0][2] = 0.0f
; expectedmat
.m
[0][3] = 0.0f
;
235 expectedmat
.m
[1][0] = 0.0f
; expectedmat
.m
[1][1] = 9.966644f
; expectedmat
.m
[1][2] = 0.0; expectedmat
.m
[1][3] = 0.0f
;
236 expectedmat
.m
[2][0] = 0.0f
; expectedmat
.m
[2][1] = 0.0f
; expectedmat
.m
[2][2] = -0.783784f
; expectedmat
.m
[2][3] = -1.0f
;
237 expectedmat
.m
[3][0] = 0.0f
; expectedmat
.m
[3][1] = 0.0f
; expectedmat
.m
[3][2] = 1.881081f
; expectedmat
.m
[3][3] = 0.0f
;
238 D3DXMatrixPerspectiveFovRH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
);
239 expect_mat(expectedmat
,gotmat
);
241 /*____________D3DXMatrixPerspectiveLH_______________*/
242 expectedmat
.m
[0][0] = -24.0f
; expectedmat
.m
[0][1] = -0.0f
; expectedmat
.m
[0][2] = 0.0f
; expectedmat
.m
[0][3] = 0.0f
;
243 expectedmat
.m
[1][0] = 0.0f
; expectedmat
.m
[1][1] = -6.4f
; expectedmat
.m
[1][2] = 0.0; expectedmat
.m
[1][3] = 0.0f
;
244 expectedmat
.m
[2][0] = 0.0f
; expectedmat
.m
[2][1] = 0.0f
; expectedmat
.m
[2][2] = 0.783784f
; expectedmat
.m
[2][3] = 1.0f
;
245 expectedmat
.m
[3][0] = 0.0f
; expectedmat
.m
[3][1] = 0.0f
; expectedmat
.m
[3][2] = 1.881081f
; expectedmat
.m
[3][3] = 0.0f
;
246 D3DXMatrixPerspectiveLH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
);
247 expect_mat(expectedmat
,gotmat
);
249 /*____________D3DXMatrixPerspectiveRH_______________*/
250 expectedmat
.m
[0][0] = -24.0f
; expectedmat
.m
[0][1] = -0.0f
; expectedmat
.m
[0][2] = 0.0f
; expectedmat
.m
[0][3] = 0.0f
;
251 expectedmat
.m
[1][0] = 0.0f
; expectedmat
.m
[1][1] = -6.4f
; expectedmat
.m
[1][2] = 0.0; expectedmat
.m
[1][3] = 0.0f
;
252 expectedmat
.m
[2][0] = 0.0f
; expectedmat
.m
[2][1] = 0.0f
; expectedmat
.m
[2][2] = -0.783784f
; expectedmat
.m
[2][3] = -1.0f
;
253 expectedmat
.m
[3][0] = 0.0f
; expectedmat
.m
[3][1] = 0.0f
; expectedmat
.m
[3][2] = 1.881081f
; expectedmat
.m
[3][3] = 0.0f
;
254 D3DXMatrixPerspectiveRH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
);
255 expect_mat(expectedmat
,gotmat
);
257 /*____________D3DXMatrixRotationAxis_____*/
258 expectedmat
.m
[0][0] = 0.508475f
; expectedmat
.m
[0][1] = 0.763805f
; expectedmat
.m
[0][2] = 0.397563f
; expectedmat
.m
[0][3] = 0.0f
;
259 expectedmat
.m
[1][0] = -0.814652f
; expectedmat
.m
[1][1] = 0.576271f
; expectedmat
.m
[1][2] = -0.065219f
; expectedmat
.m
[1][3] = 0.0f
;
260 expectedmat
.m
[2][0] = -0.278919f
; expectedmat
.m
[2][1] = -0.290713f
; expectedmat
.m
[2][2] = 0.915254f
; expectedmat
.m
[2][3] = 0.0f
;
261 expectedmat
.m
[3][0] = 0.0f
; expectedmat
.m
[3][1] = 0.0f
; expectedmat
.m
[3][2] = 0.0f
; expectedmat
.m
[3][3] = 1.0f
;
262 D3DXMatrixRotationAxis(&gotmat
,&axis
,angle
);
263 expect_mat(expectedmat
,gotmat
);
265 /*____________D3DXMatrixRotationQuaternion______________*/
266 expectedmat
.m
[0][0] = -129.0f
; expectedmat
.m
[0][1] = -162.0f
; expectedmat
.m
[0][2] = -74.0f
; expectedmat
.m
[0][3] = 0.0f
;
267 expectedmat
.m
[1][0] = 146.0f
; expectedmat
.m
[1][1] = -99.0f
; expectedmat
.m
[1][2] = -78.0f
; expectedmat
.m
[1][3] = 0.0f
;
268 expectedmat
.m
[2][0] = 102.0f
; expectedmat
.m
[2][1] = -34.0f
; expectedmat
.m
[2][2] = -33.0f
; expectedmat
.m
[2][3] = 0.0f
;
269 expectedmat
.m
[3][0] = 0.0f
; expectedmat
.m
[3][1] = 0.0f
; expectedmat
.m
[3][2] = 0.0f
; expectedmat
.m
[3][3] = 1.0f
;
270 D3DXMatrixRotationQuaternion(&gotmat
,&q
);
271 expect_mat(expectedmat
,gotmat
);
273 /*____________D3DXMatrixRotationX______________*/
274 expectedmat
.m
[0][0] = 1.0f
; expectedmat
.m
[0][1] = 0.0f
; expectedmat
.m
[0][2] = 0.0f
; expectedmat
.m
[0][3] = 0.0f
;
275 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
;
276 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
;
277 expectedmat
.m
[3][0] = 0.0f
; expectedmat
.m
[3][1] = 0.0f
; expectedmat
.m
[3][2] = 0.0f
; expectedmat
.m
[3][3] = 1.0f
;
278 D3DXMatrixRotationX(&gotmat
,angle
);
279 expect_mat(expectedmat
,gotmat
);
281 /*____________D3DXMatrixRotationY______________*/
282 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
;
283 expectedmat
.m
[1][0] = 0.0; expectedmat
.m
[1][1] = 1.0f
; expectedmat
.m
[1][2] = 0.0f
; expectedmat
.m
[1][3] = 0.0f
;
284 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
;
285 expectedmat
.m
[3][0] = 0.0f
; expectedmat
.m
[3][1] = 0.0f
; expectedmat
.m
[3][2] = 0.0f
; expectedmat
.m
[3][3] = 1.0f
;
286 D3DXMatrixRotationY(&gotmat
,angle
);
287 expect_mat(expectedmat
,gotmat
);
289 /*____________D3DXMatrixRotationYawPitchRoll____*/
290 expectedmat
.m
[0][0] = 0.888777f
; expectedmat
.m
[0][1] = 0.091875f
; expectedmat
.m
[0][2] = -0.449037f
; expectedmat
.m
[0][3] = 0.0f
;
291 expectedmat
.m
[1][0] = 0.351713f
; expectedmat
.m
[1][1] = 0.491487f
; expectedmat
.m
[1][2] = 0.796705f
; expectedmat
.m
[1][3] = 0.0f
;
292 expectedmat
.m
[2][0] = 0.293893f
; expectedmat
.m
[2][1] = -0.866025f
; expectedmat
.m
[2][2] = 0.404509f
; expectedmat
.m
[2][3] = 0.0f
;
293 expectedmat
.m
[3][0] = 0.0f
; expectedmat
.m
[3][1] = 0.0f
; expectedmat
.m
[3][2] = 0.0f
; expectedmat
.m
[3][3] = 1.0f
;
294 D3DXMatrixRotationYawPitchRoll(&gotmat
, 3.0f
*angle
/5.0f
, angle
, 3.0f
*angle
/17.0f
);
295 expect_mat(expectedmat
,gotmat
);
297 /*____________D3DXMatrixRotationZ______________*/
298 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
;
299 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
;
300 expectedmat
.m
[2][0] = 0.0f
; expectedmat
.m
[2][1] = 0.0f
; expectedmat
.m
[2][2] = 1.0f
; expectedmat
.m
[2][3] = 0.0f
;
301 expectedmat
.m
[3][0] = 0.0f
; expectedmat
.m
[3][1] = 0.0f
; expectedmat
.m
[3][2] = 0.0f
; expectedmat
.m
[3][3] = 1.0f
;
302 D3DXMatrixRotationZ(&gotmat
,angle
);
303 expect_mat(expectedmat
,gotmat
);
305 /*____________D3DXMatrixScaling______________*/
306 expectedmat
.m
[0][0] = 0.69f
; expectedmat
.m
[0][1] = 0.0f
; expectedmat
.m
[0][2] = 0.0f
; expectedmat
.m
[0][3] = 0.0f
;
307 expectedmat
.m
[1][0] = 0.0; expectedmat
.m
[1][1] = 0.53f
; expectedmat
.m
[1][2] = 0.0f
; expectedmat
.m
[1][3] = 0.0f
;
308 expectedmat
.m
[2][0] = 0.0f
; expectedmat
.m
[2][1] = 0.0f
; expectedmat
.m
[2][2] = 4.11f
; expectedmat
.m
[2][3] = 0.0f
;
309 expectedmat
.m
[3][0] = 0.0f
; expectedmat
.m
[3][1] = 0.0f
; expectedmat
.m
[3][2] = 0.0f
; expectedmat
.m
[3][3] = 1.0f
;
310 D3DXMatrixScaling(&gotmat
,0.69f
,0.53f
,4.11f
);
311 expect_mat(expectedmat
,gotmat
);
313 /*____________D3DXMatrixTranslation______________*/
314 expectedmat
.m
[0][0] = 1.0f
; expectedmat
.m
[0][1] = 0.0f
; expectedmat
.m
[0][2] = 0.0f
; expectedmat
.m
[0][3] = 0.0f
;
315 expectedmat
.m
[1][0] = 0.0; expectedmat
.m
[1][1] = 1.0f
; expectedmat
.m
[1][2] = 0.0f
; expectedmat
.m
[1][3] = 0.0f
;
316 expectedmat
.m
[2][0] = 0.0f
; expectedmat
.m
[2][1] = 0.0f
; expectedmat
.m
[2][2] = 1.0f
; expectedmat
.m
[2][3] = 0.0f
;
317 expectedmat
.m
[3][0] = 0.69f
; expectedmat
.m
[3][1] = 0.53f
; expectedmat
.m
[3][2] = 4.11f
; expectedmat
.m
[3][3] = 1.0f
;
318 D3DXMatrixTranslation(&gotmat
,0.69f
,0.53f
,4.11f
);
319 expect_mat(expectedmat
,gotmat
);
321 /*____________D3DXMatrixTranspose______________*/
322 expectedmat
.m
[0][0] = 10.0f
; expectedmat
.m
[0][1] = 11.0f
; expectedmat
.m
[0][2] = 19.0f
; expectedmat
.m
[0][3] = 2.0f
;
323 expectedmat
.m
[1][0] = 5.0; expectedmat
.m
[1][1] = 20.0f
; expectedmat
.m
[1][2] = -21.0f
; expectedmat
.m
[1][3] = 3.0f
;
324 expectedmat
.m
[2][0] = 7.0f
; expectedmat
.m
[2][1] = 16.0f
; expectedmat
.m
[2][2] = 30.f
; expectedmat
.m
[2][3] = -4.0f
;
325 expectedmat
.m
[3][0] = 8.0f
; expectedmat
.m
[3][1] = 33.0f
; expectedmat
.m
[3][2] = 43.0f
; expectedmat
.m
[3][3] = -40.0f
;
326 D3DXMatrixTranspose(&gotmat
,&mat
);
327 expect_mat(expectedmat
,gotmat
);
330 static void D3DXPlaneTest(void)
336 plane
.a
= -3.0f
; plane
.b
= -1.0f
; plane
.c
= 4.0f
; plane
.d
= 7.0f
;
337 vec
.x
= 2.0f
; vec
.y
= 5.0f
; vec
.z
= -6.0f
; vec
.w
= 11.0f
;
339 /*_______________D3DXPlaneDot________________*/
341 got
= D3DXPlaneDot(&plane
,&vec
),
342 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
344 got
= D3DXPlaneDot(NULL
,&vec
),
345 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
347 got
= D3DXPlaneDot(NULL
,NULL
),
348 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
350 /*_______________D3DXPlaneDotCoord________________*/
352 got
= D3DXPlaneDotCoord(&plane
,&vec
),
353 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
355 got
= D3DXPlaneDotCoord(NULL
,&vec
),
356 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
358 got
= D3DXPlaneDotCoord(NULL
,NULL
),
359 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
361 /*_______________D3DXPlaneDotNormal______________*/
363 got
= D3DXPlaneDotNormal(&plane
,&vec
),
364 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
366 got
= D3DXPlaneDotNormal(NULL
,&vec
),
367 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
369 got
= D3DXPlaneDotNormal(NULL
,NULL
),
370 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
373 static void D3X8QuaternionTest(void)
375 D3DXQUATERNION expectedquat
, gotquat
, nul
, q
, r
, s
;
376 LPD3DXQUATERNION funcpointer
;
378 BOOL expectedbool
, gotbool
;
380 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
; nul
.w
= 0.0f
;
381 q
.x
= 1.0f
, q
.y
= 2.0f
; q
.z
= 4.0f
; q
.w
= 10.0f
;
382 r
.x
= -3.0f
; r
.y
= 4.0f
; r
.z
= -5.0f
; r
.w
= 7.0;
384 /*_______________D3DXQuaternionConjugate________________*/
385 expectedquat
.x
= -1.0f
; expectedquat
.y
= -2.0f
; expectedquat
.z
= -4.0f
; expectedquat
.w
= 10.0f
;
386 D3DXQuaternionConjugate(&gotquat
,&q
);
387 expect_vec4(expectedquat
,gotquat
);
388 /* Test the NULL case */
389 funcpointer
= D3DXQuaternionConjugate(&gotquat
,NULL
);
390 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
391 funcpointer
= D3DXQuaternionConjugate(NULL
,NULL
);
392 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
394 /*_______________D3DXQuaternionDot______________________*/
396 got
= D3DXQuaternionDot(&q
,&r
);
397 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
398 /* Tests the case NULL */
400 got
= D3DXQuaternionDot(NULL
,&r
);
401 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
403 got
= D3DXQuaternionDot(NULL
,NULL
);
404 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
406 /*_______________D3DXQuaternionIdentity________________*/
407 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 1.0f
;
408 D3DXQuaternionIdentity(&gotquat
);
409 expect_vec4(expectedquat
,gotquat
);
410 /* Test the NULL case */
411 funcpointer
= D3DXQuaternionIdentity(NULL
);
412 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
414 /*_______________D3DXQuaternionIsIdentity________________*/
415 s
.x
= 0.0f
; s
.y
= 0.0f
; s
.z
= 0.0f
; s
.w
= 1.0f
;
417 gotbool
= D3DXQuaternionIsIdentity(&s
);
418 ok( expectedbool
== gotbool
, "Expected boolean : %d, Got bool : %d\n", expectedbool
, gotbool
);
419 s
.x
= 2.3f
; s
.y
= -4.2f
; s
.z
= 1.2f
; s
.w
=0.2f
;
420 expectedbool
= FALSE
;
421 gotbool
= D3DXQuaternionIsIdentity(&q
);
422 ok( expectedbool
== gotbool
, "Expected boolean : %d, Got bool : %d\n", expectedbool
, gotbool
);
423 /* Test the NULL case */
424 gotbool
= D3DXQuaternionIsIdentity(NULL
);
425 ok(gotbool
== FALSE
, "Expected boolean: %d, Got boolean: %d\n", FALSE
, gotbool
);
427 /*_______________D3DXQuaternionLength__________________________*/
429 got
= D3DXQuaternionLength(&q
);
430 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
431 /* Tests the case NULL */
433 got
= D3DXQuaternionLength(NULL
);
434 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
436 /*_______________D3DXQuaternionLengthSq________________________*/
438 got
= D3DXQuaternionLengthSq(&q
);
439 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
440 /* Tests the case NULL */
442 got
= D3DXQuaternionLengthSq(NULL
);
443 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
445 /*_______________D3DXQuaternionNormalize________________________*/
446 expectedquat
.x
= 1.0f
/11.0f
; expectedquat
.y
= 2.0f
/11.0f
; expectedquat
.z
= 4.0f
/11.0f
; expectedquat
.w
= 10.0f
/11.0f
;
447 D3DXQuaternionNormalize(&gotquat
,&q
);
448 expect_vec4(expectedquat
,gotquat
);
449 /* Test the nul quaternion */
450 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.0f
;
451 D3DXQuaternionNormalize(&gotquat
,&nul
);
452 expect_vec4(expectedquat
,gotquat
);
455 static void D3X8Vector2Test(void)
457 D3DXVECTOR2 expectedvec
, gotvec
, nul
, nulproj
, u
, v
, w
, x
;
458 LPD3DXVECTOR2 funcpointer
;
459 D3DXVECTOR4 expectedtrans
, gottrans
;
461 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
463 nul
.x
= 0.0f
; nul
.y
= 0.0f
;
464 u
.x
= 3.0f
; u
.y
= 4.0f
;
465 v
.x
= -7.0f
; v
.y
= 9.0f
;
466 w
.x
= 4.0f
; w
.y
= -3.0f
;
467 x
.x
= 2.0f
; x
.y
= -11.0f
;
469 mat
.m
[0][0] = 1.0f
; mat
.m
[0][1] = 2.0f
; mat
.m
[0][2] = 3.0f
; mat
.m
[0][3] = 4.0f
;
470 mat
.m
[1][0] = 5.0f
; mat
.m
[1][1] = 6.0f
; mat
.m
[1][2] = 7.0f
; mat
.m
[1][3] = 8.0f
;
471 mat
.m
[2][0] = 9.0f
; mat
.m
[2][1] = 10.0f
; mat
.m
[2][2] = 11.0f
; mat
.m
[2][3] = 12.0f
;
472 mat
.m
[3][0] = 13.0f
; mat
.m
[3][1] = 14.0f
; mat
.m
[3][2] = 15.0f
; mat
.m
[3][3] = 16.0f
;
474 coeff1
= 2.0f
; coeff2
= 5.0f
;
477 /*_______________D3DXVec2Add__________________________*/
478 expectedvec
.x
= -4.0f
; expectedvec
.y
= 13.0f
;
479 D3DXVec2Add(&gotvec
,&u
,&v
);
480 expect_vec(expectedvec
,gotvec
);
481 /* Tests the case NULL */
482 funcpointer
= D3DXVec2Add(&gotvec
,NULL
,&v
);
483 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
484 funcpointer
= D3DXVec2Add(NULL
,NULL
,NULL
);
485 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
487 /*_______________D3DXVec2BaryCentric___________________*/
488 expectedvec
.x
= -12.0f
; expectedvec
.y
= -21.0f
;
489 D3DXVec2BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
490 expect_vec(expectedvec
,gotvec
);
492 /*_______________D3DXVec2CatmullRom____________________*/
493 expectedvec
.x
= 5820.25f
; expectedvec
.y
= -3654.5625f
;
494 D3DXVec2CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
495 expect_vec(expectedvec
,gotvec
);
497 /*_______________D3DXVec2CCW__________________________*/
499 got
= D3DXVec2CCW(&u
,&v
);
500 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
501 /* Tests the case NULL */
503 got
= D3DXVec2CCW(NULL
,&v
);
504 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
506 got
= D3DXVec2CCW(NULL
,NULL
);
507 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
509 /*_______________D3DXVec2Dot__________________________*/
511 got
= D3DXVec2Dot(&u
,&v
);
512 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
513 /* Tests the case NULL */
515 got
= D3DXVec2Dot(NULL
,&v
);
516 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
518 got
= D3DXVec2Dot(NULL
,NULL
);
519 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
521 /*_______________D3DXVec2Hermite__________________________*/
522 expectedvec
.x
= 2604.625f
; expectedvec
.y
= -4533.0f
;
523 D3DXVec2Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
524 expect_vec(expectedvec
,gotvec
);
526 /*_______________D3DXVec2Length__________________________*/
528 got
= D3DXVec2Length(&u
);
529 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
530 /* Tests the case NULL */
532 got
= D3DXVec2Length(NULL
);
533 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
535 /*_______________D3DXVec2LengthSq________________________*/
537 got
= D3DXVec2LengthSq(&u
);
538 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
539 /* Tests the case NULL */
541 got
= D3DXVec2LengthSq(NULL
);
542 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
544 /*_______________D3DXVec2Lerp__________________________*/
545 expectedvec
.x
= 68.0f
; expectedvec
.y
= -28.5f
;
546 D3DXVec2Lerp(&gotvec
,&u
,&v
,scale
);
547 expect_vec(expectedvec
,gotvec
);
548 /* Tests the case NULL */
549 funcpointer
= D3DXVec2Lerp(&gotvec
,NULL
,&v
,scale
);
550 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
551 funcpointer
= D3DXVec2Lerp(NULL
,NULL
,NULL
,scale
);
552 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
554 /*_______________D3DXVec2Maximize__________________________*/
555 expectedvec
.x
= 3.0f
; expectedvec
.y
= 9.0f
;
556 D3DXVec2Maximize(&gotvec
,&u
,&v
);
557 expect_vec(expectedvec
,gotvec
);
558 /* Tests the case NULL */
559 funcpointer
= D3DXVec2Maximize(&gotvec
,NULL
,&v
);
560 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
561 funcpointer
= D3DXVec2Maximize(NULL
,NULL
,NULL
);
562 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
564 /*_______________D3DXVec2Minimize__________________________*/
565 expectedvec
.x
= -7.0f
; expectedvec
.y
= 4.0f
;
566 D3DXVec2Minimize(&gotvec
,&u
,&v
);
567 expect_vec(expectedvec
,gotvec
);
568 /* Tests the case NULL */
569 funcpointer
= D3DXVec2Minimize(&gotvec
,NULL
,&v
);
570 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
571 funcpointer
= D3DXVec2Minimize(NULL
,NULL
,NULL
);
572 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
574 /*_______________D3DXVec2Normalize_________________________*/
575 expectedvec
.x
= 0.6f
; expectedvec
.y
= 0.8f
;
576 D3DXVec2Normalize(&gotvec
,&u
);
577 expect_vec(expectedvec
,gotvec
);
578 /* Test the nul vector */
579 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
;
580 D3DXVec2Normalize(&gotvec
,&nul
);
581 expect_vec(expectedvec
,gotvec
);
583 /*_______________D3DXVec2Scale____________________________*/
584 expectedvec
.x
= -19.5f
; expectedvec
.y
= -26.0f
;
585 D3DXVec2Scale(&gotvec
,&u
,scale
);
586 expect_vec(expectedvec
,gotvec
);
587 /* Tests the case NULL */
588 funcpointer
= D3DXVec2Scale(&gotvec
,NULL
,scale
);
589 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
590 funcpointer
= D3DXVec2Scale(NULL
,NULL
,scale
);
591 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
593 /*_______________D3DXVec2Subtract__________________________*/
594 expectedvec
.x
= 10.0f
; expectedvec
.y
= -5.0f
;
595 D3DXVec2Subtract(&gotvec
,&u
,&v
);
596 expect_vec(expectedvec
,gotvec
);
597 /* Tests the case NULL */
598 funcpointer
= D3DXVec2Subtract(&gotvec
,NULL
,&v
);
599 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
600 funcpointer
= D3DXVec2Subtract(NULL
,NULL
,NULL
);
601 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
603 /*_______________D3DXVec2Transform_______________________*/
604 expectedtrans
.x
= 36.0f
; expectedtrans
.y
= 44.0f
; expectedtrans
.z
= 52.0f
; expectedtrans
.w
= 60.0f
;
605 D3DXVec2Transform(&gottrans
,&u
,&mat
);
606 expect_vec4(expectedtrans
,gottrans
);
608 /*_______________D3DXVec2TransformCoord_______________________*/
609 expectedvec
.x
= 0.6f
; expectedvec
.y
= 11.0f
/15.0f
;
610 D3DXVec2TransformCoord(&gotvec
,&u
,&mat
);
611 expect_vec(expectedvec
,gotvec
);
612 /* Test the nul projected vector */
613 nulproj
.x
= -2.0f
; nulproj
.y
= -1.0f
;
614 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
;
615 D3DXVec2TransformCoord(&gotvec
,&nulproj
,&mat
);
616 expect_vec(expectedvec
,gotvec
);
618 /*_______________D3DXVec2TransformNormal______________________*/
619 expectedvec
.x
= 23.0f
; expectedvec
.y
= 30.0f
;
620 D3DXVec2TransformNormal(&gotvec
,&u
,&mat
);
621 expect_vec(expectedvec
,gotvec
);
624 static void D3X8Vector3Test(void)
626 D3DXVECTOR3 expectedvec
, gotvec
, nul
, nulproj
, u
, v
, w
, x
;
627 LPD3DXVECTOR3 funcpointer
;
628 D3DXVECTOR4 expectedtrans
, gottrans
;
630 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
632 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
;
633 u
.x
= 9.0f
; u
.y
= 6.0f
; u
.z
= 2.0f
;
634 v
.x
= 2.0f
; v
.y
= -3.0f
; v
.z
= -4.0;
635 w
.x
= 3.0f
; w
.y
= -5.0f
; w
.z
= 7.0f
;
636 x
.x
= 4.0f
; x
.y
= 1.0f
; x
.z
= 11.0f
;
638 mat
.m
[0][0] = 1.0f
; mat
.m
[0][1] = 2.0f
; mat
.m
[0][2] = 3.0f
; mat
.m
[0][3] = 4.0f
;
639 mat
.m
[1][0] = 5.0f
; mat
.m
[1][1] = 6.0f
; mat
.m
[1][2] = 7.0f
; mat
.m
[1][3] = 8.0f
;
640 mat
.m
[2][0] = 9.0f
; mat
.m
[2][1] = 10.0f
; mat
.m
[2][2] = 11.0f
; mat
.m
[2][3] = 12.0f
;
641 mat
.m
[3][0] = 13.0f
; mat
.m
[3][1] = 14.0f
; mat
.m
[3][2] = 15.0f
; mat
.m
[3][3] = 16.0f
;
643 coeff1
= 2.0f
; coeff2
= 5.0f
;
646 /*_______________D3DXVec3Add__________________________*/
647 expectedvec
.x
= 11.0f
; expectedvec
.y
= 3.0f
; expectedvec
.z
= -2.0f
;
648 D3DXVec3Add(&gotvec
,&u
,&v
);
649 expect_vec3(expectedvec
,gotvec
);
650 /* Tests the case NULL */
651 funcpointer
= D3DXVec3Add(&gotvec
,NULL
,&v
);
652 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
653 funcpointer
= D3DXVec3Add(NULL
,NULL
,NULL
);
654 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
656 /*_______________D3DXVec3BaryCentric___________________*/
657 expectedvec
.x
= -35.0f
; expectedvec
.y
= -67.0; expectedvec
.z
= 15.0f
;
658 D3DXVec3BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
660 expect_vec3(expectedvec
,gotvec
);
662 /*_______________D3DXVec3CatmullRom____________________*/
663 expectedvec
.x
= 1458.0f
; expectedvec
.y
= 22.1875f
; expectedvec
.z
= 4141.375f
;
664 D3DXVec3CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
665 expect_vec3(expectedvec
,gotvec
);
667 /*_______________D3DXVec3Cross________________________*/
668 expectedvec
.x
= -18.0f
; expectedvec
.y
= 40.0f
; expectedvec
.z
= -39.0f
;
669 D3DXVec3Cross(&gotvec
,&u
,&v
);
670 expect_vec3(expectedvec
,gotvec
);
671 /* Tests the case NULL */
672 funcpointer
= D3DXVec3Cross(&gotvec
,NULL
,&v
);
673 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
674 funcpointer
= D3DXVec3Cross(NULL
,NULL
,NULL
);
675 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
677 /*_______________D3DXVec3Dot__________________________*/
679 got
= D3DXVec3Dot(&u
,&v
);
680 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
681 /* Tests the case NULL */
683 got
= D3DXVec3Dot(NULL
,&v
);
684 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
686 got
= D3DXVec3Dot(NULL
,NULL
);
687 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
689 /*_______________D3DXVec3Hermite__________________________*/
690 expectedvec
.x
= -6045.75f
; expectedvec
.y
= -6650.0f
; expectedvec
.z
= 1358.875f
;
691 D3DXVec3Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
692 expect_vec3(expectedvec
,gotvec
);
694 /*_______________D3DXVec3Length__________________________*/
696 got
= D3DXVec3Length(&u
);
697 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
698 /* Tests the case NULL */
700 got
= D3DXVec3Length(NULL
);
701 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
703 /*_______________D3DXVec3LengthSq________________________*/
705 got
= D3DXVec3LengthSq(&u
);
706 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
707 /* Tests the case NULL */
709 got
= D3DXVec3LengthSq(NULL
);
710 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
712 /*_______________D3DXVec3Lerp__________________________*/
713 expectedvec
.x
= 54.5f
; expectedvec
.y
= 64.5f
, expectedvec
.z
= 41.0f
;
714 D3DXVec3Lerp(&gotvec
,&u
,&v
,scale
);
715 expect_vec3(expectedvec
,gotvec
);
716 /* Tests the case NULL */
717 funcpointer
= D3DXVec3Lerp(&gotvec
,NULL
,&v
,scale
);
718 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
719 funcpointer
= D3DXVec3Lerp(NULL
,NULL
,NULL
,scale
);
720 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
722 /*_______________D3DXVec3Maximize__________________________*/
723 expectedvec
.x
= 9.0f
; expectedvec
.y
= 6.0f
; expectedvec
.z
= 2.0f
;
724 D3DXVec3Maximize(&gotvec
,&u
,&v
);
725 expect_vec3(expectedvec
,gotvec
);
726 /* Tests the case NULL */
727 funcpointer
= D3DXVec3Maximize(&gotvec
,NULL
,&v
);
728 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
729 funcpointer
= D3DXVec3Maximize(NULL
,NULL
,NULL
);
730 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
732 /*_______________D3DXVec3Minimize__________________________*/
733 expectedvec
.x
= 2.0f
; expectedvec
.y
= -3.0f
; expectedvec
.z
= -4.0f
;
734 D3DXVec3Minimize(&gotvec
,&u
,&v
);
735 expect_vec3(expectedvec
,gotvec
);
736 /* Tests the case NULL */
737 funcpointer
= D3DXVec3Minimize(&gotvec
,NULL
,&v
);
738 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
739 funcpointer
= D3DXVec3Minimize(NULL
,NULL
,NULL
);
740 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
742 /*_______________D3DXVec3Normalize_________________________*/
743 expectedvec
.x
= 9.0f
/11.0f
; expectedvec
.y
= 6.0f
/11.0f
; expectedvec
.z
= 2.0f
/11.0f
;
744 D3DXVec3Normalize(&gotvec
,&u
);
745 expect_vec3(expectedvec
,gotvec
);
746 /* Test the nul vector */
747 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
;
748 D3DXVec3Normalize(&gotvec
,&nul
);
749 expect_vec3(expectedvec
,gotvec
);
751 /*_______________D3DXVec3Scale____________________________*/
752 expectedvec
.x
= -58.5f
; expectedvec
.y
= -39.0f
; expectedvec
.z
= -13.0f
;
753 D3DXVec3Scale(&gotvec
,&u
,scale
);
754 expect_vec3(expectedvec
,gotvec
);
755 /* Tests the case NULL */
756 funcpointer
= D3DXVec3Scale(&gotvec
,NULL
,scale
);
757 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
758 funcpointer
= D3DXVec3Scale(NULL
,NULL
,scale
);
759 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
761 /*_______________D3DXVec3Subtract_______________________*/
762 expectedvec
.x
= 7.0f
; expectedvec
.y
= 9.0f
; expectedvec
.z
= 6.0f
;
763 D3DXVec3Subtract(&gotvec
,&u
,&v
);
764 expect_vec3(expectedvec
,gotvec
);
765 /* Tests the case NULL */
766 funcpointer
= D3DXVec3Subtract(&gotvec
,NULL
,&v
);
767 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
768 funcpointer
= D3DXVec3Subtract(NULL
,NULL
,NULL
);
769 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
771 /*_______________D3DXVec3Transform_______________________*/
772 expectedtrans
.x
= 70.0f
; expectedtrans
.y
= 88.0f
; expectedtrans
.z
= 106.0f
; expectedtrans
.w
= 124.0f
;
773 D3DXVec3Transform(&gottrans
,&u
,&mat
);
774 expect_vec4(expectedtrans
,gottrans
);
776 /*_______________D3DXVec3TransformCoord_______________________*/
777 expectedvec
.x
= 70.0f
/124.0f
; expectedvec
.y
= 88.0f
/124.0f
; expectedvec
.z
= 106.0f
/124.0f
;
778 D3DXVec3TransformCoord(&gotvec
,&u
,&mat
);
779 expect_vec3(expectedvec
,gotvec
);
780 /* Test the nul projected vector */
781 nulproj
.x
= 1.0f
; nulproj
.y
= -1.0f
, nulproj
.z
= -1.0f
;
782 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
;
783 D3DXVec3TransformCoord(&gotvec
,&nulproj
,&mat
);
784 expect_vec3(expectedvec
,gotvec
);
786 /*_______________D3DXVec3TransformNormal______________________*/
787 expectedvec
.x
= 57.0f
; expectedvec
.y
= 74.0f
; expectedvec
.z
= 91.0f
;
788 D3DXVec3TransformNormal(&gotvec
,&u
,&mat
);
789 expect_vec3(expectedvec
,gotvec
);
792 static void D3X8Vector4Test(void)
794 D3DXVECTOR4 expectedvec
, gotvec
, nul
, u
, v
, w
, x
;
795 LPD3DXVECTOR4 funcpointer
;
796 D3DXVECTOR4 expectedtrans
, gottrans
;
798 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
800 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
; nul
.w
= 0.0f
;
801 u
.x
= 1.0f
; u
.y
= 2.0f
; u
.z
= 4.0f
; u
.w
= 10.0;
802 v
.x
= -3.0f
; v
.y
= 4.0f
; v
.z
= -5.0f
; v
.w
= 7.0;
803 w
.x
= 4.0f
; w
.y
=6.0f
; w
.z
= -2.0f
; w
.w
= 1.0f
;
804 x
.x
= 6.0f
; x
.y
= -7.0f
; x
.z
=8.0f
; x
.w
= -9.0f
;
806 mat
.m
[0][0] = 1.0f
; mat
.m
[0][1] = 2.0f
; mat
.m
[0][2] = 3.0f
; mat
.m
[0][3] = 4.0f
;
807 mat
.m
[1][0] = 5.0f
; mat
.m
[1][1] = 6.0f
; mat
.m
[1][2] = 7.0f
; mat
.m
[1][3] = 8.0f
;
808 mat
.m
[2][0] = 9.0f
; mat
.m
[2][1] = 10.0f
; mat
.m
[2][2] = 11.0f
; mat
.m
[2][3] = 12.0f
;
809 mat
.m
[3][0] = 13.0f
; mat
.m
[3][1] = 14.0f
; mat
.m
[3][2] = 15.0f
; mat
.m
[3][3] = 16.0f
;
811 coeff1
= 2.0f
; coeff2
= 5.0;
814 /*_______________D3DXVec4Add__________________________*/
815 expectedvec
.x
= -2.0f
; expectedvec
.y
= 6.0f
; expectedvec
.z
= -1.0f
; expectedvec
.w
= 17.0f
;
816 D3DXVec4Add(&gotvec
,&u
,&v
);
817 expect_vec4(expectedvec
,gotvec
);
818 /* Tests the case NULL */
819 funcpointer
= D3DXVec4Add(&gotvec
,NULL
,&v
);
820 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
821 funcpointer
= D3DXVec4Add(NULL
,NULL
,NULL
);
822 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
824 /*_______________D3DXVec4BaryCentric____________________*/
825 expectedvec
.x
= 8.0f
; expectedvec
.y
= 26.0; expectedvec
.z
= -44.0f
; expectedvec
.w
= -41.0f
;
826 D3DXVec4BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
827 expect_vec4(expectedvec
,gotvec
);
829 /*_______________D3DXVec4CatmullRom____________________*/
830 expectedvec
.x
= 2754.625f
; expectedvec
.y
= 2367.5625f
; expectedvec
.z
= 1060.1875f
; expectedvec
.w
= 131.3125f
;
831 D3DXVec4CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
832 expect_vec4(expectedvec
,gotvec
);
834 /*_______________D3DXVec4Cross_________________________*/
835 expectedvec
.x
= 390.0f
; expectedvec
.y
= -393.0f
; expectedvec
.z
= -316.0f
; expectedvec
.w
= 166.0f
;
836 D3DXVec4Cross(&gotvec
,&u
,&v
,&w
);
837 expect_vec4(expectedvec
,gotvec
);
839 /*_______________D3DXVec4Dot__________________________*/
841 got
= D3DXVec4Dot(&u
,&v
);
842 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
843 /* Tests the case NULL */
845 got
= D3DXVec4Dot(NULL
,&v
);
846 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
848 got
= D3DXVec4Dot(NULL
,NULL
);
849 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
851 /*_______________D3DXVec4Hermite_________________________*/
852 expectedvec
.x
= 1224.625f
; expectedvec
.y
= 3461.625f
; expectedvec
.z
= -4758.875f
; expectedvec
.w
= -5781.5f
;
853 D3DXVec4Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
854 expect_vec4(expectedvec
,gotvec
);
856 /*_______________D3DXVec4Length__________________________*/
858 got
= D3DXVec4Length(&u
);
859 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
860 /* Tests the case NULL */
862 got
= D3DXVec4Length(NULL
);
863 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
865 /*_______________D3DXVec4LengthSq________________________*/
867 got
= D3DXVec4LengthSq(&u
);
868 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
869 /* Tests the case NULL */
871 got
= D3DXVec4LengthSq(NULL
);
872 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
874 /*_______________D3DXVec4Lerp__________________________*/
875 expectedvec
.x
= 27.0f
; expectedvec
.y
= -11.0f
; expectedvec
.z
= 62.5; expectedvec
.w
= 29.5;
876 D3DXVec4Lerp(&gotvec
,&u
,&v
,scale
);
877 expect_vec4(expectedvec
,gotvec
);
878 /* Tests the case NULL */
879 funcpointer
= D3DXVec4Lerp(&gotvec
,NULL
,&v
,scale
);
880 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
881 funcpointer
= D3DXVec4Lerp(NULL
,NULL
,NULL
,scale
);
882 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
884 /*_______________D3DXVec4Maximize__________________________*/
885 expectedvec
.x
= 1.0f
; expectedvec
.y
= 4.0f
; expectedvec
.z
= 4.0f
; expectedvec
.w
= 10.0;
886 D3DXVec4Maximize(&gotvec
,&u
,&v
);
887 expect_vec4(expectedvec
,gotvec
);
888 /* Tests the case NULL */
889 funcpointer
= D3DXVec4Maximize(&gotvec
,NULL
,&v
);
890 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
891 funcpointer
= D3DXVec4Maximize(NULL
,NULL
,NULL
);
892 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
894 /*_______________D3DXVec4Minimize__________________________*/
895 expectedvec
.x
= -3.0f
; expectedvec
.y
= 2.0f
; expectedvec
.z
= -5.0f
; expectedvec
.w
= 7.0;
896 D3DXVec4Minimize(&gotvec
,&u
,&v
);
897 expect_vec4(expectedvec
,gotvec
);
898 /* Tests the case NULL */
899 funcpointer
= D3DXVec4Minimize(&gotvec
,NULL
,&v
);
900 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
901 funcpointer
= D3DXVec4Minimize(NULL
,NULL
,NULL
);
902 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
904 /*_______________D3DXVec4Normalize_________________________*/
905 expectedvec
.x
= 1.0f
/11.0f
; expectedvec
.y
= 2.0f
/11.0f
; expectedvec
.z
= 4.0f
/11.0f
; expectedvec
.w
= 10.0f
/11.0f
;
906 D3DXVec4Normalize(&gotvec
,&u
);
907 expect_vec4(expectedvec
,gotvec
);
908 /* Test the nul vector */
909 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
; expectedvec
.w
= 0.0f
;
910 D3DXVec4Normalize(&gotvec
,&nul
);
911 expect_vec4(expectedvec
,gotvec
);
913 /*_______________D3DXVec4Scale____________________________*/
914 expectedvec
.x
= -6.5f
; expectedvec
.y
= -13.0f
; expectedvec
.z
= -26.0f
; expectedvec
.w
= -65.0f
;
915 D3DXVec4Scale(&gotvec
,&u
,scale
);
916 expect_vec4(expectedvec
,gotvec
);
917 /* Tests the case NULL */
918 funcpointer
= D3DXVec4Scale(&gotvec
,NULL
,scale
);
919 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
920 funcpointer
= D3DXVec4Scale(NULL
,NULL
,scale
);
921 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
923 /*_______________D3DXVec4Subtract__________________________*/
924 expectedvec
.x
= 4.0f
; expectedvec
.y
= -2.0f
; expectedvec
.z
= 9.0f
; expectedvec
.w
= 3.0f
;
925 D3DXVec4Subtract(&gotvec
,&u
,&v
);
926 expect_vec4(expectedvec
,gotvec
);
927 /* Tests the case NULL */
928 funcpointer
= D3DXVec4Subtract(&gotvec
,NULL
,&v
);
929 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
930 funcpointer
= D3DXVec4Subtract(NULL
,NULL
,NULL
);
931 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
933 /*_______________D3DXVec4Transform_______________________*/
934 expectedtrans
.x
= 177.0f
; expectedtrans
.y
= 194.0f
; expectedtrans
.z
= 211.0f
; expectedtrans
.w
= 228.0f
;
935 D3DXVec4Transform(&gottrans
,&u
,&mat
);
936 expect_vec4(expectedtrans
,gottrans
);
944 D3X8QuaternionTest();