ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/view.h
(Generate patch)

Comparing libgender/view.h (file contents):
Revision 1.11 by root, Wed Oct 6 00:27:01 2004 UTC vs.
Revision 1.26 by root, Sun Oct 17 09:43:07 2004 UTC

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#include <map>
6#include <utility>
6 7
7using namespace std; 8using namespace std;
8 9
9#include "util.h" 10#include "util.h"
11#include "event.h"
10 12
13struct visibility_base
14{
15 unsigned int generation; // freshness check
16};
17
18struct 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
24struct 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
33typedef event_receiver<void, occ_query> recv_occ_query;
34
11struct view { 35struct view
36{
12 sector orig; 37 sector orig;
13 point p; 38 point p;
14 vec3 d, u; 39 vec3 d, u;
15 float fov; 40 GLfloat fov;
41 GLfloat z_near, z_far, c_far;
16 int w, h; 42 int w, h;
43 GLfloat pixfact; // how many pixels on screen are drawn by a unit length line, *roughly*
17 44
18 void draw (draw_context &ctx); 45 GLfloat gamma;
19};
20 46
21struct visibility_state { 47 // only to be used by friends: TODO
22 unsigned int generation;
23 enum { UNKNOWN, OCCLUDED, PARTIAL, FULL } visibility;
24 48
25 visibility_state () : generation(0), visibility(UNKNOWN) { }; 49 GLfloat nz_far, nc_far;
26}; 50 GLfloat diagfact; // bounding box border to depth factor
51 GLfloat perspfact; // perspfact * (1/depth)=> pixels
27 52
28struct draw_context {
29 view &v;
30
31 matrix projection; 53 gl::matrix projection;
32
33 void transform (const matrix &m);
34 54
35 struct { 55 struct {
36 plane l, r, t, b, n, f; 56 plane l, r, t, b, n, f;
37 } frustum; 57 } frustum;
38 enum { DEPTH, LIGHTED } mode; 58
59 // the passes
60 enum pass {
61 DEPTH, // mandatory, render depth only
62 POSTDEPTH, // mandatory, occ tests or ignored
63 LIGHTED, // optional, render faces in full glory
64 } pass;
65
39 light *l; 66 struct light *l;
40 set<entity_base *> drawn; 67 set<const entity *> drawn; // TODO: put drawn info and octant+entity visibility info into vismap!
41 68
42 unsigned int generation; 69 unsigned int generation;
43 map<octant *, visibility_state> vismap; 70 typedef map<visible *, visibility_base *> visibility_map;
44 vector<octant *> vislist; // octants partially or fully visible 71 visibility_map vismap;
45 vector<octant *> checklist; // octants possibly visible
46 72
47 bool may_draw (entity_base *e); 73 vector<octant *> vislist; // octants that want to be drawn
48 74
49 draw_context (view &v); 75 struct oq_data {
50 ~draw_context (); 76 recv_occ_query *recv;
77 GLint id;
78 void *data;
79
80 oq_data (recv_occ_query *recv, GLint id, void *data) : recv(recv), id(id), data(data) { };
81 };
82 vector<oq_data> occ_queries;
83 void begin_occ_query (recv_occ_query &recv, void *id = 0);
84 void end_occ_query ();
85
86 void reset_projection ();
87
88 // public
89
90 void begin ();
91 void render (enum pass p);
92 void end ();
93
94 bool may_draw (const entity *e);
95
96 view ();
97 ~view ();
51}; 98};
52 99
53#endif 100#endif
54 101

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines