1 |
root |
1.1 |
#ifndef VIEW_H |
2 |
|
|
#define VIEW_H |
3 |
|
|
|
4 |
|
|
#include <set> |
5 |
root |
1.4 |
#include <map> |
6 |
root |
1.17 |
#include <utility> |
7 |
root |
1.1 |
|
8 |
|
|
using namespace std; |
9 |
|
|
|
10 |
|
|
#include "util.h" |
11 |
root |
1.17 |
#include "event.h" |
12 |
root |
1.1 |
|
13 |
root |
1.12 |
struct visibility_state { |
14 |
|
|
unsigned int generation; |
15 |
|
|
enum { UNKNOWN, OCCLUDED, PARTIAL, FULL } visibility; |
16 |
|
|
|
17 |
|
|
visibility_state () : generation(0), visibility(UNKNOWN) { }; |
18 |
|
|
}; |
19 |
|
|
|
20 |
root |
1.17 |
struct occ_query { |
21 |
|
|
struct view &v; |
22 |
|
|
GLuint id; |
23 |
|
|
GLuint r; |
24 |
|
|
|
25 |
|
|
occ_query (view &v, GLuint id, GLuint r) : v(v), id(id), r(r) { }; |
26 |
|
|
}; |
27 |
|
|
|
28 |
|
|
typedef event_receiver<void, occ_query> recv_occ_query; |
29 |
|
|
|
30 |
root |
1.2 |
struct view { |
31 |
|
|
sector orig; |
32 |
|
|
point p; |
33 |
|
|
vec3 d, u; |
34 |
root |
1.13 |
GLfloat fov; |
35 |
|
|
GLfloat near, far; |
36 |
root |
1.2 |
int w, h; |
37 |
|
|
|
38 |
root |
1.13 |
GLfloat gamma; |
39 |
root |
1.4 |
|
40 |
root |
1.17 |
// only to be used by friends: TODO |
41 |
root |
1.5 |
|
42 |
root |
1.13 |
GLfloat nextfar; |
43 |
root |
1.17 |
GLfloat diagfact; // bounding box border to depth factor |
44 |
root |
1.13 |
|
45 |
root |
1.8 |
matrix projection; |
46 |
root |
1.9 |
|
47 |
root |
1.5 |
struct { |
48 |
|
|
plane l, r, t, b, n, f; |
49 |
|
|
} frustum; |
50 |
root |
1.14 |
|
51 |
root |
1.13 |
enum mode { DEPTH, LIGHTED } mode; |
52 |
root |
1.1 |
light *l; |
53 |
root |
1.15 |
set<const entity *> drawn; |
54 |
root |
1.4 |
|
55 |
|
|
unsigned int generation; |
56 |
|
|
map<octant *, visibility_state> vismap; |
57 |
root |
1.17 |
|
58 |
root |
1.16 |
vector<octant *> vislist; // octants partially or fully visible in frustum |
59 |
root |
1.14 |
vector<octant *> farlist; // octants possibly visible |
60 |
root |
1.17 |
|
61 |
|
|
typedef pair<recv_occ_query *, GLint> oq_data; |
62 |
|
|
vector<oq_data> occ_queries; |
63 |
|
|
void begin_occ_query (recv_occ_query &recv); |
64 |
|
|
void end_occ_query (); |
65 |
root |
1.13 |
|
66 |
|
|
void reset_projection (); |
67 |
|
|
|
68 |
|
|
// public |
69 |
|
|
|
70 |
|
|
void begin (); |
71 |
|
|
void pass (enum mode m); |
72 |
|
|
void end (); |
73 |
root |
1.1 |
|
74 |
root |
1.15 |
bool may_draw (const entity *e); |
75 |
root |
1.1 |
|
76 |
root |
1.12 |
view (); |
77 |
|
|
~view (); |
78 |
root |
1.1 |
}; |
79 |
root |
1.7 |
|
80 |
root |
1.1 |
#endif |
81 |
|
|
|