1 |
root |
1.1 |
#ifndef VIEW_H |
2 |
|
|
#define VIEW_H |
3 |
|
|
|
4 |
|
|
#include <set> |
5 |
root |
1.4 |
#include <map> |
6 |
root |
1.1 |
|
7 |
|
|
using namespace std; |
8 |
|
|
|
9 |
|
|
#include "util.h" |
10 |
|
|
|
11 |
root |
1.2 |
struct view { |
12 |
|
|
sector orig; |
13 |
|
|
point p; |
14 |
|
|
vec3 d, u; |
15 |
|
|
float fov; |
16 |
|
|
int w, h; |
17 |
|
|
|
18 |
|
|
void draw (draw_context &ctx); |
19 |
|
|
}; |
20 |
|
|
|
21 |
root |
1.4 |
struct visibility_state { |
22 |
|
|
unsigned int generation; |
23 |
root |
1.6 |
enum { UNKNOWN, OCCLUDED, PARTIAL, FULL } visibility; |
24 |
root |
1.4 |
|
25 |
root |
1.5 |
visibility_state () : generation(0), visibility(UNKNOWN) { }; |
26 |
root |
1.4 |
}; |
27 |
|
|
|
28 |
root |
1.1 |
struct draw_context { |
29 |
root |
1.5 |
view &v; |
30 |
|
|
|
31 |
root |
1.3 |
gl_matrix projection; |
32 |
root |
1.5 |
struct { |
33 |
|
|
plane l, r, t, b, n, f; |
34 |
|
|
} frustum; |
35 |
root |
1.1 |
enum { DEPTH, LIGHTED } mode; |
36 |
|
|
light *l; |
37 |
|
|
set<entity_base *> drawn; |
38 |
root |
1.4 |
|
39 |
|
|
unsigned int generation; |
40 |
|
|
map<octant *, visibility_state> vismap; |
41 |
root |
1.6 |
vector<octant *> vislist; // octants partially or fully visible |
42 |
|
|
vector<octant *> checklist; // octants possibly visible |
43 |
root |
1.1 |
|
44 |
|
|
bool may_draw (entity_base *e); |
45 |
|
|
|
46 |
root |
1.2 |
draw_context (view &v); |
47 |
root |
1.1 |
~draw_context (); |
48 |
|
|
}; |
49 |
|
|
|
50 |
root |
1.7 |
inline void update_matrix (const draw_context &ctx) |
51 |
|
|
{ |
52 |
|
|
gl_matrix m1 = ctx.projection; |
53 |
|
|
gl_matrix m2; |
54 |
|
|
|
55 |
|
|
glGetFloatv (GL_MODELVIEW_MATRIX, (GLfloat *)&m2); |
56 |
|
|
|
57 |
|
|
m1 = m1 * m2; |
58 |
|
|
|
59 |
|
|
for (int i = 0; i < 4; i++) |
60 |
|
|
for (int j = 0; j < 4 ; j++) |
61 |
|
|
mvp[i][j] = m1(i,j); |
62 |
|
|
} |
63 |
|
|
|
64 |
root |
1.1 |
#endif |
65 |
|
|
|