dungeon_crawler
annotate prototype/src/light.h @ 27:cbf86e5198a9
fized the vbo state creep
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 25 Aug 2012 14:37:51 +0300 |
parents | 0588f8a1a351 |
children | 862461b686f4 |
rev | line source |
---|---|
nuclear@4 | 1 #ifndef LIGHT_H_ |
nuclear@4 | 2 #define LIGHT_H_ |
nuclear@4 | 3 |
nuclear@4 | 4 #include "color.h" |
nuclear@4 | 5 |
nuclear@4 | 6 class Light { |
nuclear@4 | 7 protected: |
nuclear@4 | 8 float intensity; |
nuclear@4 | 9 Color color; |
nuclear@4 | 10 |
nuclear@23 | 11 // VBO for rendering the light source |
nuclear@23 | 12 unsigned int vbo; |
nuclear@23 | 13 unsigned int num_faces; |
nuclear@23 | 14 |
nuclear@23 | 15 virtual bool create_mesh(); |
nuclear@23 | 16 |
nuclear@4 | 17 public: |
nuclear@4 | 18 Light(const Color &col = 1.0); |
nuclear@4 | 19 virtual ~Light(); |
nuclear@4 | 20 |
nuclear@4 | 21 virtual void set_intensity(float val); |
nuclear@4 | 22 virtual void set_color(const Color &col); |
nuclear@4 | 23 |
nuclear@21 | 24 virtual Color get_color(bool with_intensity = true) const; |
nuclear@21 | 25 |
nuclear@4 | 26 virtual void use(int id = 0) const; |
nuclear@23 | 27 |
nuclear@23 | 28 virtual void draw() const; |
nuclear@4 | 29 }; |
nuclear@4 | 30 |
nuclear@4 | 31 class PointLight : public Light { |
nuclear@4 | 32 protected: |
nuclear@4 | 33 Vector3 pos; |
nuclear@4 | 34 float atten[3]; |
nuclear@21 | 35 float radius; |
nuclear@4 | 36 |
nuclear@23 | 37 bool create_mesh(); |
nuclear@23 | 38 |
nuclear@4 | 39 public: |
nuclear@4 | 40 PointLight(); |
nuclear@4 | 41 PointLight(const Vector3 &pos, const Color &col = 1.0); |
nuclear@4 | 42 |
nuclear@4 | 43 void set_position(const Vector3 &pos); |
nuclear@4 | 44 void set_attenuation(float att_const, float att_lin, float att_quad); |
nuclear@4 | 45 |
nuclear@21 | 46 void set_radius(float rad); |
nuclear@21 | 47 float get_radius() const; |
nuclear@21 | 48 |
nuclear@4 | 49 virtual void use(int id = 0) const; |
nuclear@23 | 50 |
nuclear@23 | 51 virtual void draw() const; |
nuclear@4 | 52 }; |
nuclear@4 | 53 |
nuclear@4 | 54 class DirLight : public Light { |
nuclear@4 | 55 protected: |
nuclear@4 | 56 Vector3 dir; |
nuclear@4 | 57 |
nuclear@23 | 58 bool create_mesh(); |
nuclear@23 | 59 |
nuclear@4 | 60 public: |
nuclear@4 | 61 DirLight(); |
nuclear@4 | 62 DirLight(const Vector3 &dir, const Color &col = 1.0); |
nuclear@4 | 63 |
nuclear@4 | 64 void set_direction(const Vector3 &dir); |
nuclear@4 | 65 |
nuclear@4 | 66 virtual void use(int id = 0) const; |
nuclear@4 | 67 }; |
nuclear@4 | 68 |
nuclear@4 | 69 |
nuclear@4 | 70 void set_light(int id, const Light *lt); |
nuclear@4 | 71 |
nuclear@4 | 72 |
nuclear@4 | 73 #endif // LIGHT_H_ |