Add more structure constructor tests.
[piglit/hramrach.git] / tests / glean / geomutil.h
blob34e735668398a0cabcbe150dcd1fc04683b6608e
1 // BEGIN_COPYRIGHT -*- glean -*-
2 //
3 // Copyright (C) 1999,2000 Allen Akin All Rights Reserved.
4 //
5 // Permission is hereby granted, free of charge, to any person
6 // obtaining a copy of this software and associated documentation
7 // files (the "Software"), to deal in the Software without
8 // restriction, including without limitation the rights to use,
9 // copy, modify, merge, publish, distribute, sublicense, and/or
10 // sell copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following
12 // conditions:
13 //
14 // The above copyright notice and this permission notice shall be
15 // included in all copies or substantial portions of the
16 // Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 // KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
21 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ALLEN AKIN BE
22 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 // AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 // OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 // DEALINGS IN THE SOFTWARE.
26 //
27 // END_COPYRIGHT
32 // geomutil.h: frequently-used geometric operations
34 #ifndef __geomutil_h__
35 #define __geomutil_h__
37 #include <vector>
39 namespace GLEAN {
41 class RandomDouble; // Forward reference.
43 class RandomMesh2D {
44 float* m;
45 int rowLength;
46 public:
47 RandomMesh2D(float minX, float maxX, int xPoints,
48 float minY, float maxY, int yPoints,
49 RandomDouble& rand);
50 ~RandomMesh2D();
51 inline float* operator() (int y, int x)
52 { return m + 2 * (y * rowLength + x); }
53 }; // RandomMesh2D
55 class SpiralStrip2D {
56 float* v;
57 public:
58 SpiralStrip2D(int nPoints, float minX, float maxX,
59 float minY, float maxY);
60 ~SpiralStrip2D();
61 inline float* operator() (int i)
62 { return v + 2 * i; }
63 }; // SpiralStrip2D
65 class SpiralTri2D {
66 float* v;
67 public:
68 SpiralTri2D(int nTris, float minX, float maxX,
69 float minY, float maxY);
70 ~SpiralTri2D();
71 inline float* operator() (int i)
72 { return v + 6 * i; }
73 }; // SpiralTri2D
75 class Sphere3D {
76 std::vector<float> vertices;
77 std::vector<float> normals;
78 int numVertices;
79 std::vector<unsigned int> indices;
80 int numIndices;
81 public:
82 Sphere3D(float radius, int slices, int stacks);
84 // This returns the vertices: 3 floats per vertex in a tightly packed array (no padding between vertices).
85 const float* getVertices() const;
86 int getNumVertices() const;
88 // This returns the normals; same data format as the vertices. And of course the number of normals is
89 // the same as the number of vertices.
90 const float* getNormals() const;
92 // This returns a series of vertices that form triangles from the vertices (the indices specify loose
93 // triangles, not tristrips or fans or whatnot. So each triplet of indices is an individual triangle.)
94 const unsigned int* getIndices() const;
95 int getNumIndices() const;
98 } // namespace GLEAN
100 #endif // __geomutil_h__