--- libgender/view.h 2004/10/17 09:43:07 1.26 +++ libgender/view.h 2004/11/06 00:06:33 1.33 @@ -9,6 +9,7 @@ #include "util.h" #include "event.h" +#include "shader.h" struct visibility_base { @@ -32,6 +33,18 @@ typedef event_receiver recv_occ_query; +struct pass +{ + struct light *l; + + typedef map matmap_t; + matmap_t matmap; + + pass (light *l) : l(l) { } +}; + +extern pass pass_depth; // the standard depth pass + struct view { sector orig; @@ -41,12 +54,13 @@ 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* + sector eorig; // orig of currently-rendered entity in relation to the camera GLfloat gamma; // only to be used by friends: TODO - GLfloat nz_far, nc_far; + GLfloat nz_far, nz_near, nc_far; GLfloat diagfact; // bounding box border to depth factor GLfloat perspfact; // perspfact * (1/depth)=> pixels @@ -54,16 +68,19 @@ struct { plane l, r, t, b, n, f; + cone c; + sphere s; } frustum; // the passes - enum pass { + enum pass_type { DEPTH, // mandatory, render depth only POSTDEPTH, // mandatory, occ tests or ignored LIGHTED, // optional, render faces in full glory - } pass; + } pass_type; + + pass *pass_data; - struct light *l; set drawn; // TODO: put drawn info and octant+entity visibility info into vismap! unsigned int generation; @@ -88,7 +105,7 @@ // public void begin (); - void render (enum pass p); + void render (enum pass_type p, pass &data); void end (); bool may_draw (const entity *e); @@ -97,5 +114,34 @@ ~view (); }; +struct light : view +{ + // the following variables are valid in the fragment shader as well as in the vertex shader + bool has_lightvec; // is a light vector available? + shader::temp_3f sh_lightvec; // not defined unless has_lightvec is true + shader::temp_3f sh_colour; // always available for any light + + // vertex shader + virtual void vsh () = 0; + // fragment shader + virtual void fsh () = 0; + + virtual void enable (); + virtual void disable (); + +protected: + shader::uniform_3f lightpos; // or direction +}; + +struct linear_light : light +{ + colour c; + GLfloat intensity; + GLfloat radius; + + void vsh (); + void fsh (); +}; + #endif