#ifndef VIEW_H #define VIEW_H #include #include #include using namespace std; #include "util.h" #include "event.h" struct visibility_base { unsigned int generation; // freshness check }; 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 &ctx; void *id; GLuint count; occ_query (view &ctx, void *id, GLuint count) : ctx(ctx), id(id), count(count) { }; }; typedef event_receiver recv_occ_query; struct view { sector orig; point p; vec3 d, u; GLfloat fov; 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 nz_far, nc_far; GLfloat diagfact; // bounding box border to depth factor GLfloat perspfact; // perspfact * (1/depth)=> pixels gl::matrix projection; struct { plane l, r, t, b, n, f; cone c; sphere s; } frustum; // 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; typedef map visibility_map; visibility_map vismap; vector vislist; // octants that want to be drawn struct oq_data { recv_occ_query *recv; GLint id; void *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 *id = 0); void end_occ_query (); void reset_projection (); // public void begin (); void render (enum pass p); void end (); bool may_draw (const entity *e); view (); ~view (); }; #endif