dungeon_crawler
view prototype/src/light.h @ 53:1ea56011c1ff
stuff + streaming start
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 19 Sep 2012 01:08:41 +0300 |
parents | 862461b686f4 |
children | aa86119e3295 |
line source
1 #ifndef LIGHT_H_
2 #define LIGHT_H_
4 #include "color.h"
6 class Light {
7 protected:
8 float intensity;
9 Color color;
11 float flicker_offset;
13 // VBO for rendering the light source
14 unsigned int vbo;
15 unsigned int num_faces;
17 virtual bool create_mesh();
19 public:
20 Light(const Color &col = 1.0);
21 virtual ~Light();
23 virtual void set_intensity(float val);
24 virtual void set_color(const Color &col);
26 virtual Color get_color(bool with_intensity = true) const;
28 virtual void use(int id = 0) const;
30 virtual void draw() const;
31 };
33 class PointLight : public Light {
34 protected:
35 Vector3 pos;
36 float atten[3];
37 float radius;
39 bool create_mesh();
41 public:
42 PointLight();
43 PointLight(const Vector3 &pos, const Color &col = 1.0);
45 void set_position(const Vector3 &pos);
46 const Vector3 &get_position() const;
48 void set_attenuation(float att_const, float att_lin, float att_quad);
50 void set_radius(float rad);
51 float get_radius() const;
53 virtual void use(int id = 0) const;
55 virtual void draw() const;
56 };
58 class DirLight : public Light {
59 protected:
60 Vector3 dir;
62 bool create_mesh();
64 public:
65 DirLight();
66 DirLight(const Vector3 &dir, const Color &col = 1.0);
68 void set_direction(const Vector3 &dir);
69 const Vector3 &get_direction() const;
71 virtual void use(int id = 0) const;
72 };
75 void set_light(int id, const Light *lt);
78 #endif // LIGHT_H_