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

Comparing libgender/view.h (file contents):
Revision 1.26 by root, Sun Oct 17 09:43:07 2004 UTC vs.
Revision 1.37 by root, Fri Nov 26 02:38:17 2004 UTC

7 7
8using namespace std; 8using namespace std;
9 9
10#include "util.h" 10#include "util.h"
11#include "event.h" 11#include "event.h"
12#include "shader.h"
12 13
13struct visibility_base 14struct visibility_base
14{ 15{
15 unsigned int generation; // freshness check 16 unsigned int generation; // freshness check
16}; 17};
30 occ_query (view &ctx, void *id, GLuint count) : ctx(ctx), id(id), count(count) { }; 31 occ_query (view &ctx, void *id, GLuint count) : ctx(ctx), id(id), count(count) { };
31}; 32};
32 33
33typedef event_receiver<void, occ_query> recv_occ_query; 34typedef event_receiver<void, occ_query> recv_occ_query;
34 35
36enum pass_type {
37 DEPTH, // mandatory, render depth only
38 POSTDEPTH, // mandatory, occ tests or ignored
39 LIGHTED, // optional, render faces in full glory
40};
41
42struct pass_data
43{
44 pass_type type;
45
46 struct light *l;
47
48 typedef map<struct material *, shader::program_object> matmap_t;
49 matmap_t matmap;
50
51 pass_data (light *l, pass_type type = LIGHTED) : l(l), type(type) { }
52};
53
54extern pass_data pass_depth; // the standard depth pass
55extern pass_data pass_postdepth; // the standard post-depth pass
56
35struct view 57struct view
36{ 58{
37 sector orig; 59 sector orig;
38 point p; 60 point p;
39 vec3 d, u; 61 vec3 d, u;
40 GLfloat fov; 62 GLfloat fov;
41 GLfloat z_near, z_far, c_far; 63 GLfloat z_near, z_far, c_far;
42 int w, h; 64 int w, h;
43 GLfloat pixfact; // how many pixels on screen are drawn by a unit length line, *roughly* 65 GLfloat pixfact; // how many pixels on screen are drawn by a unit length line, *roughly*
66 sector eorig; // orig of currently-rendered entity in relation to the camera
44 67
45 GLfloat gamma; 68 GLfloat gamma;
46 69
47 // only to be used by friends: TODO 70 // only to be used by friends: TODO
48 71
49 GLfloat nz_far, nc_far; 72 GLfloat nz_far, nz_near, nc_far;
50 GLfloat diagfact; // bounding box border to depth factor 73 GLfloat diagfact; // bounding box border to depth factor
51 GLfloat perspfact; // perspfact * (1/depth)=> pixels 74 GLfloat perspfact; // perspfact * (1/depth)=> pixels
52 75
53 gl::matrix projection; 76 gl::matrix projection;
54 77
55 struct { 78 struct {
56 plane l, r, t, b, n, f; 79 plane l, r, t, b, n, f;
80 cone c;
81 sphere s;
57 } frustum; 82 } frustum;
58 83
59 // the passes 84 pass_data *pass;
60 enum pass { 85 bool first_lighted; // first lighted 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 86
66 struct light *l;
67 set<const entity *> drawn; // TODO: put drawn info and octant+entity visibility info into vismap! 87 set<const entity *> drawn; // TODO: put drawn info and octant+entity visibility info into vismap!
68 88
69 unsigned int generation; 89 unsigned int generation;
70 typedef map<visible *, visibility_base *> visibility_map; 90 typedef map<visible *, visibility_base *> visibility_map;
71 visibility_map vismap; 91 visibility_map vismap;
72 92
73 vector<octant *> vislist; // octants that want to be drawn 93 vector<octant *> vislist; // octants that want to be drawn
94 vector<octant *> postdepthlist; // octants that want to checked
74 95
75 struct oq_data { 96 struct oq_data {
76 recv_occ_query *recv; 97 recv_occ_query *recv;
77 GLint id; 98 GLint id;
78 void *data; 99 void *data;
86 void reset_projection (); 107 void reset_projection ();
87 108
88 // public 109 // public
89 110
90 void begin (); 111 void begin ();
91 void render (enum pass p); 112 void render (pass_data &pass);
92 void end (); 113 void end ();
93 114
94 bool may_draw (const entity *e); 115 bool may_draw (const entity *e);
95 116
96 view (); 117 view ();
97 ~view (); 118 ~view ();
119
120 int stat1; //D
121 int stat2; //D
122};
123
124struct light : view
125{
126 // the following variables are valid in the fragment shader as well as in the vertex shader
127 bool has_lightvec; // is a light vector available?
128 shader::temp_3f sh_lightvec; // not defined unless has_lightvec is true
129 shader::temp_3f sh_colour; // always available for any light
130
131 // vertex shader
132 virtual void vsh () = 0;
133 // fragment shader
134 virtual void fsh () = 0;
135
136 virtual void enable ();
137 virtual void disable ();
138
139protected:
140 shader::uniform_3f lightpos; // or direction
141};
142
143struct linear_light : light
144{
145 colour c;
146 GLfloat intensity;
147 GLfloat radius;
148
149 void vsh ();
150 void fsh ();
98}; 151};
99 152
100#endif 153#endif
101 154

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines