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