ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/util.h
Revision: 1.1
Committed: Sun Oct 3 02:38:33 2004 UTC (19 years, 8 months ago) by root
Content type: text/plain
Branch: MAIN
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #ifndef UTIL_H
2     #define UTIL_H
3    
4     #include <GL/gl.h>
5    
6     #include <vector>
7    
8     using namespace std;
9    
10     typedef unsigned int soffs; // 32 bit
11     #define SOFFS_MAXEXTENT (soffs)(1UL << 31)
12    
13     #define GLFLOAT_MAX 1e30
14     #define GLFLOAT_MIN -1e30
15    
16     struct sector {
17     soffs x, y, z;
18     };
19    
20     struct point {
21     GLfloat x, y, z;
22    
23     point () { };
24     point (GLfloat x, GLfloat y, GLfloat z) : x(x), y(y), z(z) { };
25     };
26    
27     struct colour {
28     GLfloat r, g, b;
29     colour (GLfloat r = 1., GLfloat g = 1., GLfloat b = 1.) : r(r), g(g), b(b) { };
30     };
31    
32     struct vec3 {
33     GLfloat x, y, z;
34     vec3 () { };
35     vec3 (GLfloat x, GLfloat y, GLfloat z) : x(x), y(y), z(z) { };
36    
37     const vec3 operator -() const
38     { return vec3 (-x, -y, -z); }
39     };
40    
41     const vec3 normalize (const vec3 &v);
42     const vec3 cross (const vec3 &a, const vec3 &b);
43     GLfloat dot (const vec3 &a, const vec3 &b);
44    
45     struct texc {
46     GLfloat s, t;
47     texc () { };
48     texc (GLfloat s, GLfloat t) : s(s), t(t) { };
49     };
50    
51     struct box {
52     point a, b;
53    
54     void reset ()
55     {
56     a = point (GLFLOAT_MAX, GLFLOAT_MAX, GLFLOAT_MAX);
57     b = point (GLFLOAT_MIN, GLFLOAT_MIN, GLFLOAT_MIN);
58     }
59    
60     void add (const box &o);
61     void add (const point &p);
62     };
63    
64     struct light {
65     point p;
66     colour c;
67     GLfloat intensity;
68     GLfloat radius;
69     };
70    
71     struct draw_context {
72     enum { DEPTH, LIGHTED } mode;
73     light *l;
74     };
75    
76     #endif
77