dungeon_crawler
view 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 |
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 // VBO for rendering the light source
12 unsigned int vbo;
13 unsigned int num_faces;
15 virtual bool create_mesh();
17 public:
18 Light(const Color &col = 1.0);
19 virtual ~Light();
21 virtual void set_intensity(float val);
22 virtual void set_color(const Color &col);
24 virtual Color get_color(bool with_intensity = true) const;
26 virtual void use(int id = 0) const;
28 virtual void draw() const;
29 };
31 class PointLight : public Light {
32 protected:
33 Vector3 pos;
34 float atten[3];
35 float radius;
37 bool create_mesh();
39 public:
40 PointLight();
41 PointLight(const Vector3 &pos, const Color &col = 1.0);
43 void set_position(const Vector3 &pos);
44 void set_attenuation(float att_const, float att_lin, float att_quad);
46 void set_radius(float rad);
47 float get_radius() const;
49 virtual void use(int id = 0) const;
51 virtual void draw() const;
52 };
54 class DirLight : public Light {
55 protected:
56 Vector3 dir;
58 bool create_mesh();
60 public:
61 DirLight();
62 DirLight(const Vector3 &dir, const Color &col = 1.0);
64 void set_direction(const Vector3 &dir);
66 virtual void use(int id = 0) const;
67 };
70 void set_light(int id, const Light *lt);
73 #endif // LIGHT_H_