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

Comparing libgender/view.C (file contents):
Revision 1.75 by root, Sun Nov 7 02:28:18 2004 UTC vs.
Revision 1.76 by root, Sun Nov 7 03:28:20 2004 UTC

2 2
3#include "opengl.h" 3#include "opengl.h"
4 4
5#include "view.h" 5#include "view.h"
6#include "oct.h" 6#include "oct.h"
7#include "material.h"
7 8
8using namespace gl; 9using namespace gl;
9 10
10pass pass_depth (0); 11pass_data pass_depth (0, DEPTH);
12pass_data pass_postdepth (0, POSTDEPTH);
11 13
12vector<GLuint> occ_query_objects; 14vector<GLuint> occ_query_objects;
13 15
14static GLuint begin_occ_query () 16static GLuint begin_occ_query ()
15{ 17{
57} 59}
58 60
59void view::end_occ_query () 61void view::end_occ_query ()
60{ 62{
61 ::end_occ_query (); 63 ::end_occ_query ();
64}
65
66struct occ_query_material : material
67{
68 void vsh (view &ctx);
69 void fsh (view &ctx);
70};
71
72static struct occ_query_material occ_query_material;
73
74void occ_query_material::vsh (view &ctx)
75{
76 std_vsh ();
77}
78
79void occ_query_material::fsh (view &ctx)
80{
81 // nop
62} 82}
63 83
64bool view::may_draw (const entity *e) 84bool view::may_draw (const entity *e)
65{ 85{
66 if (drawn.find (e) != drawn.end ()) 86 if (drawn.find (e) != drawn.end ())
203 vislist.clear (); 223 vislist.clear ();
204} 224}
205 225
206#define DEPTH_OFFSET (1. / (GLdouble)(1L << 16)) 226#define DEPTH_OFFSET (1. / (GLdouble)(1L << 16))
207 227
208void view::render (enum pass_type p, pass &data) 228void view::render (pass_data &pass)
209{ 229{
210 pass_type = p; 230 this->pass = &pass;
211 pass_data = &data;
212 231
213 switch (pass_type) 232 switch (pass.type)
214 { 233 {
215 case DEPTH: 234 case DEPTH:
216 glColorMask (1, 1, 1, 1); 235 glColorMask (1, 1, 1, 1);
217 glDepthMask (1); 236 glDepthMask (1);
218 glDisable (GL_BLEND); 237 glDisable (GL_BLEND);
245 glDepthMask (0); 264 glDepthMask (0);
246 glEnable (GL_DEPTH_CLAMP_NV); 265 glEnable (GL_DEPTH_CLAMP_NV);
247 glDisable (GL_STENCIL_TEST); 266 glDisable (GL_STENCIL_TEST);
248 glDisable (GL_CULL_FACE); 267 glDisable (GL_CULL_FACE);
249 268
269 occ_query_material.enable (*this);
270
250 // check occlusion queries 271 // check occlusion queries
251 for (vector<oq_data>::iterator i = occ_queries.begin (); i != occ_queries.end (); ++i) 272 for (vector<oq_data>::iterator i = occ_queries.begin (); i != occ_queries.end (); ++i)
252 { 273 {
253 occ_query oq(*this, i->data, ::occ_query_result (i->id)); 274 occ_query oq(*this, i->data, ::occ_query_result (i->id));
254 i->recv->event (oq); 275 i->recv->event (oq);
255 } 276 }
277
278 occ_query_material.disable (*this);
256 279
257 occ_queries.clear (); 280 occ_queries.clear ();
258 281
259 break; 282 break;
260 283
275 } 298 }
276 299
277 for (vector<octant *>::iterator i = vislist.begin (); i != vislist.end (); ++i) 300 for (vector<octant *>::iterator i = vislist.begin (); i != vislist.end (); ++i)
278 (*i)->display (*this); 301 (*i)->display (*this);
279 302
280 if (pass_type == DEPTH) 303 if (pass.type == DEPTH)
281 printf ("fps %f NF %f:%f vis %d CAM (%d,%d,%d)\n", timer.fps, z_near, z_far, drawn.size (), orig.x, orig.y, orig.z);//D 304 printf ("fps %f NF %f:%f vis %d CAM (%d,%d,%d)\n", timer.fps, z_near, z_far, drawn.size (), orig.x, orig.y, orig.z);//D
282 305
283 drawn.clear (); 306 drawn.clear ();
284 307
285#if 0 308#if 0

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines