… | |
… | |
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 | |
8 | using namespace gl; |
9 | using namespace gl; |
9 | |
10 | |
10 | pass pass_depth (0); |
11 | pass_data pass_depth (0, DEPTH); |
|
|
12 | pass_data pass_postdepth (0, POSTDEPTH); |
11 | |
13 | |
12 | vector<GLuint> occ_query_objects; |
14 | vector<GLuint> occ_query_objects; |
13 | |
15 | |
14 | static GLuint begin_occ_query () |
16 | static GLuint begin_occ_query () |
15 | { |
17 | { |
… | |
… | |
57 | } |
59 | } |
58 | |
60 | |
59 | void view::end_occ_query () |
61 | void view::end_occ_query () |
60 | { |
62 | { |
61 | ::end_occ_query (); |
63 | ::end_occ_query (); |
|
|
64 | } |
|
|
65 | |
|
|
66 | struct occ_query_material : material |
|
|
67 | { |
|
|
68 | void vsh (view &ctx); |
|
|
69 | void fsh (view &ctx); |
|
|
70 | }; |
|
|
71 | |
|
|
72 | static struct occ_query_material occ_query_material; |
|
|
73 | |
|
|
74 | void occ_query_material::vsh (view &ctx) |
|
|
75 | { |
|
|
76 | std_vsh (); |
|
|
77 | } |
|
|
78 | |
|
|
79 | void occ_query_material::fsh (view &ctx) |
|
|
80 | { |
|
|
81 | // nop |
62 | } |
82 | } |
63 | |
83 | |
64 | bool view::may_draw (const entity *e) |
84 | bool 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 | |
208 | void view::render (enum pass_type p, pass &data) |
228 | void 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 |