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.0001f
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(U(expectedmat).m[i][j]-U(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 U(expectedmat).m[0][0],U(expectedmat).m[0][1],U(expectedmat).m[0][2],U(expectedmat).m[0][3], \
44 U(expectedmat).m[1][0],U(expectedmat).m[1][1],U(expectedmat).m[1][2],U(expectedmat).m[1][3], \
45 U(expectedmat).m[2][0],U(expectedmat).m[2][1],U(expectedmat).m[2][2],U(expectedmat).m[2][3], \
46 U(expectedmat).m[3][0],U(expectedmat).m[3][1],U(expectedmat).m[3][2],U(expectedmat).m[3][3], \
47 U(gotmat).m[0][0],U(gotmat).m[0][1],U(gotmat).m[0][2],U(gotmat).m[0][3], \
48 U(gotmat).m[1][0],U(gotmat).m[1][1],U(gotmat).m[1][2],U(gotmat).m[1][3], \
49 U(gotmat).m[2][0],U(gotmat).m[2][1],U(gotmat).m[2][2],U(gotmat).m[2][3], \
50 U(gotmat).m[3][0],U(gotmat).m[3][1],U(gotmat).m[3][2],U(gotmat).m[3][3]); \
53 #define expect_plane(expectedplane,gotplane) ok((fabs(expectedplane.a-gotplane.a)<admitted_error)&&(fabs(expectedplane.b-gotplane.b)<admitted_error)&&(fabs(expectedplane.c-gotplane.c)<admitted_error)&&(fabs(expectedplane.d-gotplane.d)<admitted_error),"Expected Plane= (%f, %f, %f, %f)\n , Got Plane= (%f, %f, %f, %f)\n", expectedplane.a, expectedplane.b, expectedplane.c, expectedplane.d, gotplane.a, gotplane.b, gotplane.c, gotplane.d);
55 #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);
57 #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);
59 #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);
61 static void D3DXColorTest(void)
63 D3DXCOLOR color
, color1
, color2
, expected
, got
;
64 LPD3DXCOLOR funcpointer
;
67 color
.r
= 0.2f
; color
.g
= 0.75f
; color
.b
= 0.41f
; color
.a
= 0.93f
;
68 color1
.r
= 0.6f
; color1
.g
= 0.55f
; color1
.b
= 0.23f
; color1
.a
= 0.82f
;
69 color2
.r
= 0.3f
; color2
.g
= 0.5f
; color2
.b
= 0.76f
; color2
.a
= 0.11f
;
72 /*_______________D3DXColorAdd________________*/
73 expected
.r
= 0.9f
; expected
.g
= 1.05f
; expected
.b
= 0.99f
, expected
.a
= 0.93f
;
74 D3DXColorAdd(&got
,&color1
,&color2
);
75 expect_color(expected
,got
);
76 /* Test the NULL case */
77 funcpointer
= D3DXColorAdd(&got
,NULL
,&color2
);
78 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
79 funcpointer
= D3DXColorAdd(NULL
,NULL
,&color2
);
80 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
81 funcpointer
= D3DXColorAdd(NULL
,NULL
,NULL
);
82 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
84 /*_______________D3DXColorLerp________________*/
85 expected
.r
= 0.32f
; expected
.g
= 0.69f
; expected
.b
= 0.356f
; expected
.a
= 0.897f
;
86 D3DXColorLerp(&got
,&color
,&color1
,scale
);
87 expect_color(expected
,got
);
88 /* Test the NULL case */
89 funcpointer
= D3DXColorLerp(&got
,NULL
,&color1
,scale
);
90 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
91 funcpointer
= D3DXColorLerp(NULL
,NULL
,&color1
,scale
);
92 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
93 funcpointer
= D3DXColorLerp(NULL
,NULL
,NULL
,scale
);
94 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
96 /*_______________D3DXColorModulate________________*/
97 expected
.r
= 0.18f
; expected
.g
= 0.275f
; expected
.b
= 0.1748f
; expected
.a
= 0.0902f
;
98 D3DXColorModulate(&got
,&color1
,&color2
);
99 expect_color(expected
,got
);
100 /* Test the NULL case */
101 funcpointer
= D3DXColorModulate(&got
,NULL
,&color2
);
102 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
103 funcpointer
= D3DXColorModulate(NULL
,NULL
,&color2
);
104 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
105 funcpointer
= D3DXColorModulate(NULL
,NULL
,NULL
);
106 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
108 /*_______________D3DXColorNegative________________*/
109 expected
.r
= 0.8f
; expected
.g
= 0.25f
; expected
.b
= 0.59f
; expected
.a
= 0.93f
;
110 D3DXColorNegative(&got
,&color
);
111 expect_color(got
,expected
);
112 /* Test the greater than 1 case */
113 color1
.r
= 0.2f
; color1
.g
= 1.75f
; color1
.b
= 0.41f
; color1
.a
= 0.93f
;
114 expected
.r
= 0.8f
; expected
.g
= -0.75f
; expected
.b
= 0.59f
; expected
.a
= 0.93f
;
115 D3DXColorNegative(&got
,&color1
);
116 expect_color(got
,expected
);
117 /* Test the negative case */
118 color1
.r
= 0.2f
; color1
.g
= -0.75f
; color1
.b
= 0.41f
; color1
.a
= 0.93f
;
119 expected
.r
= 0.8f
; expected
.g
= 1.75f
; expected
.b
= 0.59f
; expected
.a
= 0.93f
;
120 D3DXColorNegative(&got
,&color1
);
121 expect_color(got
,expected
);
122 /* Test the NULL case */
123 funcpointer
= D3DXColorNegative(&got
,NULL
);
124 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
125 funcpointer
= D3DXColorNegative(NULL
,NULL
);
126 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
128 /*_______________D3DXColorScale________________*/
129 expected
.r
= 0.06f
; expected
.g
= 0.225f
; expected
.b
= 0.123f
; expected
.a
= 0.279f
;
130 D3DXColorScale(&got
,&color
,scale
);
131 expect_color(expected
,got
);
132 /* Test the NULL case */
133 funcpointer
= D3DXColorScale(&got
,NULL
,scale
);
134 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
135 funcpointer
= D3DXColorScale(NULL
,NULL
,scale
);
136 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
138 /*_______________D3DXColorSubtract_______________*/
139 expected
.r
= -0.1f
; expected
.g
= 0.25f
; expected
.b
= -0.35f
, expected
.a
= 0.82f
;
140 D3DXColorSubtract(&got
,&color
,&color2
);
141 expect_color(expected
,got
);
142 /* Test the NULL case */
143 funcpointer
= D3DXColorSubtract(&got
,NULL
,&color2
);
144 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
145 funcpointer
= D3DXColorSubtract(NULL
,NULL
,&color2
);
146 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
147 funcpointer
= D3DXColorSubtract(NULL
,NULL
,NULL
);
148 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
151 static void D3DXMatrixTest(void)
153 D3DXMATRIX expectedmat
, gotmat
, mat
, mat2
, mat3
;
154 LPD3DXMATRIX funcpointer
;
157 D3DXVECTOR3 at
, axis
, eye
;
160 FLOAT angle
, determinant
, expectedfloat
, gotfloat
;
162 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
163 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
164 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
165 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
166 U(mat
).m
[0][0] = 10.0f
; U(mat
).m
[1][1] = 20.0f
; U(mat
).m
[2][2] = 30.0f
;
167 U(mat
).m
[3][3] = -40.0f
;
169 U(mat2
).m
[0][0] = 1.0f
; U(mat2
).m
[1][0] = 2.0f
; U(mat2
).m
[2][0] = 3.0f
;
170 U(mat2
).m
[3][0] = 4.0f
; U(mat2
).m
[0][1] = 5.0f
; U(mat2
).m
[1][1] = 6.0f
;
171 U(mat2
).m
[2][1] = 7.0f
; U(mat2
).m
[3][1] = 8.0f
; U(mat2
).m
[0][2] = -8.0f
;
172 U(mat2
).m
[1][2] = -7.0f
; U(mat2
).m
[2][2] = -6.0f
; U(mat2
).m
[3][2] = -5.0f
;
173 U(mat2
).m
[0][3] = -4.0f
; U(mat2
).m
[1][3] = -3.0f
; U(mat2
).m
[2][3] = -2.0f
;
174 U(mat2
).m
[3][3] = -1.0f
;
176 plane
.a
= -3.0f
; plane
.b
= -1.0f
; plane
.c
= 4.0f
; plane
.d
= 7.0f
;
178 q
.x
= 1.0f
; q
.y
= -4.0f
; q
.z
=7.0f
; q
.w
= -11.0f
;
180 at
.x
= -2.0f
; at
.y
= 13.0f
; at
.z
= -9.0f
;
181 axis
.x
= 1.0f
; axis
.y
= -3.0f
; axis
.z
= 7.0f
;
182 eye
.x
= 8.0f
; eye
.y
= -5.0f
; eye
.z
= 5.75f
;
184 light
.x
= 9.6f
; light
.y
= 8.5f
; light
.z
= 7.4; light
.w
= 6.3;
186 angle
= D3DX_PI
/3.0f
;
188 /*____________D3DXMatrixAffineTransformation______*/
189 expectedmat
.m
[0][0] = -459.239990f
; expectedmat
.m
[0][1] = -576.719971f
; expectedmat
.m
[0][2] = -263.440002f
; expectedmat
.m
[0][3] = 0.0f
;
190 expectedmat
.m
[1][0] = 519.760010f
; expectedmat
.m
[1][1] = -352.440002f
; expectedmat
.m
[1][2] = -277.679993f
; expectedmat
.m
[1][3] = 0.0f
;
191 expectedmat
.m
[2][0] = 363.119995f
; expectedmat
.m
[2][1] = -121.040001f
; expectedmat
.m
[2][2] = -117.479996f
; expectedmat
.m
[2][3] = 0.0f
;
192 expectedmat
.m
[3][0] = -1239.0f
; expectedmat
.m
[3][1] = 667.0f
; expectedmat
.m
[3][2] = 567.0f
; expectedmat
.m
[3][3] = 1.0f
;
193 D3DXMatrixAffineTransformation(&gotmat
,3.56f
,&at
,&q
,&axis
);
194 expect_mat(expectedmat
,gotmat
);
195 /* Test the NULL case */
196 expectedmat
.m
[0][0] = -459.239990f
; expectedmat
.m
[0][1] = -576.719971f
; expectedmat
.m
[0][2] = -263.440002f
; expectedmat
.m
[0][3] = 0.0f
;
197 expectedmat
.m
[1][0] = 519.760010f
; expectedmat
.m
[1][1] = -352.440002f
; expectedmat
.m
[1][2] = -277.679993f
; expectedmat
.m
[1][3] = 0.0f
;
198 expectedmat
.m
[2][0] = 363.119995f
; expectedmat
.m
[2][1] = -121.040001f
; expectedmat
.m
[2][2] = -117.479996f
; expectedmat
.m
[2][3] = 0.0f
;
199 expectedmat
.m
[3][0] = 1.0f
; expectedmat
.m
[3][1] = -3.0f
; expectedmat
.m
[3][2] = 7.0f
; expectedmat
.m
[3][3] = 1.0f
;
200 D3DXMatrixAffineTransformation(&gotmat
,3.56f
,NULL
,&q
,&axis
);
201 expect_mat(expectedmat
,gotmat
);
203 /*____________D3DXMatrixfDeterminant_____________*/
204 expectedfloat
= -147888.0f
;
205 gotfloat
= D3DXMatrixfDeterminant(&mat
);
206 ok(fabs( gotfloat
- expectedfloat
) < admitted_error
, "Expected: %f, Got: %f\n", expectedfloat
, gotfloat
);
208 /*____________D3DXMatrixInverse______________*/
209 expectedmat
.m
[0][0] = 16067.0f
/73944.0f
; expectedmat
.m
[0][1] = -10165.0f
/147888.0f
; expectedmat
.m
[0][2] = -2729.0f
/147888.0f
; expectedmat
.m
[0][3] = -1631.0f
/49296.0f
;
210 expectedmat
.m
[1][0] = -565.0f
/36972.0f
; expectedmat
.m
[1][1] = 2723.0f
/73944.0f
; expectedmat
.m
[1][2] = -1073.0f
/73944.0f
; expectedmat
.m
[1][3] = 289.0f
/24648.0f
;
211 expectedmat
.m
[2][0] = -389.0f
/2054.0f
; expectedmat
.m
[2][1] = 337.0f
/4108.0f
; expectedmat
.m
[2][2] = 181.0f
/4108.0f
; expectedmat
.m
[2][3] = 317.0f
/4108.0f
;
212 expectedmat
.m
[3][0] = 163.0f
/5688.0f
; expectedmat
.m
[3][1] = -101.0f
/11376.0f
; expectedmat
.m
[3][2] = -73.0f
/11376.0f
; expectedmat
.m
[3][3] = -127.0f
/3792.0f
;
213 expectedfloat
= -147888.0f
;
214 D3DXMatrixInverse(&gotmat
,&determinant
,&mat
);
215 expect_mat(expectedmat
,gotmat
);
216 ok(fabs( determinant
- expectedfloat
) < admitted_error
, "Expected: %f, Got: %f\n", expectedfloat
, determinant
);
217 funcpointer
= D3DXMatrixInverse(&gotmat
,NULL
,&mat2
);
218 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
220 /*____________D3DXMatrixIsIdentity______________*/
222 got
= D3DXMatrixIsIdentity(&mat3
);
223 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
224 D3DXMatrixIdentity(&mat3
);
226 got
= D3DXMatrixIsIdentity(&mat3
);
227 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
228 U(mat3
).m
[0][0] = 0.000009f
;
230 got
= D3DXMatrixIsIdentity(&mat3
);
231 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
232 /* Test the NULL case */
234 got
= D3DXMatrixIsIdentity(NULL
);
235 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
237 /*____________D3DXMatrixLookatLH_______________*/
238 U(expectedmat
).m
[0][0] = -0.822465f
; U(expectedmat
).m
[0][1] = -0.409489f
; U(expectedmat
).m
[0][2] = -0.394803f
; U(expectedmat
).m
[0][3] = 0.0f
;
239 U(expectedmat
).m
[1][0] = -0.555856f
; U(expectedmat
).m
[1][1] = 0.431286f
; U(expectedmat
).m
[1][2] = 0.710645f
; U(expectedmat
).m
[1][3] = 0.0f
;
240 U(expectedmat
).m
[2][0] = -0.120729f
; U(expectedmat
).m
[2][1] = 0.803935f
; U(expectedmat
).m
[2][2] = -0.582335f
; U(expectedmat
).m
[2][3] = 0.0f
;
241 U(expectedmat
).m
[3][0] = 4.494634f
; U(expectedmat
).m
[3][1] = 0.809719f
; U(expectedmat
).m
[3][2] = 10.060076f
; U(expectedmat
).m
[3][3] = 1.0f
;
242 D3DXMatrixLookAtLH(&gotmat
,&eye
,&at
,&axis
);
243 expect_mat(expectedmat
,gotmat
);
245 /*____________D3DXMatrixLookatRH_______________*/
246 U(expectedmat
).m
[0][0] = 0.822465f
; U(expectedmat
).m
[0][1] = -0.409489f
; U(expectedmat
).m
[0][2] = 0.394803f
; U(expectedmat
).m
[0][3] = 0.0f
;
247 U(expectedmat
).m
[1][0] = 0.555856f
; U(expectedmat
).m
[1][1] = 0.431286f
; U(expectedmat
).m
[1][2] = -0.710645f
; U(expectedmat
).m
[1][3] = 0.0f
;
248 U(expectedmat
).m
[2][0] = 0.120729f
; U(expectedmat
).m
[2][1] = 0.803935f
; U(expectedmat
).m
[2][2] = 0.582335f
; U(expectedmat
).m
[2][3] = 0.0f
;
249 U(expectedmat
).m
[3][0] = -4.494634f
; U(expectedmat
).m
[3][1] = 0.809719f
; U(expectedmat
).m
[3][2] = -10.060076f
; U(expectedmat
).m
[3][3] = 1.0f
;
250 D3DXMatrixLookAtRH(&gotmat
,&eye
,&at
,&axis
);
251 expect_mat(expectedmat
,gotmat
);
253 /*____________D3DXMatrixMultiply______________*/
254 U(expectedmat
).m
[0][0] = 73.0f
; U(expectedmat
).m
[0][1] = 193.0f
; U(expectedmat
).m
[0][2] = -197.0f
; U(expectedmat
).m
[0][3] = -77.0f
;
255 U(expectedmat
).m
[1][0] = 231.0f
; U(expectedmat
).m
[1][1] = 551.0f
; U(expectedmat
).m
[1][2] = -489.0f
; U(expectedmat
).m
[1][3] = -169.0;
256 U(expectedmat
).m
[2][0] = 239.0f
; U(expectedmat
).m
[2][1] = 523.0f
; U(expectedmat
).m
[2][2] = -400.0f
; U(expectedmat
).m
[2][3] = -116.0f
;
257 U(expectedmat
).m
[3][0] = -164.0f
; U(expectedmat
).m
[3][1] = -320.0f
; U(expectedmat
).m
[3][2] = 187.0f
; U(expectedmat
).m
[3][3] = 31.0f
;
258 D3DXMatrixMultiply(&gotmat
,&mat
,&mat2
);
259 expect_mat(expectedmat
,gotmat
);
261 /*____________D3DXMatrixMultiplyTranspose____*/
262 expectedmat
.m
[0][0] = 73.0f
; expectedmat
.m
[0][1] = 231.0f
; expectedmat
.m
[0][2] = 239.0f
; expectedmat
.m
[0][3] = -164.0f
;
263 expectedmat
.m
[1][0] = 193.0f
; expectedmat
.m
[1][1] = 551.0f
; expectedmat
.m
[1][2] = 523.0f
; expectedmat
.m
[1][3] = -320.0;
264 expectedmat
.m
[2][0] = -197.0f
; expectedmat
.m
[2][1] = -489.0f
; expectedmat
.m
[2][2] = -400.0f
; expectedmat
.m
[2][3] = 187.0f
;
265 expectedmat
.m
[3][0] = -77.0f
; expectedmat
.m
[3][1] = -169.0f
; expectedmat
.m
[3][2] = -116.0f
; expectedmat
.m
[3][3] = 31.0f
;
266 D3DXMatrixMultiplyTranspose(&gotmat
,&mat
,&mat2
);
267 expect_mat(expectedmat
,gotmat
);
269 /*____________D3DXMatrixOrthoLH_______________*/
270 U(expectedmat
).m
[0][0] = 0.8f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
271 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 0.270270f
; U(expectedmat
).m
[1][2] = 0.0f
; U(expectedmat
).m
[1][3] = 0.0f
;
272 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = -0.151515f
; U(expectedmat
).m
[2][3] = 0.0f
;
273 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = -0.484848f
; U(expectedmat
).m
[3][3] = 1.0f
;
274 D3DXMatrixOrthoLH(&gotmat
, 2.5f
, 7.4f
, -3.2f
, -9.8f
);
275 expect_mat(expectedmat
,gotmat
);
277 /*____________D3DXMatrixOrthoOffCenterLH_______________*/
278 U(expectedmat
).m
[0][0] = 3.636364f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
279 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 0.180180f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
280 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = -0.045662f
; U(expectedmat
).m
[2][3] = 0.0f
;
281 U(expectedmat
).m
[3][0] = -1.727272f
; U(expectedmat
).m
[3][1] = -0.567568f
; U(expectedmat
).m
[3][2] = 0.424658f
; U(expectedmat
).m
[3][3] = 1.0f
;
282 D3DXMatrixOrthoOffCenterLH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
, 9.3, -12.6);
283 expect_mat(expectedmat
,gotmat
);
285 /*____________D3DXMatrixOrthoOffCenterRH_______________*/
286 U(expectedmat
).m
[0][0] = 3.636364f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
287 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 0.180180f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
288 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 0.045662f
; U(expectedmat
).m
[2][3] = 0.0f
;
289 U(expectedmat
).m
[3][0] = -1.727272f
; U(expectedmat
).m
[3][1] = -0.567568f
; U(expectedmat
).m
[3][2] = 0.424658f
; U(expectedmat
).m
[3][3] = 1.0f
;
290 D3DXMatrixOrthoOffCenterRH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
, 9.3, -12.6);
291 expect_mat(expectedmat
,gotmat
);
293 /*____________D3DXMatrixOrthoRH_______________*/
294 U(expectedmat
).m
[0][0] = 0.8f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
295 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 0.270270f
; U(expectedmat
).m
[1][2] = 0.0f
; U(expectedmat
).m
[1][3] = 0.0f
;
296 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 0.151515f
; U(expectedmat
).m
[2][3] = 0.0f
;
297 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = -0.484848f
; U(expectedmat
).m
[3][3] = 1.0f
;
298 D3DXMatrixOrthoRH(&gotmat
, 2.5f
, 7.4f
, -3.2f
, -9.8f
);
299 expect_mat(expectedmat
,gotmat
);
301 /*____________D3DXMatrixPerspectiveFovLH_______________*/
302 U(expectedmat
).m
[0][0] = 13.288858f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
303 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 9.966644f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
304 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 0.783784f
; U(expectedmat
).m
[2][3] = 1.0f
;
305 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 1.881081f
; U(expectedmat
).m
[3][3] = 0.0f
;
306 D3DXMatrixPerspectiveFovLH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
);
307 expect_mat(expectedmat
,gotmat
);
309 /*____________D3DXMatrixPerspectiveFovRH_______________*/
310 U(expectedmat
).m
[0][0] = 13.288858f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
311 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 9.966644f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
312 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = -0.783784f
; U(expectedmat
).m
[2][3] = -1.0f
;
313 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 1.881081f
; U(expectedmat
).m
[3][3] = 0.0f
;
314 D3DXMatrixPerspectiveFovRH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
);
315 expect_mat(expectedmat
,gotmat
);
317 /*____________D3DXMatrixPerspectiveLH_______________*/
318 U(expectedmat
).m
[0][0] = -24.0f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
319 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = -6.4f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
320 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 0.783784f
; U(expectedmat
).m
[2][3] = 1.0f
;
321 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 1.881081f
; U(expectedmat
).m
[3][3] = 0.0f
;
322 D3DXMatrixPerspectiveLH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
);
323 expect_mat(expectedmat
,gotmat
);
325 /*____________D3DXMatrixPerspectiveOffCenterLH_______________*/
326 U(expectedmat
).m
[0][0] = 11.636364f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
327 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 0.576577f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
328 U(expectedmat
).m
[2][0] = -1.727273f
; U(expectedmat
).m
[2][1] = -0.567568f
; U(expectedmat
).m
[2][2] = 0.840796f
; U(expectedmat
).m
[2][3] = 1.0f
;
329 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = -2.690547f
; U(expectedmat
).m
[3][3] = 0.0f
;
330 D3DXMatrixPerspectiveOffCenterLH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
, 3.2f
, -16.9f
);
331 expect_mat(expectedmat
,gotmat
);
333 /*____________D3DXMatrixPerspectiveOffCenterRH_______________*/
334 U(expectedmat
).m
[0][0] = 11.636364f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
335 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 0.576577f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
336 U(expectedmat
).m
[2][0] = 1.727273f
; U(expectedmat
).m
[2][1] = 0.567568f
; U(expectedmat
).m
[2][2] = -0.840796f
; U(expectedmat
).m
[2][3] = -1.0f
;
337 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = -2.690547f
; U(expectedmat
).m
[3][3] = 0.0f
;
338 D3DXMatrixPerspectiveOffCenterRH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
, 3.2f
, -16.9f
);
339 expect_mat(expectedmat
,gotmat
);
341 /*____________D3DXMatrixPerspectiveRH_______________*/
342 U(expectedmat
).m
[0][0] = -24.0f
; U(expectedmat
).m
[0][1] = -0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
343 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = -6.4f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
344 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = -0.783784f
; U(expectedmat
).m
[2][3] = -1.0f
;
345 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 1.881081f
; U(expectedmat
).m
[3][3] = 0.0f
;
346 D3DXMatrixPerspectiveRH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
);
347 expect_mat(expectedmat
,gotmat
);
349 /*____________D3DXMatrixReflect______________*/
350 U(expectedmat
).m
[0][0] = 0.307692f
; U(expectedmat
).m
[0][1] = -0.230769f
; U(expectedmat
).m
[0][2] = 0.923077f
; U(expectedmat
).m
[0][3] = 0.0f
;
351 U(expectedmat
).m
[1][0] = -0.230769; U(expectedmat
).m
[1][1] = 0.923077f
; U(expectedmat
).m
[1][2] = 0.307693f
; U(expectedmat
).m
[1][3] = 0.0f
;
352 U(expectedmat
).m
[2][0] = 0.923077f
; U(expectedmat
).m
[2][1] = 0.307693f
; U(expectedmat
).m
[2][2] = -0.230769f
; U(expectedmat
).m
[2][3] = 0.0f
;
353 U(expectedmat
).m
[3][0] = 1.615385f
; U(expectedmat
).m
[3][1] = 0.538462f
; U(expectedmat
).m
[3][2] = -2.153846f
; U(expectedmat
).m
[3][3] = 1.0f
;
354 D3DXMatrixReflect(&gotmat
,&plane
);
355 expect_mat(expectedmat
,gotmat
);
356 /*____________D3DXMatrixRotationAxis_____*/
357 U(expectedmat
).m
[0][0] = 0.508475f
; U(expectedmat
).m
[0][1] = 0.763805f
; U(expectedmat
).m
[0][2] = 0.397563f
; U(expectedmat
).m
[0][3] = 0.0f
;
358 U(expectedmat
).m
[1][0] = -0.814652f
; U(expectedmat
).m
[1][1] = 0.576271f
; U(expectedmat
).m
[1][2] = -0.065219f
; U(expectedmat
).m
[1][3] = 0.0f
;
359 U(expectedmat
).m
[2][0] = -0.278919f
; U(expectedmat
).m
[2][1] = -0.290713f
; U(expectedmat
).m
[2][2] = 0.915254f
; U(expectedmat
).m
[2][3] = 0.0f
;
360 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 0.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
361 D3DXMatrixRotationAxis(&gotmat
,&axis
,angle
);
362 expect_mat(expectedmat
,gotmat
);
364 /*____________D3DXMatrixRotationQuaternion______________*/
365 U(expectedmat
).m
[0][0] = -129.0f
; U(expectedmat
).m
[0][1] = -162.0f
; U(expectedmat
).m
[0][2] = -74.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
366 U(expectedmat
).m
[1][0] = 146.0f
; U(expectedmat
).m
[1][1] = -99.0f
; U(expectedmat
).m
[1][2] = -78.0f
; U(expectedmat
).m
[1][3] = 0.0f
;
367 U(expectedmat
).m
[2][0] = 102.0f
; U(expectedmat
).m
[2][1] = -34.0f
; U(expectedmat
).m
[2][2] = -33.0f
; U(expectedmat
).m
[2][3] = 0.0f
;
368 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 0.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
369 D3DXMatrixRotationQuaternion(&gotmat
,&q
);
370 expect_mat(expectedmat
,gotmat
);
372 /*____________D3DXMatrixRotationX______________*/
373 U(expectedmat
).m
[0][0] = 1.0f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
374 U(expectedmat
).m
[1][0] = 0.0; U(expectedmat
).m
[1][1] = 0.5f
; U(expectedmat
).m
[1][2] = sqrt(3.0f
)/2.0f
; U(expectedmat
).m
[1][3] = 0.0f
;
375 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = -sqrt(3.0f
)/2.0f
; U(expectedmat
).m
[2][2] = 0.5f
; U(expectedmat
).m
[2][3] = 0.0f
;
376 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 0.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
377 D3DXMatrixRotationX(&gotmat
,angle
);
378 expect_mat(expectedmat
,gotmat
);
380 /*____________D3DXMatrixRotationY______________*/
381 U(expectedmat
).m
[0][0] = 0.5f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = -sqrt(3.0f
)/2.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
382 U(expectedmat
).m
[1][0] = 0.0; U(expectedmat
).m
[1][1] = 1.0f
; U(expectedmat
).m
[1][2] = 0.0f
; U(expectedmat
).m
[1][3] = 0.0f
;
383 U(expectedmat
).m
[2][0] = sqrt(3.0f
)/2.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 0.5f
; U(expectedmat
).m
[2][3] = 0.0f
;
384 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 0.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
385 D3DXMatrixRotationY(&gotmat
,angle
);
386 expect_mat(expectedmat
,gotmat
);
388 /*____________D3DXMatrixRotationYawPitchRoll____*/
389 U(expectedmat
).m
[0][0] = 0.888777f
; U(expectedmat
).m
[0][1] = 0.091875f
; U(expectedmat
).m
[0][2] = -0.449037f
; U(expectedmat
).m
[0][3] = 0.0f
;
390 U(expectedmat
).m
[1][0] = 0.351713f
; U(expectedmat
).m
[1][1] = 0.491487f
; U(expectedmat
).m
[1][2] = 0.796705f
; U(expectedmat
).m
[1][3] = 0.0f
;
391 U(expectedmat
).m
[2][0] = 0.293893f
; U(expectedmat
).m
[2][1] = -0.866025f
; U(expectedmat
).m
[2][2] = 0.404509f
; U(expectedmat
).m
[2][3] = 0.0f
;
392 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 0.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
393 D3DXMatrixRotationYawPitchRoll(&gotmat
, 3.0f
*angle
/5.0f
, angle
, 3.0f
*angle
/17.0f
);
394 expect_mat(expectedmat
,gotmat
);
396 /*____________D3DXMatrixRotationZ______________*/
397 U(expectedmat
).m
[0][0] = 0.5f
; U(expectedmat
).m
[0][1] = sqrt(3.0f
)/2.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
398 U(expectedmat
).m
[1][0] = -sqrt(3.0f
)/2.0f
; U(expectedmat
).m
[1][1] = 0.5f
; U(expectedmat
).m
[1][2] = 0.0f
; U(expectedmat
).m
[1][3] = 0.0f
;
399 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 1.0f
; U(expectedmat
).m
[2][3] = 0.0f
;
400 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 0.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
401 D3DXMatrixRotationZ(&gotmat
,angle
);
402 expect_mat(expectedmat
,gotmat
);
404 /*____________D3DXMatrixScaling______________*/
405 U(expectedmat
).m
[0][0] = 0.69f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
406 U(expectedmat
).m
[1][0] = 0.0; U(expectedmat
).m
[1][1] = 0.53f
; U(expectedmat
).m
[1][2] = 0.0f
; U(expectedmat
).m
[1][3] = 0.0f
;
407 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 4.11f
; U(expectedmat
).m
[2][3] = 0.0f
;
408 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 0.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
409 D3DXMatrixScaling(&gotmat
,0.69f
,0.53f
,4.11f
);
410 expect_mat(expectedmat
,gotmat
);
412 /*____________D3DXMatrixShadow______________*/
413 U(expectedmat
).m
[0][0] = 12.786773f
; U(expectedmat
).m
[0][1] = 5.000961f
; U(expectedmat
).m
[0][2] = 4.353778f
; U(expectedmat
).m
[0][3] = 3.706595f
;
414 U(expectedmat
).m
[1][0] = 1.882715; U(expectedmat
).m
[1][1] = 8.805615f
; U(expectedmat
).m
[1][2] = 1.451259f
; U(expectedmat
).m
[1][3] = 1.235532f
;
415 U(expectedmat
).m
[2][0] = -7.530860f
; U(expectedmat
).m
[2][1] = -6.667949f
; U(expectedmat
).m
[2][2] = 1.333590f
; U(expectedmat
).m
[2][3] = -4.942127f
;
416 U(expectedmat
).m
[3][0] = -13.179006f
; U(expectedmat
).m
[3][1] = -11.668910f
; U(expectedmat
).m
[3][2] = -10.158816f
; U(expectedmat
).m
[3][3] = -1.510094f
;
417 D3DXMatrixShadow(&gotmat
,&light
,&plane
);
418 expect_mat(expectedmat
,gotmat
);
420 /*____________D3DXMatrixTranslation______________*/
421 U(expectedmat
).m
[0][0] = 1.0f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
422 U(expectedmat
).m
[1][0] = 0.0; U(expectedmat
).m
[1][1] = 1.0f
; U(expectedmat
).m
[1][2] = 0.0f
; U(expectedmat
).m
[1][3] = 0.0f
;
423 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 1.0f
; U(expectedmat
).m
[2][3] = 0.0f
;
424 U(expectedmat
).m
[3][0] = 0.69f
; U(expectedmat
).m
[3][1] = 0.53f
; U(expectedmat
).m
[3][2] = 4.11f
; U(expectedmat
).m
[3][3] = 1.0f
;
425 D3DXMatrixTranslation(&gotmat
,0.69f
,0.53f
,4.11f
);
426 expect_mat(expectedmat
,gotmat
);
428 /*____________D3DXMatrixTranspose______________*/
429 U(expectedmat
).m
[0][0] = 10.0f
; U(expectedmat
).m
[0][1] = 11.0f
; U(expectedmat
).m
[0][2] = 19.0f
; U(expectedmat
).m
[0][3] = 2.0f
;
430 U(expectedmat
).m
[1][0] = 5.0; U(expectedmat
).m
[1][1] = 20.0f
; U(expectedmat
).m
[1][2] = -21.0f
; U(expectedmat
).m
[1][3] = 3.0f
;
431 U(expectedmat
).m
[2][0] = 7.0f
; U(expectedmat
).m
[2][1] = 16.0f
; U(expectedmat
).m
[2][2] = 30.f
; U(expectedmat
).m
[2][3] = -4.0f
;
432 U(expectedmat
).m
[3][0] = 8.0f
; U(expectedmat
).m
[3][1] = 33.0f
; U(expectedmat
).m
[3][2] = 43.0f
; U(expectedmat
).m
[3][3] = -40.0f
;
433 D3DXMatrixTranspose(&gotmat
,&mat
);
434 expect_mat(expectedmat
,gotmat
);
437 static void D3DXPlaneTest(void)
439 D3DXPLANE expectedplane
, gotplane
, nulplane
, plane
;
440 D3DXVECTOR3 expectedvec
, gotvec
, vec1
, vec2
;
441 LPD3DXVECTOR3 funcpointer
;
445 plane
.a
= -3.0f
; plane
.b
= -1.0f
; plane
.c
= 4.0f
; plane
.d
= 7.0f
;
446 vec
.x
= 2.0f
; vec
.y
= 5.0f
; vec
.z
= -6.0f
; vec
.w
= 11.0f
;
448 /*_______________D3DXPlaneDot________________*/
450 got
= D3DXPlaneDot(&plane
,&vec
),
451 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
453 got
= D3DXPlaneDot(NULL
,&vec
),
454 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
456 got
= D3DXPlaneDot(NULL
,NULL
),
457 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
459 /*_______________D3DXPlaneDotCoord________________*/
461 got
= D3DXPlaneDotCoord(&plane
,&vec
),
462 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
464 got
= D3DXPlaneDotCoord(NULL
,&vec
),
465 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
467 got
= D3DXPlaneDotCoord(NULL
,NULL
),
468 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
470 /*_______________D3DXPlaneDotNormal______________*/
472 got
= D3DXPlaneDotNormal(&plane
,&vec
),
473 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
475 got
= D3DXPlaneDotNormal(NULL
,&vec
),
476 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
478 got
= D3DXPlaneDotNormal(NULL
,NULL
),
479 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
481 /*_______________D3DXPlaneIntersectLine___________*/
482 vec1
.x
= 9.0f
; vec1
.y
= 6.0f
; vec1
.z
= 3.0f
;
483 vec2
.x
= 2.0f
; vec2
.y
= 5.0f
; vec2
.z
= 8.0f
;
484 expectedvec
.x
= 20.0f
/3.0f
; expectedvec
.y
= 17.0f
/3.0f
; expectedvec
.z
= 14.0f
/3.0f
;
485 D3DXPlaneIntersectLine(&gotvec
,&plane
,&vec1
,&vec2
);
486 expect_vec3(expectedvec
, gotvec
);
487 /* Test a parallele line */
488 vec1
.x
= 11.0f
; vec1
.y
= 13.0f
; vec1
.z
= 15.0f
;
489 vec2
.x
= 17.0f
; vec2
.y
= 31.0f
; vec2
.z
= 24.0f
;
490 expectedvec
.x
= 20.0f
/3.0f
; expectedvec
.y
= 17.0f
/3.0f
; expectedvec
.z
= 14.0f
/3.0f
;
491 funcpointer
= D3DXPlaneIntersectLine(&gotvec
,&plane
,&vec1
,&vec2
);
492 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
494 /*_______________D3DXPlaneNormalize______________*/
495 expectedplane
.a
= -3.0f
/sqrt(26.0f
); expectedplane
.b
= -1.0f
/sqrt(26.0f
); expectedplane
.c
= 4.0f
/sqrt(26.0f
); expectedplane
.d
= 7.0/sqrt(26.0f
);
496 D3DXPlaneNormalize(&gotplane
, &plane
);
497 expect_plane(expectedplane
, gotplane
);
498 nulplane
.a
= 0.0; nulplane
.b
= 0.0f
, nulplane
.c
= 0.0f
; nulplane
.d
= 0.0f
;
499 expectedplane
.a
= 0.0f
; expectedplane
.b
= 0.0f
; expectedplane
.c
= 0.0f
; expectedplane
.d
= 0.0f
;
500 D3DXPlaneNormalize(&gotplane
, &nulplane
);
501 expect_plane(expectedplane
, gotplane
);
502 nulplane
.a
= 0.0; nulplane
.b
= 0.0f
, nulplane
.c
= 0.0f
; nulplane
.d
= 4.3f
;
503 expectedplane
.a
= 0.0f
; expectedplane
.b
= 0.0f
; expectedplane
.c
= 0.0f
; expectedplane
.d
= 0.0f
;
504 D3DXPlaneNormalize(&gotplane
, &nulplane
);
505 expect_plane(expectedplane
, gotplane
);
508 static void D3X8QuaternionTest(void)
510 D3DXQUATERNION expectedquat
, gotquat
, nul
, q
, r
, s
;
511 LPD3DXQUATERNION funcpointer
;
513 BOOL expectedbool
, gotbool
;
515 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
; nul
.w
= 0.0f
;
516 q
.x
= 1.0f
, q
.y
= 2.0f
; q
.z
= 4.0f
; q
.w
= 10.0f
;
517 r
.x
= -3.0f
; r
.y
= 4.0f
; r
.z
= -5.0f
; r
.w
= 7.0;
519 /*_______________D3DXQuaternionConjugate________________*/
520 expectedquat
.x
= -1.0f
; expectedquat
.y
= -2.0f
; expectedquat
.z
= -4.0f
; expectedquat
.w
= 10.0f
;
521 D3DXQuaternionConjugate(&gotquat
,&q
);
522 expect_vec4(expectedquat
,gotquat
);
523 /* Test the NULL case */
524 funcpointer
= D3DXQuaternionConjugate(&gotquat
,NULL
);
525 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
526 funcpointer
= D3DXQuaternionConjugate(NULL
,NULL
);
527 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
529 /*_______________D3DXQuaternionDot______________________*/
531 got
= D3DXQuaternionDot(&q
,&r
);
532 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
533 /* Tests the case NULL */
535 got
= D3DXQuaternionDot(NULL
,&r
);
536 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
538 got
= D3DXQuaternionDot(NULL
,NULL
);
539 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
541 /*_______________D3DXQuaternionIdentity________________*/
542 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 1.0f
;
543 D3DXQuaternionIdentity(&gotquat
);
544 expect_vec4(expectedquat
,gotquat
);
545 /* Test the NULL case */
546 funcpointer
= D3DXQuaternionIdentity(NULL
);
547 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
549 /*_______________D3DXQuaternionIsIdentity________________*/
550 s
.x
= 0.0f
; s
.y
= 0.0f
; s
.z
= 0.0f
; s
.w
= 1.0f
;
552 gotbool
= D3DXQuaternionIsIdentity(&s
);
553 ok( expectedbool
== gotbool
, "Expected boolean : %d, Got bool : %d\n", expectedbool
, gotbool
);
554 s
.x
= 2.3f
; s
.y
= -4.2f
; s
.z
= 1.2f
; s
.w
=0.2f
;
555 expectedbool
= FALSE
;
556 gotbool
= D3DXQuaternionIsIdentity(&q
);
557 ok( expectedbool
== gotbool
, "Expected boolean : %d, Got bool : %d\n", expectedbool
, gotbool
);
558 /* Test the NULL case */
559 gotbool
= D3DXQuaternionIsIdentity(NULL
);
560 ok(gotbool
== FALSE
, "Expected boolean: %d, Got boolean: %d\n", FALSE
, gotbool
);
562 /*_______________D3DXQuaternionLength__________________________*/
564 got
= D3DXQuaternionLength(&q
);
565 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
566 /* Tests the case NULL */
568 got
= D3DXQuaternionLength(NULL
);
569 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
571 /*_______________D3DXQuaternionLengthSq________________________*/
573 got
= D3DXQuaternionLengthSq(&q
);
574 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
575 /* Tests the case NULL */
577 got
= D3DXQuaternionLengthSq(NULL
);
578 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
580 /*_______________D3DXQuaternionNormalize________________________*/
581 expectedquat
.x
= 1.0f
/11.0f
; expectedquat
.y
= 2.0f
/11.0f
; expectedquat
.z
= 4.0f
/11.0f
; expectedquat
.w
= 10.0f
/11.0f
;
582 D3DXQuaternionNormalize(&gotquat
,&q
);
583 expect_vec4(expectedquat
,gotquat
);
584 /* Test the nul quaternion */
585 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.0f
;
586 D3DXQuaternionNormalize(&gotquat
,&nul
);
587 expect_vec4(expectedquat
,gotquat
);
590 static void D3X8Vector2Test(void)
592 D3DXVECTOR2 expectedvec
, gotvec
, nul
, nulproj
, u
, v
, w
, x
;
593 LPD3DXVECTOR2 funcpointer
;
594 D3DXVECTOR4 expectedtrans
, gottrans
;
596 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
598 nul
.x
= 0.0f
; nul
.y
= 0.0f
;
599 u
.x
= 3.0f
; u
.y
= 4.0f
;
600 v
.x
= -7.0f
; v
.y
= 9.0f
;
601 w
.x
= 4.0f
; w
.y
= -3.0f
;
602 x
.x
= 2.0f
; x
.y
= -11.0f
;
604 U(mat
).m
[0][0] = 1.0f
; U(mat
).m
[0][1] = 2.0f
; U(mat
).m
[0][2] = 3.0f
; U(mat
).m
[0][3] = 4.0f
;
605 U(mat
).m
[1][0] = 5.0f
; U(mat
).m
[1][1] = 6.0f
; U(mat
).m
[1][2] = 7.0f
; U(mat
).m
[1][3] = 8.0f
;
606 U(mat
).m
[2][0] = 9.0f
; U(mat
).m
[2][1] = 10.0f
; U(mat
).m
[2][2] = 11.0f
; U(mat
).m
[2][3] = 12.0f
;
607 U(mat
).m
[3][0] = 13.0f
; U(mat
).m
[3][1] = 14.0f
; U(mat
).m
[3][2] = 15.0f
; U(mat
).m
[3][3] = 16.0f
;
609 coeff1
= 2.0f
; coeff2
= 5.0f
;
612 /*_______________D3DXVec2Add__________________________*/
613 expectedvec
.x
= -4.0f
; expectedvec
.y
= 13.0f
;
614 D3DXVec2Add(&gotvec
,&u
,&v
);
615 expect_vec(expectedvec
,gotvec
);
616 /* Tests the case NULL */
617 funcpointer
= D3DXVec2Add(&gotvec
,NULL
,&v
);
618 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
619 funcpointer
= D3DXVec2Add(NULL
,NULL
,NULL
);
620 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
622 /*_______________D3DXVec2BaryCentric___________________*/
623 expectedvec
.x
= -12.0f
; expectedvec
.y
= -21.0f
;
624 D3DXVec2BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
625 expect_vec(expectedvec
,gotvec
);
627 /*_______________D3DXVec2CatmullRom____________________*/
628 expectedvec
.x
= 5820.25f
; expectedvec
.y
= -3654.5625f
;
629 D3DXVec2CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
630 expect_vec(expectedvec
,gotvec
);
632 /*_______________D3DXVec2CCW__________________________*/
634 got
= D3DXVec2CCW(&u
,&v
);
635 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
636 /* Tests the case NULL */
638 got
= D3DXVec2CCW(NULL
,&v
);
639 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
641 got
= D3DXVec2CCW(NULL
,NULL
);
642 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
644 /*_______________D3DXVec2Dot__________________________*/
646 got
= D3DXVec2Dot(&u
,&v
);
647 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
648 /* Tests the case NULL */
650 got
= D3DXVec2Dot(NULL
,&v
);
651 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
653 got
= D3DXVec2Dot(NULL
,NULL
);
654 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
656 /*_______________D3DXVec2Hermite__________________________*/
657 expectedvec
.x
= 2604.625f
; expectedvec
.y
= -4533.0f
;
658 D3DXVec2Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
659 expect_vec(expectedvec
,gotvec
);
661 /*_______________D3DXVec2Length__________________________*/
663 got
= D3DXVec2Length(&u
);
664 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
665 /* Tests the case NULL */
667 got
= D3DXVec2Length(NULL
);
668 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
670 /*_______________D3DXVec2LengthSq________________________*/
672 got
= D3DXVec2LengthSq(&u
);
673 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
674 /* Tests the case NULL */
676 got
= D3DXVec2LengthSq(NULL
);
677 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
679 /*_______________D3DXVec2Lerp__________________________*/
680 expectedvec
.x
= 68.0f
; expectedvec
.y
= -28.5f
;
681 D3DXVec2Lerp(&gotvec
,&u
,&v
,scale
);
682 expect_vec(expectedvec
,gotvec
);
683 /* Tests the case NULL */
684 funcpointer
= D3DXVec2Lerp(&gotvec
,NULL
,&v
,scale
);
685 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
686 funcpointer
= D3DXVec2Lerp(NULL
,NULL
,NULL
,scale
);
687 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
689 /*_______________D3DXVec2Maximize__________________________*/
690 expectedvec
.x
= 3.0f
; expectedvec
.y
= 9.0f
;
691 D3DXVec2Maximize(&gotvec
,&u
,&v
);
692 expect_vec(expectedvec
,gotvec
);
693 /* Tests the case NULL */
694 funcpointer
= D3DXVec2Maximize(&gotvec
,NULL
,&v
);
695 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
696 funcpointer
= D3DXVec2Maximize(NULL
,NULL
,NULL
);
697 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
699 /*_______________D3DXVec2Minimize__________________________*/
700 expectedvec
.x
= -7.0f
; expectedvec
.y
= 4.0f
;
701 D3DXVec2Minimize(&gotvec
,&u
,&v
);
702 expect_vec(expectedvec
,gotvec
);
703 /* Tests the case NULL */
704 funcpointer
= D3DXVec2Minimize(&gotvec
,NULL
,&v
);
705 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
706 funcpointer
= D3DXVec2Minimize(NULL
,NULL
,NULL
);
707 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
709 /*_______________D3DXVec2Normalize_________________________*/
710 expectedvec
.x
= 0.6f
; expectedvec
.y
= 0.8f
;
711 D3DXVec2Normalize(&gotvec
,&u
);
712 expect_vec(expectedvec
,gotvec
);
713 /* Test the nul vector */
714 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
;
715 D3DXVec2Normalize(&gotvec
,&nul
);
716 expect_vec(expectedvec
,gotvec
);
718 /*_______________D3DXVec2Scale____________________________*/
719 expectedvec
.x
= -19.5f
; expectedvec
.y
= -26.0f
;
720 D3DXVec2Scale(&gotvec
,&u
,scale
);
721 expect_vec(expectedvec
,gotvec
);
722 /* Tests the case NULL */
723 funcpointer
= D3DXVec2Scale(&gotvec
,NULL
,scale
);
724 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
725 funcpointer
= D3DXVec2Scale(NULL
,NULL
,scale
);
726 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
728 /*_______________D3DXVec2Subtract__________________________*/
729 expectedvec
.x
= 10.0f
; expectedvec
.y
= -5.0f
;
730 D3DXVec2Subtract(&gotvec
,&u
,&v
);
731 expect_vec(expectedvec
,gotvec
);
732 /* Tests the case NULL */
733 funcpointer
= D3DXVec2Subtract(&gotvec
,NULL
,&v
);
734 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
735 funcpointer
= D3DXVec2Subtract(NULL
,NULL
,NULL
);
736 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
738 /*_______________D3DXVec2Transform_______________________*/
739 expectedtrans
.x
= 36.0f
; expectedtrans
.y
= 44.0f
; expectedtrans
.z
= 52.0f
; expectedtrans
.w
= 60.0f
;
740 D3DXVec2Transform(&gottrans
,&u
,&mat
);
741 expect_vec4(expectedtrans
,gottrans
);
743 /*_______________D3DXVec2TransformCoord_______________________*/
744 expectedvec
.x
= 0.6f
; expectedvec
.y
= 11.0f
/15.0f
;
745 D3DXVec2TransformCoord(&gotvec
,&u
,&mat
);
746 expect_vec(expectedvec
,gotvec
);
747 /* Test the nul projected vector */
748 nulproj
.x
= -2.0f
; nulproj
.y
= -1.0f
;
749 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
;
750 D3DXVec2TransformCoord(&gotvec
,&nulproj
,&mat
);
751 expect_vec(expectedvec
,gotvec
);
753 /*_______________D3DXVec2TransformNormal______________________*/
754 expectedvec
.x
= 23.0f
; expectedvec
.y
= 30.0f
;
755 D3DXVec2TransformNormal(&gotvec
,&u
,&mat
);
756 expect_vec(expectedvec
,gotvec
);
759 static void D3X8Vector3Test(void)
761 D3DVIEWPORT8 viewport
;
762 D3DXVECTOR3 expectedvec
, gotvec
, nul
, nulproj
, u
, v
, w
, x
;
763 LPD3DXVECTOR3 funcpointer
;
764 D3DXVECTOR4 expectedtrans
, gottrans
;
765 D3DXMATRIX mat
, projection
, view
, world
;
766 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
768 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
;
769 u
.x
= 9.0f
; u
.y
= 6.0f
; u
.z
= 2.0f
;
770 v
.x
= 2.0f
; v
.y
= -3.0f
; v
.z
= -4.0;
771 w
.x
= 3.0f
; w
.y
= -5.0f
; w
.z
= 7.0f
;
772 x
.x
= 4.0f
; x
.y
= 1.0f
; x
.z
= 11.0f
;
774 viewport
.Width
= 800; viewport
.MinZ
= 0.2f
; viewport
.X
= 10;
775 viewport
.Height
= 680; viewport
.MaxZ
= 0.9f
; viewport
.Y
= 5;
777 U(mat
).m
[0][0] = 1.0f
; U(mat
).m
[0][1] = 2.0f
; U(mat
).m
[0][2] = 3.0f
; U(mat
).m
[0][3] = 4.0f
;
778 U(mat
).m
[1][0] = 5.0f
; U(mat
).m
[1][1] = 6.0f
; U(mat
).m
[1][2] = 7.0f
; U(mat
).m
[1][3] = 8.0f
;
779 U(mat
).m
[2][0] = 9.0f
; U(mat
).m
[2][1] = 10.0f
; U(mat
).m
[2][2] = 11.0f
; U(mat
).m
[2][3] = 12.0f
;
780 U(mat
).m
[3][0] = 13.0f
; U(mat
).m
[3][1] = 14.0f
; U(mat
).m
[3][2] = 15.0f
; U(mat
).m
[3][3] = 16.0f
;
782 view
.m
[0][1] = 5.0f
; view
.m
[0][2] = 7.0f
; view
.m
[0][3] = 8.0f
;
783 view
.m
[1][0] = 11.0f
; view
.m
[1][2] = 16.0f
; view
.m
[1][3] = 33.0f
;
784 view
.m
[2][0] = 19.0f
; view
.m
[2][1] = -21.0f
; view
.m
[2][3] = 43.0f
;
785 view
.m
[3][0] = 2.0f
; view
.m
[3][1] = 3.0f
; view
.m
[3][2] = -4.0f
;
786 view
.m
[0][0] = 10.0f
; view
.m
[1][1] = 20.0f
; view
.m
[2][2] = 30.0f
;
787 view
.m
[3][3] = -40.0f
;
789 world
.m
[0][0] = 21.0f
; world
.m
[0][1] = 2.0f
; world
.m
[0][2] = 3.0f
; world
.m
[0][3] = 4.0;
790 world
.m
[1][0] = 5.0f
; world
.m
[1][1] = 23.0f
; world
.m
[1][2] = 7.0f
; world
.m
[1][3] = 8.0f
;
791 world
.m
[2][0] = -8.0f
; world
.m
[2][1] = -7.0f
; world
.m
[2][2] = 25.0f
; world
.m
[2][3] = -5.0f
;
792 world
.m
[3][0] = -4.0f
; world
.m
[3][1] = -3.0f
; world
.m
[3][2] = -2.0f
; world
.m
[3][3] = 27.0f
;
794 coeff1
= 2.0f
; coeff2
= 5.0f
;
797 /*_______________D3DXVec3Add__________________________*/
798 expectedvec
.x
= 11.0f
; expectedvec
.y
= 3.0f
; expectedvec
.z
= -2.0f
;
799 D3DXVec3Add(&gotvec
,&u
,&v
);
800 expect_vec3(expectedvec
,gotvec
);
801 /* Tests the case NULL */
802 funcpointer
= D3DXVec3Add(&gotvec
,NULL
,&v
);
803 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
804 funcpointer
= D3DXVec3Add(NULL
,NULL
,NULL
);
805 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
807 /*_______________D3DXVec3BaryCentric___________________*/
808 expectedvec
.x
= -35.0f
; expectedvec
.y
= -67.0; expectedvec
.z
= 15.0f
;
809 D3DXVec3BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
811 expect_vec3(expectedvec
,gotvec
);
813 /*_______________D3DXVec3CatmullRom____________________*/
814 expectedvec
.x
= 1458.0f
; expectedvec
.y
= 22.1875f
; expectedvec
.z
= 4141.375f
;
815 D3DXVec3CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
816 expect_vec3(expectedvec
,gotvec
);
818 /*_______________D3DXVec3Cross________________________*/
819 expectedvec
.x
= -18.0f
; expectedvec
.y
= 40.0f
; expectedvec
.z
= -39.0f
;
820 D3DXVec3Cross(&gotvec
,&u
,&v
);
821 expect_vec3(expectedvec
,gotvec
);
822 /* Tests the case NULL */
823 funcpointer
= D3DXVec3Cross(&gotvec
,NULL
,&v
);
824 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
825 funcpointer
= D3DXVec3Cross(NULL
,NULL
,NULL
);
826 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
828 /*_______________D3DXVec3Dot__________________________*/
830 got
= D3DXVec3Dot(&u
,&v
);
831 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
832 /* Tests the case NULL */
834 got
= D3DXVec3Dot(NULL
,&v
);
835 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
837 got
= D3DXVec3Dot(NULL
,NULL
);
838 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
840 /*_______________D3DXVec3Hermite__________________________*/
841 expectedvec
.x
= -6045.75f
; expectedvec
.y
= -6650.0f
; expectedvec
.z
= 1358.875f
;
842 D3DXVec3Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
843 expect_vec3(expectedvec
,gotvec
);
845 /*_______________D3DXVec3Length__________________________*/
847 got
= D3DXVec3Length(&u
);
848 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
849 /* Tests the case NULL */
851 got
= D3DXVec3Length(NULL
);
852 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
854 /*_______________D3DXVec3LengthSq________________________*/
856 got
= D3DXVec3LengthSq(&u
);
857 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
858 /* Tests the case NULL */
860 got
= D3DXVec3LengthSq(NULL
);
861 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
863 /*_______________D3DXVec3Lerp__________________________*/
864 expectedvec
.x
= 54.5f
; expectedvec
.y
= 64.5f
, expectedvec
.z
= 41.0f
;
865 D3DXVec3Lerp(&gotvec
,&u
,&v
,scale
);
866 expect_vec3(expectedvec
,gotvec
);
867 /* Tests the case NULL */
868 funcpointer
= D3DXVec3Lerp(&gotvec
,NULL
,&v
,scale
);
869 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
870 funcpointer
= D3DXVec3Lerp(NULL
,NULL
,NULL
,scale
);
871 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
873 /*_______________D3DXVec3Maximize__________________________*/
874 expectedvec
.x
= 9.0f
; expectedvec
.y
= 6.0f
; expectedvec
.z
= 2.0f
;
875 D3DXVec3Maximize(&gotvec
,&u
,&v
);
876 expect_vec3(expectedvec
,gotvec
);
877 /* Tests the case NULL */
878 funcpointer
= D3DXVec3Maximize(&gotvec
,NULL
,&v
);
879 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
880 funcpointer
= D3DXVec3Maximize(NULL
,NULL
,NULL
);
881 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
883 /*_______________D3DXVec3Minimize__________________________*/
884 expectedvec
.x
= 2.0f
; expectedvec
.y
= -3.0f
; expectedvec
.z
= -4.0f
;
885 D3DXVec3Minimize(&gotvec
,&u
,&v
);
886 expect_vec3(expectedvec
,gotvec
);
887 /* Tests the case NULL */
888 funcpointer
= D3DXVec3Minimize(&gotvec
,NULL
,&v
);
889 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
890 funcpointer
= D3DXVec3Minimize(NULL
,NULL
,NULL
);
891 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
893 /*_______________D3DXVec3Normalize_________________________*/
894 expectedvec
.x
= 9.0f
/11.0f
; expectedvec
.y
= 6.0f
/11.0f
; expectedvec
.z
= 2.0f
/11.0f
;
895 D3DXVec3Normalize(&gotvec
,&u
);
896 expect_vec3(expectedvec
,gotvec
);
897 /* Test the nul vector */
898 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
;
899 D3DXVec3Normalize(&gotvec
,&nul
);
900 expect_vec3(expectedvec
,gotvec
);
902 /*_______________D3DXVec3Project_________________________*/
903 expectedvec
.x
= 1135.721924f
; expectedvec
.y
= 147.086914f
; expectedvec
.z
= 0.153412f
;
904 D3DXMatrixPerspectiveFovLH(&projection
,D3DX_PI
/4.0f
,20.0f
/17.0f
,1.0f
,1000.0f
);
905 D3DXVec3Project(&gotvec
,&u
,&viewport
,&projection
,&view
,&world
);
906 expect_vec3(expectedvec
,gotvec
);
908 /*_______________D3DXVec3Scale____________________________*/
909 expectedvec
.x
= -58.5f
; expectedvec
.y
= -39.0f
; expectedvec
.z
= -13.0f
;
910 D3DXVec3Scale(&gotvec
,&u
,scale
);
911 expect_vec3(expectedvec
,gotvec
);
912 /* Tests the case NULL */
913 funcpointer
= D3DXVec3Scale(&gotvec
,NULL
,scale
);
914 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
915 funcpointer
= D3DXVec3Scale(NULL
,NULL
,scale
);
916 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
918 /*_______________D3DXVec3Subtract_______________________*/
919 expectedvec
.x
= 7.0f
; expectedvec
.y
= 9.0f
; expectedvec
.z
= 6.0f
;
920 D3DXVec3Subtract(&gotvec
,&u
,&v
);
921 expect_vec3(expectedvec
,gotvec
);
922 /* Tests the case NULL */
923 funcpointer
= D3DXVec3Subtract(&gotvec
,NULL
,&v
);
924 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
925 funcpointer
= D3DXVec3Subtract(NULL
,NULL
,NULL
);
926 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
928 /*_______________D3DXVec3Transform_______________________*/
929 expectedtrans
.x
= 70.0f
; expectedtrans
.y
= 88.0f
; expectedtrans
.z
= 106.0f
; expectedtrans
.w
= 124.0f
;
930 D3DXVec3Transform(&gottrans
,&u
,&mat
);
931 expect_vec4(expectedtrans
,gottrans
);
933 /*_______________D3DXVec3TransformCoord_______________________*/
934 expectedvec
.x
= 70.0f
/124.0f
; expectedvec
.y
= 88.0f
/124.0f
; expectedvec
.z
= 106.0f
/124.0f
;
935 D3DXVec3TransformCoord(&gotvec
,&u
,&mat
);
936 expect_vec3(expectedvec
,gotvec
);
937 /* Test the nul projected vector */
938 nulproj
.x
= 1.0f
; nulproj
.y
= -1.0f
, nulproj
.z
= -1.0f
;
939 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
;
940 D3DXVec3TransformCoord(&gotvec
,&nulproj
,&mat
);
941 expect_vec3(expectedvec
,gotvec
);
943 /*_______________D3DXVec3TransformNormal______________________*/
944 expectedvec
.x
= 57.0f
; expectedvec
.y
= 74.0f
; expectedvec
.z
= 91.0f
;
945 D3DXVec3TransformNormal(&gotvec
,&u
,&mat
);
946 expect_vec3(expectedvec
,gotvec
);
948 /*_______________D3DXVec3Unproject_________________________*/
949 expectedvec
.x
= -2.913411f
; expectedvec
.y
= 1.593215f
; expectedvec
.z
= 0.380724f
;
950 D3DXMatrixPerspectiveFovLH(&projection
,D3DX_PI
/4.0f
,20.0f
/17.0f
,1.0f
,1000.0f
);
951 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,&projection
,&view
,&world
);
952 expect_vec3(expectedvec
,gotvec
);
955 static void D3X8Vector4Test(void)
957 D3DXVECTOR4 expectedvec
, gotvec
, nul
, u
, v
, w
, x
;
958 LPD3DXVECTOR4 funcpointer
;
959 D3DXVECTOR4 expectedtrans
, gottrans
;
961 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
963 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
; nul
.w
= 0.0f
;
964 u
.x
= 1.0f
; u
.y
= 2.0f
; u
.z
= 4.0f
; u
.w
= 10.0;
965 v
.x
= -3.0f
; v
.y
= 4.0f
; v
.z
= -5.0f
; v
.w
= 7.0;
966 w
.x
= 4.0f
; w
.y
=6.0f
; w
.z
= -2.0f
; w
.w
= 1.0f
;
967 x
.x
= 6.0f
; x
.y
= -7.0f
; x
.z
=8.0f
; x
.w
= -9.0f
;
969 U(mat
).m
[0][0] = 1.0f
; U(mat
).m
[0][1] = 2.0f
; U(mat
).m
[0][2] = 3.0f
; U(mat
).m
[0][3] = 4.0f
;
970 U(mat
).m
[1][0] = 5.0f
; U(mat
).m
[1][1] = 6.0f
; U(mat
).m
[1][2] = 7.0f
; U(mat
).m
[1][3] = 8.0f
;
971 U(mat
).m
[2][0] = 9.0f
; U(mat
).m
[2][1] = 10.0f
; U(mat
).m
[2][2] = 11.0f
; U(mat
).m
[2][3] = 12.0f
;
972 U(mat
).m
[3][0] = 13.0f
; U(mat
).m
[3][1] = 14.0f
; U(mat
).m
[3][2] = 15.0f
; U(mat
).m
[3][3] = 16.0f
;
974 coeff1
= 2.0f
; coeff2
= 5.0;
977 /*_______________D3DXVec4Add__________________________*/
978 expectedvec
.x
= -2.0f
; expectedvec
.y
= 6.0f
; expectedvec
.z
= -1.0f
; expectedvec
.w
= 17.0f
;
979 D3DXVec4Add(&gotvec
,&u
,&v
);
980 expect_vec4(expectedvec
,gotvec
);
981 /* Tests the case NULL */
982 funcpointer
= D3DXVec4Add(&gotvec
,NULL
,&v
);
983 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
984 funcpointer
= D3DXVec4Add(NULL
,NULL
,NULL
);
985 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
987 /*_______________D3DXVec4BaryCentric____________________*/
988 expectedvec
.x
= 8.0f
; expectedvec
.y
= 26.0; expectedvec
.z
= -44.0f
; expectedvec
.w
= -41.0f
;
989 D3DXVec4BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
990 expect_vec4(expectedvec
,gotvec
);
992 /*_______________D3DXVec4CatmullRom____________________*/
993 expectedvec
.x
= 2754.625f
; expectedvec
.y
= 2367.5625f
; expectedvec
.z
= 1060.1875f
; expectedvec
.w
= 131.3125f
;
994 D3DXVec4CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
995 expect_vec4(expectedvec
,gotvec
);
997 /*_______________D3DXVec4Cross_________________________*/
998 expectedvec
.x
= 390.0f
; expectedvec
.y
= -393.0f
; expectedvec
.z
= -316.0f
; expectedvec
.w
= 166.0f
;
999 D3DXVec4Cross(&gotvec
,&u
,&v
,&w
);
1000 expect_vec4(expectedvec
,gotvec
);
1002 /*_______________D3DXVec4Dot__________________________*/
1004 got
= D3DXVec4Dot(&u
,&v
);
1005 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1006 /* Tests the case NULL */
1008 got
= D3DXVec4Dot(NULL
,&v
);
1009 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1011 got
= D3DXVec4Dot(NULL
,NULL
);
1012 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1014 /*_______________D3DXVec4Hermite_________________________*/
1015 expectedvec
.x
= 1224.625f
; expectedvec
.y
= 3461.625f
; expectedvec
.z
= -4758.875f
; expectedvec
.w
= -5781.5f
;
1016 D3DXVec4Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1017 expect_vec4(expectedvec
,gotvec
);
1019 /*_______________D3DXVec4Length__________________________*/
1021 got
= D3DXVec4Length(&u
);
1022 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1023 /* Tests the case NULL */
1025 got
= D3DXVec4Length(NULL
);
1026 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1028 /*_______________D3DXVec4LengthSq________________________*/
1030 got
= D3DXVec4LengthSq(&u
);
1031 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1032 /* Tests the case NULL */
1034 got
= D3DXVec4LengthSq(NULL
);
1035 ok(fabs( got
- expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1037 /*_______________D3DXVec4Lerp__________________________*/
1038 expectedvec
.x
= 27.0f
; expectedvec
.y
= -11.0f
; expectedvec
.z
= 62.5; expectedvec
.w
= 29.5;
1039 D3DXVec4Lerp(&gotvec
,&u
,&v
,scale
);
1040 expect_vec4(expectedvec
,gotvec
);
1041 /* Tests the case NULL */
1042 funcpointer
= D3DXVec4Lerp(&gotvec
,NULL
,&v
,scale
);
1043 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1044 funcpointer
= D3DXVec4Lerp(NULL
,NULL
,NULL
,scale
);
1045 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1047 /*_______________D3DXVec4Maximize__________________________*/
1048 expectedvec
.x
= 1.0f
; expectedvec
.y
= 4.0f
; expectedvec
.z
= 4.0f
; expectedvec
.w
= 10.0;
1049 D3DXVec4Maximize(&gotvec
,&u
,&v
);
1050 expect_vec4(expectedvec
,gotvec
);
1051 /* Tests the case NULL */
1052 funcpointer
= D3DXVec4Maximize(&gotvec
,NULL
,&v
);
1053 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1054 funcpointer
= D3DXVec4Maximize(NULL
,NULL
,NULL
);
1055 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1057 /*_______________D3DXVec4Minimize__________________________*/
1058 expectedvec
.x
= -3.0f
; expectedvec
.y
= 2.0f
; expectedvec
.z
= -5.0f
; expectedvec
.w
= 7.0;
1059 D3DXVec4Minimize(&gotvec
,&u
,&v
);
1060 expect_vec4(expectedvec
,gotvec
);
1061 /* Tests the case NULL */
1062 funcpointer
= D3DXVec4Minimize(&gotvec
,NULL
,&v
);
1063 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1064 funcpointer
= D3DXVec4Minimize(NULL
,NULL
,NULL
);
1065 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1067 /*_______________D3DXVec4Normalize_________________________*/
1068 expectedvec
.x
= 1.0f
/11.0f
; expectedvec
.y
= 2.0f
/11.0f
; expectedvec
.z
= 4.0f
/11.0f
; expectedvec
.w
= 10.0f
/11.0f
;
1069 D3DXVec4Normalize(&gotvec
,&u
);
1070 expect_vec4(expectedvec
,gotvec
);
1071 /* Test the nul vector */
1072 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
; expectedvec
.w
= 0.0f
;
1073 D3DXVec4Normalize(&gotvec
,&nul
);
1074 expect_vec4(expectedvec
,gotvec
);
1076 /*_______________D3DXVec4Scale____________________________*/
1077 expectedvec
.x
= -6.5f
; expectedvec
.y
= -13.0f
; expectedvec
.z
= -26.0f
; expectedvec
.w
= -65.0f
;
1078 D3DXVec4Scale(&gotvec
,&u
,scale
);
1079 expect_vec4(expectedvec
,gotvec
);
1080 /* Tests the case NULL */
1081 funcpointer
= D3DXVec4Scale(&gotvec
,NULL
,scale
);
1082 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1083 funcpointer
= D3DXVec4Scale(NULL
,NULL
,scale
);
1084 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1086 /*_______________D3DXVec4Subtract__________________________*/
1087 expectedvec
.x
= 4.0f
; expectedvec
.y
= -2.0f
; expectedvec
.z
= 9.0f
; expectedvec
.w
= 3.0f
;
1088 D3DXVec4Subtract(&gotvec
,&u
,&v
);
1089 expect_vec4(expectedvec
,gotvec
);
1090 /* Tests the case NULL */
1091 funcpointer
= D3DXVec4Subtract(&gotvec
,NULL
,&v
);
1092 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1093 funcpointer
= D3DXVec4Subtract(NULL
,NULL
,NULL
);
1094 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1096 /*_______________D3DXVec4Transform_______________________*/
1097 expectedtrans
.x
= 177.0f
; expectedtrans
.y
= 194.0f
; expectedtrans
.z
= 211.0f
; expectedtrans
.w
= 228.0f
;
1098 D3DXVec4Transform(&gottrans
,&u
,&mat
);
1099 expect_vec4(expectedtrans
,gottrans
);
1107 D3X8QuaternionTest();