comctl32/tests: Destroy the window after the tests.
[wine] / dlls / d3dx8 / tests / mesh.c
1 /*
2  * Copyright 2008 David Adam
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include "d3dx8.h"
20
21 #include "wine/test.h"
22
23 static void D3DXBoundProbeTest(void)
24 {
25     BOOL result;
26     D3DXVECTOR3 bottom_point, center, top_point, raydirection, rayposition;
27     FLOAT radius;
28
29 /*____________Test the Box case___________________________*/
30     bottom_point.x = -3.0f; bottom_point.y = -2.0f; bottom_point.z = -1.0f;
31     top_point.x = 7.0f; top_point.y = 8.0f; top_point.z = 9.0f;
32
33     raydirection.x = -4.0f; raydirection.y = -5.0f; raydirection.z = -6.0f;
34     rayposition.x = 5.0f; rayposition.y = 5.0f; rayposition.z = 11.0f;
35     result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
36     ok(result == TRUE, "expected TRUE, received FALSE\n");
37
38     raydirection.x = 4.0f; raydirection.y = 5.0f; raydirection.z = 6.0f;
39     rayposition.x = 5.0f; rayposition.y = 5.0f; rayposition.z = 11.0f;
40     result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
41     ok(result == FALSE, "expected FALSE, received TRUE\n");
42
43     rayposition.x = -4.0f; rayposition.y = 1.0f; rayposition.z = -2.0f;
44     result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
45     ok(result == TRUE, "expected TRUE, received FALSE\n");
46
47     bottom_point.x = 1.0f; bottom_point.y = 0.0f; bottom_point.z = 0.0f;
48     top_point.x = 1.0f; top_point.y = 0.0f; top_point.z = 0.0f;
49     rayposition.x = 0.0f; rayposition.y = 1.0f; rayposition.z = 0.0f;
50     raydirection.x = 0.0f; raydirection.y = 3.0f; raydirection.z = 0.0f;
51     result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
52     ok(result == FALSE, "expected FALSE, received TRUE\n");
53
54     bottom_point.x = 1.0f; bottom_point.y = 2.0f; bottom_point.z = 3.0f;
55     top_point.x = 10.0f; top_point.y = 15.0f; top_point.z = 20.0f;
56
57     raydirection.x = 7.0f; raydirection.y = 8.0f; raydirection.z = 9.0f;
58     rayposition.x = 3.0f; rayposition.y = 7.0f; rayposition.z = -6.0f;
59     result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
60     ok(result == TRUE, "expected TRUE, received FALSE\n");
61
62     bottom_point.x = 0.0f; bottom_point.y = 0.0f; bottom_point.z = 0.0f;
63     top_point.x = 1.0f; top_point.y = 1.0f; top_point.z = 1.0f;
64
65     raydirection.x = 0.0f; raydirection.y = 1.0f; raydirection.z = .0f;
66     rayposition.x = -3.0f; rayposition.y = 0.0f; rayposition.z = 0.0f;
67     result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
68     ok(result == FALSE, "expected FALSE, received TRUE\n");
69
70     raydirection.x = 1.0f; raydirection.y = 0.0f; raydirection.z = .0f;
71     rayposition.x = -3.0f; rayposition.y = 0.0f; rayposition.z = 0.0f;
72     result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
73     ok(result == TRUE, "expected TRUE, received FALSE\n");
74
75 /*____________Test the Sphere case________________________*/
76     radius = sqrt(77.0f);
77     center.x = 1.0f; center.y = 2.0f; center.z = 3.0f;
78     raydirection.x = 2.0f; raydirection.y = -4.0f; raydirection.z = 2.0f;
79
80     rayposition.x = 5.0f; rayposition.y = 5.0f; rayposition.z = 9.0f;
81     result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
82     ok(result == TRUE, "expected TRUE, received FALSE\n");
83
84     rayposition.x = 45.0f; rayposition.y = -75.0f; rayposition.z = 49.0f;
85     result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
86     ok(result == FALSE, "expected FALSE, received TRUE\n");
87
88     rayposition.x = 5.0f; rayposition.y = 7.0f; rayposition.z = 9.0f;
89     result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
90     ok(result == FALSE, "expected FALSE, received TRUE\n");
91
92     rayposition.x = 5.0f; rayposition.y = 11.0f; rayposition.z = 9.0f;
93     result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
94     ok(result == FALSE, "expected FALSE, received TRUE\n");
95 }
96
97 START_TEST(mesh)
98 {
99     D3DXBoundProbeTest();
100 }