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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines