--- libgender/view.h 2004/10/09 22:43:31 1.18 +++ libgender/view.h 2004/10/17 09:43:07 1.26 @@ -10,58 +10,77 @@ #include "util.h" #include "event.h" -struct visibility_state { - unsigned int generation; - enum { UNKNOWN, OCCLUDED, PARTIAL, FULL } visibility; - double last; +struct visibility_base +{ + unsigned int generation; // freshness check +}; - visibility_state () : generation(0), last(0.), visibility(UNKNOWN) { }; +struct visible { + visibility_base *get_visibility (view &ctx); + virtual visibility_base *new_visibility () = 0; + virtual void clear_visibility (visibility_base *vs) = 0; }; -struct occ_query { - struct view &v; - GLuint id; - GLuint r; +struct occ_query +{ + struct view &ctx; + void *id; + GLuint count; - occ_query (view &v, GLuint id, GLuint r) : v(v), id(id), r(r) { }; + occ_query (view &ctx, void *id, GLuint count) : ctx(ctx), id(id), count(count) { }; }; typedef event_receiver recv_occ_query; -struct view { +struct view +{ sector orig; point p; vec3 d, u; GLfloat fov; - GLfloat near, far; + GLfloat z_near, z_far, c_far; int w, h; + GLfloat pixfact; // how many pixels on screen are drawn by a unit length line, *roughly* GLfloat gamma; // only to be used by friends: TODO - GLfloat nextfar; + GLfloat nz_far, nc_far; GLfloat diagfact; // bounding box border to depth factor + GLfloat perspfact; // perspfact * (1/depth)=> pixels - matrix projection; + gl::matrix projection; struct { plane l, r, t, b, n, f; } frustum; - enum mode { DEPTH, LIGHTED } mode; - light *l; - set drawn; + // the passes + enum pass { + DEPTH, // mandatory, render depth only + POSTDEPTH, // mandatory, occ tests or ignored + LIGHTED, // optional, render faces in full glory + } pass; + + struct light *l; + set drawn; // TODO: put drawn info and octant+entity visibility info into vismap! unsigned int generation; - map vismap; + typedef map visibility_map; + visibility_map vismap; + + vector vislist; // octants that want to be drawn - vector vislist; // octants partially or fully visible in frustum - vector farlist; // octants possibly visible + struct oq_data { + recv_occ_query *recv; + GLint id; + void *data; - typedef pair oq_data; + oq_data (recv_occ_query *recv, GLint id, void *data) : recv(recv), id(id), data(data) { }; + }; vector occ_queries; - void begin_occ_query (recv_occ_query &recv); + void begin_occ_query (recv_occ_query &recv, void *id = 0); void end_occ_query (); void reset_projection (); @@ -69,7 +88,7 @@ // public void begin (); - void pass (enum mode m); + void render (enum pass p); void end (); bool may_draw (const entity *e);