--- libgender/entity.h 2004/10/03 02:38:33 1.5 +++ libgender/entity.h 2004/10/03 22:46:03 1.11 @@ -7,29 +7,31 @@ #include "util.h" #include "oct.h" +#include "view.h" using namespace std; struct entity_base { struct entity_base *parent; + sector orig; vector o; box bbox; virtual void update_bbox (); - virtual void show (const sector &sec) { }; + virtual void show () { world.add (this); }; void hide (); - virtual void draw (const draw_context &ctx) = 0; - virtual ~entity_base () - { - hide (); - }; + void display (draw_context &ctx); + virtual void draw (draw_context &ctx) = 0; + + entity_base (); + virtual ~entity_base (); }; struct entity_container : entity_base, protected vector { void add (entity_base *e) { push_back (e); e->parent = this; } void update_bbox (); - void show (const sector &sec); - void draw (const draw_context &ctx); + void show (); + void draw (draw_context &ctx); ~entity_container (); }; @@ -53,21 +55,12 @@ entity_base *content () { return e; }; void update_bbox (); - void show (const sector &sec); - void draw (const draw_context &ctx); + void show (); + void draw (draw_context &ctx); ~entity_filter (); }; struct entity : entity_filter { - sector sec; - - void show (const sector &sec); - void show (); - void draw (const draw_context &ctx); -}; - -struct entity_affine : entity_filter { - //matrix m; }; struct vertex1d { @@ -76,27 +69,41 @@ }; struct vertex2d { - colour c; // colour - point p; // vertex - vec3 n; // normal - texc t; // texture + point p; // vertex + vec3 n; // normal + texc t; // texture vertex2d () { }; - vertex2d (colour c, point p, vec3 n, texc t = texc()) : c(c), p(p), n(n), t(t) { }; + vertex2d (point p, vec3 n, texc t = texc()) : p(p), n(n), t(t) { }; +}; + +struct entity_opengl : entity_base { }; template -struct entity_opengl1d : entity_base, vector { +struct entity_opengl1d : entity_opengl, vector { void update_bbox (); - void show (const sector &sec); - void draw (const draw_context &ctx); + void draw (draw_context &ctx); }; template -struct entity_opengl2d : entity_base, vector { +struct entity_opengl2d : entity_opengl, vector { + material m; + GLuint list; + void update_bbox (); - void show (const sector &sec); - void draw (const draw_context &ctx); + void draw (draw_context &ctx); + + entity_opengl2d () + : list(0) + { + } + + ~entity_opengl2d () + { + if (list) + glDeleteLists (list, 1); + } }; typedef entity_opengl1d entity_points; @@ -110,13 +117,14 @@ typedef entity_opengl2d entity_quad_strip; typedef entity_opengl2d entity_polygon; -struct view { - point p; - vec3 d, u; - float fov; - int w, h; +struct entity_transform : entity_filter { + gl_matrix m; + + entity_transform (); - void draw (const draw_context &ctx); + void update_bbox (); + void show (); + void draw (draw_context &ctx); }; #endif