2 * Copyright 2008 David Adam
3 * Copyright 2008 Luis Busquets
4 * Copyright 2009 Henri Verbeet for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/test.h"
24 #define admitted_error 0.0001f
26 #define compare_vertex_sizes(type, exp) \
27 got=D3DXGetFVFVertexSize(type); \
28 ok(got==exp, "Expected: %d, Got: %d\n", exp, got);
30 static BOOL
compare(FLOAT u
, FLOAT v
)
32 return (fabs(u
-v
) < admitted_error
);
35 static BOOL
compare_vec3(D3DXVECTOR3 u
, D3DXVECTOR3 v
)
37 return ( compare(u
.x
, v
.x
) && compare(u
.y
, v
.y
) && compare(u
.z
, v
.z
) );
40 static void D3DXBoundProbeTest(void)
43 D3DXVECTOR3 bottom_point
, center
, top_point
, raydirection
, rayposition
;
46 /*____________Test the Box case___________________________*/
47 bottom_point
.x
= -3.0f
; bottom_point
.y
= -2.0f
; bottom_point
.z
= -1.0f
;
48 top_point
.x
= 7.0f
; top_point
.y
= 8.0f
; top_point
.z
= 9.0f
;
50 raydirection
.x
= -4.0f
; raydirection
.y
= -5.0f
; raydirection
.z
= -6.0f
;
51 rayposition
.x
= 5.0f
; rayposition
.y
= 5.0f
; rayposition
.z
= 11.0f
;
52 result
= D3DXBoxBoundProbe(&bottom_point
, &top_point
, &rayposition
, &raydirection
);
53 ok(result
== TRUE
, "expected TRUE, received FALSE\n");
55 raydirection
.x
= 4.0f
; raydirection
.y
= 5.0f
; raydirection
.z
= 6.0f
;
56 rayposition
.x
= 5.0f
; rayposition
.y
= 5.0f
; rayposition
.z
= 11.0f
;
57 result
= D3DXBoxBoundProbe(&bottom_point
, &top_point
, &rayposition
, &raydirection
);
58 ok(result
== FALSE
, "expected FALSE, received TRUE\n");
60 rayposition
.x
= -4.0f
; rayposition
.y
= 1.0f
; rayposition
.z
= -2.0f
;
61 result
= D3DXBoxBoundProbe(&bottom_point
, &top_point
, &rayposition
, &raydirection
);
62 ok(result
== TRUE
, "expected TRUE, received FALSE\n");
64 bottom_point
.x
= 1.0f
; bottom_point
.y
= 0.0f
; bottom_point
.z
= 0.0f
;
65 top_point
.x
= 1.0f
; top_point
.y
= 0.0f
; top_point
.z
= 0.0f
;
66 rayposition
.x
= 0.0f
; rayposition
.y
= 1.0f
; rayposition
.z
= 0.0f
;
67 raydirection
.x
= 0.0f
; raydirection
.y
= 3.0f
; raydirection
.z
= 0.0f
;
68 result
= D3DXBoxBoundProbe(&bottom_point
, &top_point
, &rayposition
, &raydirection
);
69 ok(result
== FALSE
, "expected FALSE, received TRUE\n");
71 bottom_point
.x
= 1.0f
; bottom_point
.y
= 2.0f
; bottom_point
.z
= 3.0f
;
72 top_point
.x
= 10.0f
; top_point
.y
= 15.0f
; top_point
.z
= 20.0f
;
74 raydirection
.x
= 7.0f
; raydirection
.y
= 8.0f
; raydirection
.z
= 9.0f
;
75 rayposition
.x
= 3.0f
; rayposition
.y
= 7.0f
; rayposition
.z
= -6.0f
;
76 result
= D3DXBoxBoundProbe(&bottom_point
, &top_point
, &rayposition
, &raydirection
);
77 ok(result
== TRUE
, "expected TRUE, received FALSE\n");
79 bottom_point
.x
= 0.0f
; bottom_point
.y
= 0.0f
; bottom_point
.z
= 0.0f
;
80 top_point
.x
= 1.0f
; top_point
.y
= 1.0f
; top_point
.z
= 1.0f
;
82 raydirection
.x
= 0.0f
; raydirection
.y
= 1.0f
; raydirection
.z
= .0f
;
83 rayposition
.x
= -3.0f
; rayposition
.y
= 0.0f
; rayposition
.z
= 0.0f
;
84 result
= D3DXBoxBoundProbe(&bottom_point
, &top_point
, &rayposition
, &raydirection
);
85 ok(result
== FALSE
, "expected FALSE, received TRUE\n");
87 raydirection
.x
= 1.0f
; raydirection
.y
= 0.0f
; raydirection
.z
= .0f
;
88 rayposition
.x
= -3.0f
; rayposition
.y
= 0.0f
; rayposition
.z
= 0.0f
;
89 result
= D3DXBoxBoundProbe(&bottom_point
, &top_point
, &rayposition
, &raydirection
);
90 ok(result
== TRUE
, "expected TRUE, received FALSE\n");
92 /*____________Test the Sphere case________________________*/
94 center
.x
= 1.0f
; center
.y
= 2.0f
; center
.z
= 3.0f
;
95 raydirection
.x
= 2.0f
; raydirection
.y
= -4.0f
; raydirection
.z
= 2.0f
;
97 rayposition
.x
= 5.0f
; rayposition
.y
= 5.0f
; rayposition
.z
= 9.0f
;
98 result
= D3DXSphereBoundProbe(¢er
, radius
, &rayposition
, &raydirection
);
99 ok(result
== TRUE
, "expected TRUE, received FALSE\n");
101 rayposition
.x
= 45.0f
; rayposition
.y
= -75.0f
; rayposition
.z
= 49.0f
;
102 result
= D3DXSphereBoundProbe(¢er
, radius
, &rayposition
, &raydirection
);
103 ok(result
== FALSE
, "expected FALSE, received TRUE\n");
105 rayposition
.x
= 5.0f
; rayposition
.y
= 11.0f
; rayposition
.z
= 9.0f
;
106 result
= D3DXSphereBoundProbe(¢er
, radius
, &rayposition
, &raydirection
);
107 ok(result
== FALSE
, "expected FALSE, received TRUE\n");
110 static void D3DXComputeBoundingBoxTest(void)
112 D3DXVECTOR3 exp_max
, exp_min
, got_max
, got_min
, vertex
[5];
115 vertex
[0].x
= 1.0f
; vertex
[0].y
= 1.0f
; vertex
[0].z
= 1.0f
;
116 vertex
[1].x
= 1.0f
; vertex
[1].y
= 1.0f
; vertex
[1].z
= 1.0f
;
117 vertex
[2].x
= 1.0f
; vertex
[2].y
= 1.0f
; vertex
[2].z
= 1.0f
;
118 vertex
[3].x
= 1.0f
; vertex
[3].y
= 1.0f
; vertex
[3].z
= 1.0f
;
119 vertex
[4].x
= 9.0f
; vertex
[4].y
= 9.0f
; vertex
[4].z
= 9.0f
;
121 exp_min
.x
= 1.0f
; exp_min
.y
= 1.0f
; exp_min
.z
= 1.0f
;
122 exp_max
.x
= 9.0f
; exp_max
.y
= 9.0f
; exp_max
.z
= 9.0f
;
124 hr
= D3DXComputeBoundingBox(&vertex
[3],2,D3DXGetFVFVertexSize(D3DFVF_XYZ
),&got_min
,&got_max
);
126 ok( hr
== D3D_OK
, "Expected D3D_OK, got %#x\n", hr
);
127 ok( compare_vec3(exp_min
,got_min
), "Expected min: (%f, %f, %f), got: (%f, %f, %f)\n", exp_min
.x
,exp_min
.y
,exp_min
.z
,got_min
.x
,got_min
.y
,got_min
.z
);
128 ok( compare_vec3(exp_max
,got_max
), "Expected max: (%f, %f, %f), got: (%f, %f, %f)\n", exp_max
.x
,exp_max
.y
,exp_max
.z
,got_max
.x
,got_max
.y
,got_max
.z
);
130 /*________________________*/
132 vertex
[0].x
= 2.0f
; vertex
[0].y
= 5.9f
; vertex
[0].z
= -1.2f
;
133 vertex
[1].x
= -1.87f
; vertex
[1].y
= 7.9f
; vertex
[1].z
= 7.4f
;
134 vertex
[2].x
= 7.43f
; vertex
[2].y
= -0.9f
; vertex
[2].z
= 11.9f
;
135 vertex
[3].x
= -6.92f
; vertex
[3].y
= 6.3f
; vertex
[3].z
= -3.8f
;
136 vertex
[4].x
= 11.4f
; vertex
[4].y
= -8.1f
; vertex
[4].z
= 4.5f
;
138 exp_min
.x
= -6.92f
; exp_min
.y
= -8.1f
; exp_min
.z
= -3.80f
;
139 exp_max
.x
= 11.4f
; exp_max
.y
= 7.90f
; exp_max
.z
= 11.9f
;
141 hr
= D3DXComputeBoundingBox(&vertex
[0],5,D3DXGetFVFVertexSize(D3DFVF_XYZ
),&got_min
,&got_max
);
143 ok( hr
== D3D_OK
, "Expected D3D_OK, got %#x\n", hr
);
144 ok( compare_vec3(exp_min
,got_min
), "Expected min: (%f, %f, %f), got: (%f, %f, %f)\n", exp_min
.x
,exp_min
.y
,exp_min
.z
,got_min
.x
,got_min
.y
,got_min
.z
);
145 ok( compare_vec3(exp_max
,got_max
), "Expected max: (%f, %f, %f), got: (%f, %f, %f)\n", exp_max
.x
,exp_max
.y
,exp_max
.z
,got_max
.x
,got_max
.y
,got_max
.z
);
147 /*________________________*/
149 vertex
[0].x
= 2.0f
; vertex
[0].y
= 5.9f
; vertex
[0].z
= -1.2f
;
150 vertex
[1].x
= -1.87f
; vertex
[1].y
= 7.9f
; vertex
[1].z
= 7.4f
;
151 vertex
[2].x
= 7.43f
; vertex
[2].y
= -0.9f
; vertex
[2].z
= 11.9f
;
152 vertex
[3].x
= -6.92f
; vertex
[3].y
= 6.3f
; vertex
[3].z
= -3.8f
;
153 vertex
[4].x
= 11.4f
; vertex
[4].y
= -8.1f
; vertex
[4].z
= 4.5f
;
155 exp_min
.x
= -6.92f
; exp_min
.y
= -0.9f
; exp_min
.z
= -3.8f
;
156 exp_max
.x
= 7.43f
; exp_max
.y
= 7.90f
; exp_max
.z
= 11.9f
;
158 hr
= D3DXComputeBoundingBox(&vertex
[0],4,D3DXGetFVFVertexSize(D3DFVF_XYZ
),&got_min
,&got_max
);
160 ok( hr
== D3D_OK
, "Expected D3D_OK, got %#x\n", hr
);
161 ok( compare_vec3(exp_min
,got_min
), "Expected min: (%f, %f, %f), got: (%f, %f, %f)\n", exp_min
.x
,exp_min
.y
,exp_min
.z
,got_min
.x
,got_min
.y
,got_min
.z
);
162 ok( compare_vec3(exp_max
,got_max
), "Expected max: (%f, %f, %f), got: (%f, %f, %f)\n", exp_max
.x
,exp_max
.y
,exp_max
.z
,got_max
.x
,got_max
.y
,got_max
.z
);
164 /*________________________*/
165 hr
= D3DXComputeBoundingBox(NULL
,5,D3DXGetFVFVertexSize(D3DFVF_XYZ
),&got_min
,&got_max
);
166 ok( hr
== D3DERR_INVALIDCALL
, "Expected D3DERR_INVALIDCALL, got %#x\n", hr
);
168 /*________________________*/
169 hr
= D3DXComputeBoundingBox(&vertex
[3],5,D3DXGetFVFVertexSize(D3DFVF_XYZ
),NULL
,&got_max
);
170 ok( hr
== D3DERR_INVALIDCALL
, "Expected D3DERR_INVALIDCALL, got %#x\n", hr
);
172 /*________________________*/
173 hr
= D3DXComputeBoundingBox(&vertex
[3],5,D3DXGetFVFVertexSize(D3DFVF_XYZ
),&got_min
,NULL
);
174 ok( hr
== D3DERR_INVALIDCALL
, "Expected D3DERR_INVALIDCALL, got %#x\n", hr
);
177 static void D3DXComputeBoundingSphereTest(void)
179 D3DXVECTOR3 exp_cen
, got_cen
, vertex
[5];
180 FLOAT exp_rad
, got_rad
;
183 vertex
[0].x
= 1.0f
; vertex
[0].y
= 1.0f
; vertex
[0].z
= 1.0f
;
184 vertex
[1].x
= 1.0f
; vertex
[1].y
= 1.0f
; vertex
[1].z
= 1.0f
;
185 vertex
[2].x
= 1.0f
; vertex
[2].y
= 1.0f
; vertex
[2].z
= 1.0f
;
186 vertex
[3].x
= 1.0f
; vertex
[3].y
= 1.0f
; vertex
[3].z
= 1.0f
;
187 vertex
[4].x
= 9.0f
; vertex
[4].y
= 9.0f
; vertex
[4].z
= 9.0f
;
190 exp_cen
.x
= 5.0; exp_cen
.y
= 5.0; exp_cen
.z
= 5.0;
192 hr
= D3DXComputeBoundingSphere(&vertex
[3],2,D3DXGetFVFVertexSize(D3DFVF_XYZ
),&got_cen
,&got_rad
);
194 ok( hr
== D3D_OK
, "Expected D3D_OK, got %#x\n", hr
);
195 ok( compare(exp_rad
, got_rad
), "Expected radius: %f, got radius: %f\n", exp_rad
, got_rad
);
196 ok( compare_vec3(exp_cen
,got_cen
), "Expected center: (%f, %f, %f), got center: (%f, %f, %f)\n", exp_cen
.x
,exp_cen
.y
,exp_cen
.z
,got_cen
.x
,got_cen
.y
,got_cen
.z
);
198 /*________________________*/
200 vertex
[0].x
= 2.0f
; vertex
[0].y
= 5.9f
; vertex
[0].z
= -1.2f
;
201 vertex
[1].x
= -1.87f
; vertex
[1].y
= 7.9f
; vertex
[1].z
= 7.4f
;
202 vertex
[2].x
= 7.43f
; vertex
[2].y
= -0.9f
; vertex
[2].z
= 11.9f
;
203 vertex
[3].x
= -6.92f
; vertex
[3].y
= 6.3f
; vertex
[3].z
= -3.8f
;
204 vertex
[4].x
= 11.4f
; vertex
[4].y
= -8.1f
; vertex
[4].z
= 4.5f
;
206 exp_rad
= 13.707883f
;
207 exp_cen
.x
= 2.408f
; exp_cen
.y
= 2.22f
; exp_cen
.z
= 3.76f
;
209 hr
= D3DXComputeBoundingSphere(&vertex
[0],5,D3DXGetFVFVertexSize(D3DFVF_XYZ
),&got_cen
,&got_rad
);
211 ok( hr
== D3D_OK
, "Expected D3D_OK, got %#x\n", hr
);
212 ok( compare(exp_rad
, got_rad
), "Expected radius: %f, got radius: %f\n", exp_rad
, got_rad
);
213 ok( compare_vec3(exp_cen
,got_cen
), "Expected center: (%f, %f, %f), got center: (%f, %f, %f)\n", exp_cen
.x
,exp_cen
.y
,exp_cen
.z
,got_cen
.x
,got_cen
.y
,got_cen
.z
);
215 /*________________________*/
216 hr
= D3DXComputeBoundingSphere(NULL
,5,D3DXGetFVFVertexSize(D3DFVF_XYZ
),&got_cen
,&got_rad
);
217 ok( hr
== D3DERR_INVALIDCALL
, "Expected D3DERR_INVALIDCALL, got %#x\n", hr
);
219 /*________________________*/
220 hr
= D3DXComputeBoundingSphere(&vertex
[3],5,D3DXGetFVFVertexSize(D3DFVF_XYZ
),NULL
,&got_rad
);
221 ok( hr
== D3DERR_INVALIDCALL
, "Expected D3DERR_INVALIDCALL, got %#x\n", hr
);
223 /*________________________*/
224 hr
= D3DXComputeBoundingSphere(&vertex
[3],5,D3DXGetFVFVertexSize(D3DFVF_XYZ
),&got_cen
,NULL
);
225 ok( hr
== D3DERR_INVALIDCALL
, "Expected D3DERR_INVALIDCALL, got %#x\n", hr
);
228 static void D3DXDeclaratorFromFVFTest(void)
230 D3DVERTEXELEMENT9 decl
[MAX_FVF_DECL_SIZE
];
234 static const D3DVERTEXELEMENT9 exp1
[6] = {
235 {0, 0, D3DDECLTYPE_FLOAT3
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
236 {0, 0xC, D3DDECLTYPE_FLOAT3
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_NORMAL
, 0},
237 {0, 0x18, D3DDECLTYPE_D3DCOLOR
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_COLOR
, 0},
238 {0, 0x1C, D3DDECLTYPE_D3DCOLOR
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_COLOR
, 1},
239 {0, 0x20, D3DDECLTYPE_FLOAT2
, D3DDECLMETHOD_DEFAULT
,D3DDECLUSAGE_TEXCOORD
, 0},
242 static const D3DVERTEXELEMENT9 exp2
[3] = {
243 {0, 0, D3DDECLTYPE_FLOAT4
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITIONT
, 0},
244 {0, 0x10, D3DDECLTYPE_FLOAT1
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_PSIZE
, 0},
247 static const D3DVERTEXELEMENT9 exp3
[4] = {
248 {0, 0, D3DDECLTYPE_FLOAT3
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
249 {0, 0xC, D3DDECLTYPE_FLOAT4
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_BLENDWEIGHT
, 0},
250 {0, 0x1C, D3DDECLTYPE_UBYTE4
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_BLENDINDICES
, 0},
253 /* Note: passing NULL as declaration segfaults */
256 hr
= D3DXDeclaratorFromFVF(0, decl
);
257 ok(hr
== D3D_OK
, "D3DXDeclaratorFromFVF returned %#x, expected %#x\n", hr
, D3D_OK
);
258 ok(decl
[0].Stream
== 0xFF, "D3DXDeclaratorFromFVF returned an incorrect vertex declaration\n"); /* end element */
260 hr
= D3DXDeclaratorFromFVF(D3DFVF_XYZ
| D3DFVF_NORMAL
| D3DFVF_DIFFUSE
| D3DFVF_SPECULAR
| D3DFVF_TEX1
, decl
);
261 ok(hr
== D3D_OK
, "D3DXDeclaratorFromFVF returned %#x, expected %#x\n", hr
, D3D_OK
);
267 ok(decl
[i
].Stream
== exp1
[i
].Stream
, "Returned stream %d, expected %d\n", decl
[i
].Stream
, exp1
[i
].Stream
);
268 ok(decl
[i
].Type
== exp1
[i
].Type
, "Returned type %d, expected %d\n", decl
[i
].Type
, exp1
[i
].Type
);
269 ok(decl
[i
].Method
== exp1
[i
].Method
, "Returned method %d, expected %d\n", decl
[i
].Method
, exp1
[i
].Method
);
270 ok(decl
[i
].Usage
== exp1
[i
].Usage
, "Returned usage %d, expected %d\n", decl
[i
].Usage
, exp1
[i
].Usage
);
271 ok(decl
[i
].UsageIndex
== exp1
[i
].UsageIndex
, "Returned usage index %d, expected %d\n", decl
[i
].UsageIndex
, exp1
[i
].UsageIndex
);
272 ok(decl
[i
].Offset
== exp1
[i
].Offset
, "Returned offset %d, expected %d\n", decl
[1].Offset
, exp1
[i
].Offset
);
274 ok(decl
[5].Stream
== 0xFF, "Returned too long vertex declaration\n"); /* end element */
280 hr
= D3DXDeclaratorFromFVF(D3DFVF_XYZRHW
| D3DFVF_PSIZE
, decl
);
281 ok(hr
== D3D_OK
, "D3DXDeclaratorFromFVF returned %#x, expected %#x\n", hr
, D3D_OK
);
287 ok(decl
[i
].Stream
== exp2
[i
].Stream
, "Returned stream %d, expected %d\n", decl
[i
].Stream
, exp2
[i
].Stream
);
288 ok(decl
[i
].Type
== exp2
[i
].Type
, "Returned type %d, expected %d\n", decl
[i
].Type
, exp1
[i
].Type
);
289 ok(decl
[i
].Method
== exp2
[i
].Method
, "Returned method %d, expected %d\n", decl
[i
].Method
, exp2
[i
].Method
);
290 ok(decl
[i
].Usage
== exp2
[i
].Usage
, "Returned usage %d, expected %d\n", decl
[i
].Usage
, exp2
[i
].Usage
);
291 ok(decl
[i
].UsageIndex
== exp2
[i
].UsageIndex
, "Returned usage index %d, expected %d\n", decl
[i
].UsageIndex
, exp2
[i
].UsageIndex
);
292 ok(decl
[i
].Offset
== exp2
[i
].Offset
, "Returned offset %d, expected %d\n", decl
[1].Offset
, exp2
[i
].Offset
);
294 ok(decl
[2].Stream
== 0xFF, "Returned too long vertex declaration\n"); /* end element */
300 hr
= D3DXDeclaratorFromFVF(D3DFVF_XYZB5
, decl
);
301 ok(hr
== D3DERR_INVALIDCALL
, "D3DXDeclaratorFromFVF returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
303 hr
= D3DXDeclaratorFromFVF(D3DFVF_XYZB5
| D3DFVF_LASTBETA_UBYTE4
, decl
);
304 ok(hr
== D3D_OK
, "D3DXDeclaratorFromFVF returned %#x, expected %#x\n", hr
, D3D_OK
);
310 ok(decl
[i
].Stream
== exp3
[i
].Stream
, "Returned stream %d, expected %d\n", decl
[i
].Stream
, exp3
[i
].Stream
);
311 ok(decl
[i
].Type
== exp3
[i
].Type
, "Returned type %d, expected %d\n", decl
[i
].Type
, exp3
[i
].Type
);
312 ok(decl
[i
].Method
== exp3
[i
].Method
, "Returned method %d, expected %d\n", decl
[i
].Method
, exp3
[i
].Method
);
313 ok(decl
[i
].Usage
== exp3
[i
].Usage
, "Returned usage %d, expected %d\n", decl
[i
].Usage
, exp3
[i
].Usage
);
314 ok(decl
[i
].UsageIndex
== exp3
[i
].UsageIndex
, "Returned usage index %d, expected %d\n", decl
[i
].UsageIndex
, exp3
[i
].UsageIndex
);
315 ok(decl
[i
].Offset
== exp3
[i
].Offset
, "Returned offset %d, expected %d\n", decl
[1].Offset
, exp3
[i
].Offset
);
317 ok(decl
[3].Stream
== 0xFF, "Returned too long vertex declaration\n"); /* end element */
322 static void D3DXGetFVFVertexSizeTest(void)
326 compare_vertex_sizes (D3DFVF_XYZ
, 12);
328 compare_vertex_sizes (D3DFVF_XYZB3
, 24);
330 compare_vertex_sizes (D3DFVF_XYZB5
, 32);
332 compare_vertex_sizes (D3DFVF_XYZ
| D3DFVF_NORMAL
, 24);
334 compare_vertex_sizes (D3DFVF_XYZ
| D3DFVF_DIFFUSE
, 16);
336 compare_vertex_sizes (
339 D3DFVF_TEXCOORDSIZE1(0), 16);
340 compare_vertex_sizes (
343 D3DFVF_TEXCOORDSIZE1(0) |
344 D3DFVF_TEXCOORDSIZE1(1), 20);
346 compare_vertex_sizes (
349 D3DFVF_TEXCOORDSIZE2(0), 20);
351 compare_vertex_sizes (
354 D3DFVF_TEXCOORDSIZE2(0) |
355 D3DFVF_TEXCOORDSIZE2(1), 28);
357 compare_vertex_sizes (
360 D3DFVF_TEXCOORDSIZE2(0) |
361 D3DFVF_TEXCOORDSIZE2(1) |
362 D3DFVF_TEXCOORDSIZE2(2) |
363 D3DFVF_TEXCOORDSIZE2(3) |
364 D3DFVF_TEXCOORDSIZE2(4) |
365 D3DFVF_TEXCOORDSIZE2(5), 60);
367 compare_vertex_sizes (
370 D3DFVF_TEXCOORDSIZE2(0) |
371 D3DFVF_TEXCOORDSIZE2(1) |
372 D3DFVF_TEXCOORDSIZE2(2) |
373 D3DFVF_TEXCOORDSIZE2(3) |
374 D3DFVF_TEXCOORDSIZE2(4) |
375 D3DFVF_TEXCOORDSIZE2(5) |
376 D3DFVF_TEXCOORDSIZE2(6) |
377 D3DFVF_TEXCOORDSIZE2(7), 76);
379 compare_vertex_sizes (
382 D3DFVF_TEXCOORDSIZE3(0), 24);
384 compare_vertex_sizes (
387 D3DFVF_TEXCOORDSIZE3(0) |
388 D3DFVF_TEXCOORDSIZE3(1) |
389 D3DFVF_TEXCOORDSIZE3(2) |
390 D3DFVF_TEXCOORDSIZE3(3), 60);
392 compare_vertex_sizes (
395 D3DFVF_TEXCOORDSIZE4(0), 28);
397 compare_vertex_sizes (
400 D3DFVF_TEXCOORDSIZE4(0) |
401 D3DFVF_TEXCOORDSIZE4(1), 44);
403 compare_vertex_sizes (
406 D3DFVF_TEXCOORDSIZE4(0) |
407 D3DFVF_TEXCOORDSIZE4(1) |
408 D3DFVF_TEXCOORDSIZE4(2), 60);
410 compare_vertex_sizes (
416 D3DFVF_TEXCOORDSIZE4(0) |
417 D3DFVF_TEXCOORDSIZE4(1) |
418 D3DFVF_TEXCOORDSIZE4(2) |
419 D3DFVF_TEXCOORDSIZE4(3) |
420 D3DFVF_TEXCOORDSIZE4(4) |
421 D3DFVF_TEXCOORDSIZE4(5) |
422 D3DFVF_TEXCOORDSIZE4(6) |
423 D3DFVF_TEXCOORDSIZE4(7), 180);
426 static void D3DXIntersectTriTest(void)
428 BOOL exp_res
, got_res
;
429 D3DXVECTOR3 position
, ray
, vertex
[3];
430 FLOAT exp_dist
, got_dist
, exp_u
, got_u
, exp_v
, got_v
;
432 vertex
[0].x
= 1.0f
; vertex
[0].y
= 0.0f
; vertex
[0].z
= 0.0f
;
433 vertex
[1].x
= 2.0f
; vertex
[1].y
= 0.0f
; vertex
[1].z
= 0.0f
;
434 vertex
[2].x
= 1.0f
; vertex
[2].y
= 1.0f
; vertex
[2].z
= 0.0f
;
436 position
.x
= -14.5f
; position
.y
= -23.75f
; position
.z
= -32.0f
;
438 ray
.x
= 2.0f
; ray
.y
= 3.0f
; ray
.z
= 4.0f
;
440 exp_res
= TRUE
; exp_u
= 0.5f
; exp_v
= 0.25f
; exp_dist
= 8.0f
;
442 got_res
= D3DXIntersectTri(&vertex
[0],&vertex
[1],&vertex
[2],&position
,&ray
,&got_u
,&got_v
,&got_dist
);
443 ok( got_res
== exp_res
, "Expected result = %d, got %d\n",exp_res
,got_res
);
444 ok( compare(exp_u
,got_u
), "Expected u = %f, got %f\n",exp_u
,got_u
);
445 ok( compare(exp_v
,got_v
), "Expected v = %f, got %f\n",exp_v
,got_v
);
446 ok( compare(exp_dist
,got_dist
), "Expected distance = %f, got %f\n",exp_dist
,got_dist
);
448 /*Only positive ray is taken in account*/
450 vertex
[0].x
= 1.0f
; vertex
[0].y
= 0.0f
; vertex
[0].z
= 0.0f
;
451 vertex
[1].x
= 2.0f
; vertex
[1].y
= 0.0f
; vertex
[1].z
= 0.0f
;
452 vertex
[2].x
= 1.0f
; vertex
[2].y
= 1.0f
; vertex
[2].z
= 0.0f
;
454 position
.x
= 17.5f
; position
.y
= 24.25f
; position
.z
= 32.0f
;
456 ray
.x
= 2.0f
; ray
.y
= 3.0f
; ray
.z
= 4.0f
;
460 got_res
= D3DXIntersectTri(&vertex
[0],&vertex
[1],&vertex
[2],&position
,&ray
,&got_u
,&got_v
,&got_dist
);
461 ok( got_res
== exp_res
, "Expected result = %d, got %d\n",exp_res
,got_res
);
463 /*Intersection between ray and triangle in a same plane is considered as empty*/
465 vertex
[0].x
= 4.0f
; vertex
[0].y
= 0.0f
; vertex
[0].z
= 0.0f
;
466 vertex
[1].x
= 6.0f
; vertex
[1].y
= 0.0f
; vertex
[1].z
= 0.0f
;
467 vertex
[2].x
= 4.0f
; vertex
[2].y
= 2.0f
; vertex
[2].z
= 0.0f
;
469 position
.x
= 1.0f
; position
.y
= 1.0f
; position
.z
= 0.0f
;
471 ray
.x
= 1.0f
; ray
.y
= 0.0f
; ray
.z
= 0.0f
;
475 got_res
= D3DXIntersectTri(&vertex
[0],&vertex
[1],&vertex
[2],&position
,&ray
,&got_u
,&got_v
,&got_dist
);
476 ok( got_res
== exp_res
, "Expected result = %d, got %d\n",exp_res
,got_res
);
479 static void test_get_decl_vertex_size(void)
481 static const D3DVERTEXELEMENT9 declaration1
[] =
483 {0, 0, D3DDECLTYPE_FLOAT1
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
484 {1, 0, D3DDECLTYPE_FLOAT2
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
485 {2, 0, D3DDECLTYPE_FLOAT3
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
486 {3, 0, D3DDECLTYPE_FLOAT4
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
487 {4, 0, D3DDECLTYPE_D3DCOLOR
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
488 {5, 0, D3DDECLTYPE_UBYTE4
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
489 {6, 0, D3DDECLTYPE_SHORT2
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
490 {7, 0, D3DDECLTYPE_SHORT4
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
491 {8, 0, D3DDECLTYPE_UBYTE4N
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
492 {9, 0, D3DDECLTYPE_SHORT2N
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
493 {10, 0, D3DDECLTYPE_SHORT4N
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
494 {11, 0, D3DDECLTYPE_UDEC3
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
495 {12, 0, D3DDECLTYPE_DEC3N
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
496 {13, 0, D3DDECLTYPE_FLOAT16_2
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
497 {14, 0, D3DDECLTYPE_FLOAT16_4
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
500 static const D3DVERTEXELEMENT9 declaration2
[] =
502 {0, 8, D3DDECLTYPE_FLOAT1
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
503 {1, 8, D3DDECLTYPE_FLOAT2
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
504 {2, 8, D3DDECLTYPE_FLOAT3
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
505 {3, 8, D3DDECLTYPE_FLOAT4
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
506 {4, 8, D3DDECLTYPE_D3DCOLOR
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
507 {5, 8, D3DDECLTYPE_UBYTE4
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
508 {6, 8, D3DDECLTYPE_SHORT2
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
509 {7, 8, D3DDECLTYPE_SHORT4
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
510 {0, 8, D3DDECLTYPE_UBYTE4N
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
511 {1, 8, D3DDECLTYPE_SHORT2N
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
512 {2, 8, D3DDECLTYPE_SHORT4N
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
513 {3, 8, D3DDECLTYPE_UDEC3
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
514 {4, 8, D3DDECLTYPE_DEC3N
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
515 {5, 8, D3DDECLTYPE_FLOAT16_2
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
516 {6, 8, D3DDECLTYPE_FLOAT16_4
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
517 {7, 8, D3DDECLTYPE_FLOAT1
, D3DDECLMETHOD_DEFAULT
, D3DDECLUSAGE_POSITION
, 0},
520 static const UINT sizes1
[] =
527 static const UINT sizes2
[] =
535 size
= D3DXGetDeclVertexSize(NULL
, 0);
536 ok(size
== 0, "Got size %#x, expected 0.\n", size
);
538 for (i
= 0; i
< 16; ++i
)
540 size
= D3DXGetDeclVertexSize(declaration1
, i
);
541 ok(size
== sizes1
[i
], "Got size %u for stream %u, expected %u.\n", size
, i
, sizes1
[i
]);
544 for (i
= 0; i
< 8; ++i
)
546 size
= D3DXGetDeclVertexSize(declaration2
, i
);
547 ok(size
== sizes2
[i
], "Got size %u for stream %u, expected %u.\n", size
, i
, sizes2
[i
]);
553 D3DXBoundProbeTest();
554 D3DXComputeBoundingBoxTest();
555 D3DXComputeBoundingSphereTest();
556 D3DXDeclaratorFromFVFTest();
557 D3DXGetFVFVertexSizeTest();
558 D3DXIntersectTriTest();
559 test_get_decl_vertex_size();