1 | #ifndef VIEW_H |
1 | #ifndef VIEW_H |
2 | #define VIEW_H |
2 | #define VIEW_H |
3 | |
3 | |
4 | #include <set> |
4 | #include <set> |
|
|
5 | #include <map> |
5 | |
6 | |
6 | using namespace std; |
7 | using namespace std; |
7 | |
8 | |
8 | #include "util.h" |
9 | #include "util.h" |
9 | |
10 | |
… | |
… | |
15 | int w, h; |
16 | int w, h; |
16 | |
17 | |
17 | void draw (draw_context &ctx); |
18 | void draw (draw_context &ctx); |
18 | }; |
19 | }; |
19 | |
20 | |
|
|
21 | struct visibility_state { |
|
|
22 | unsigned int generation; |
|
|
23 | enum { OCCLUDED, VISIBLE } visibility; |
|
|
24 | |
|
|
25 | visibility_state () : generation(0), visibility(OCCLUDED) { }; |
|
|
26 | }; |
|
|
27 | |
20 | struct draw_context { |
28 | struct draw_context { |
21 | gl_matrix projection; |
29 | gl_matrix projection; |
22 | view &v; |
30 | view &v; |
23 | enum { DEPTH, LIGHTED } mode; |
31 | enum { DEPTH, LIGHTED } mode; |
24 | light *l; |
32 | light *l; |
25 | set<entity_base *> drawn; |
33 | set<entity_base *> drawn; |
|
|
34 | |
|
|
35 | unsigned int generation; |
|
|
36 | map<octant *, visibility_state> vismap; |
26 | |
37 | |
27 | bool may_draw (entity_base *e); |
38 | bool may_draw (entity_base *e); |
28 | |
39 | |
29 | draw_context (view &v); |
40 | draw_context (view &v); |
30 | ~draw_context (); |
41 | ~draw_context (); |