#ifndef VIEW_H #define VIEW_H #include #include using namespace std; #include "util.h" struct view { sector orig; point p; vec3 d, u; float fov; int w, h; void draw (draw_context &ctx); }; struct visibility_state { unsigned int generation; enum { UNKNOWN, OCCLUDED, PARTIAL, FULL } visibility; visibility_state () : generation(0), visibility(UNKNOWN) { }; }; struct draw_context { view &v; gl_matrix projection; struct { plane l, r, t, b, n, f; } frustum; enum { DEPTH, LIGHTED } mode; light *l; set drawn; unsigned int generation; map vismap; vector vislist; // octants partially or fully visible vector checklist; // octants possibly visible bool may_draw (entity_base *e); draw_context (view &v); ~draw_context (); }; inline void update_matrix (const draw_context &ctx) { gl_matrix m1 = ctx.projection; gl_matrix m2; glGetFloatv (GL_MODELVIEW_MATRIX, (GLfloat *)&m2); m1 = m1 * m2; for (int i = 0; i < 4; i++) for (int j = 0; j < 4 ; j++) mvp[i][j] = m1(i,j); } #endif