ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/view.h
Revision: 1.22
Committed: Sat Oct 16 12:33:46 2004 UTC (19 years, 7 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.21: +19 -10 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 #ifndef VIEW_H
2 #define VIEW_H
3
4 #include <set>
5 #include <map>
6 #include <utility>
7
8 using namespace std;
9
10 #include "util.h"
11 #include "event.h"
12
13 struct visibility_base
14 {
15 unsigned int generation; // freshness check
16 };
17
18 struct visible {
19 visibility_base *get_visibility (view &ctx);
20 virtual visibility_base *new_visibility () = 0;
21 virtual void clear_visibility (visibility_base *vs) = 0;
22 };
23
24 struct occ_query
25 {
26 struct view &v;
27 void *id;
28 GLuint r;
29
30 occ_query (view &v, void *id, GLuint r) : v(v), id(id), r(r) { };
31 };
32
33 typedef event_receiver<void, occ_query> recv_occ_query;
34
35 struct view
36 {
37 sector orig;
38 point p;
39 vec3 d, u;
40 GLfloat fov;
41 GLfloat z_near, z_far, c_far;
42 int w, h;
43 GLfloat pixfact; // how many pixels on screen are drawn by a unit length line, *roughly*
44
45 GLfloat gamma;
46
47 // only to be used by friends: TODO
48
49 GLfloat nz_far, nc_far;
50 GLfloat diagfact; // bounding box border to depth factor
51 GLfloat perspfact; // perspfact * (1/depth)=> pixels
52
53 matrix projection;
54
55 struct {
56 plane l, r, t, b, n, f;
57 } frustum;
58
59 enum mode { DEPTH, LIGHTED } mode;
60 struct light *l;
61 set<const entity *> drawn;
62
63 unsigned int generation;
64 typedef map<visible *, visibility_base *> visibility_map;
65 visibility_map vismap;
66
67 vector<octant *> vislist; // octants partially or fully visible in frustum
68 vector<octant *> farlist; // octants possibly visible
69
70 struct oq_data {
71 recv_occ_query *recv;
72 GLint id;
73 void *data;
74
75 oq_data (recv_occ_query *recv, GLint id, void *data) : recv(recv), id(id), data(data) { };
76 };
77 vector<oq_data> occ_queries;
78 void begin_occ_query (recv_occ_query &recv, void *id = 0);
79 void end_occ_query ();
80
81 void reset_projection ();
82
83 // public
84
85 void begin ();
86 void pass (enum mode m);
87 void end ();
88
89 bool may_draw (const entity *e);
90
91 view ();
92 ~view ();
93 };
94
95 #endif
96