ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/view.h
Revision: 1.29
Committed: Sat Oct 23 02:27:52 2004 UTC (19 years, 7 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.28: +0 -1 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 &ctx;
27 void *id;
28 GLuint count;
29
30 occ_query (view &ctx, void *id, GLuint count) : ctx(ctx), id(id), count(count) { };
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, nz_near, nc_far;
50 GLfloat diagfact; // bounding box border to depth factor
51 GLfloat perspfact; // perspfact * (1/depth)=> pixels
52
53 gl::matrix projection;
54
55 struct {
56 plane l, r, t, b, n, f;
57 cone c;
58 sphere s;
59 } frustum;
60
61 // the passes
62 enum pass {
63 DEPTH, // mandatory, render depth only
64 POSTDEPTH, // mandatory, occ tests or ignored
65 LIGHTED, // optional, render faces in full glory
66 } pass;
67
68 set<const entity *> drawn; // TODO: put drawn info and octant+entity visibility info into vismap!
69
70 unsigned int generation;
71 typedef map<visible *, visibility_base *> visibility_map;
72 visibility_map vismap;
73
74 vector<octant *> vislist; // octants that want to be drawn
75
76 struct oq_data {
77 recv_occ_query *recv;
78 GLint id;
79 void *data;
80
81 oq_data (recv_occ_query *recv, GLint id, void *data) : recv(recv), id(id), data(data) { };
82 };
83 vector<oq_data> occ_queries;
84 void begin_occ_query (recv_occ_query &recv, void *id = 0);
85 void end_occ_query ();
86
87 void reset_projection ();
88
89 // public
90
91 void begin ();
92 void render (enum pass p);
93 void end ();
94
95 bool may_draw (const entity *e);
96
97 view ();
98 ~view ();
99 };
100
101 #endif
102