dungeon_crawler

view prototype/src/light.h @ 60:aa86119e3295

added multipass deferred
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 25 Sep 2012 06:19:37 +0300
parents f3030df27110
children d89b403f630b
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 static unsigned int sph_vbo;
41 bool create_mesh();
43 public:
44 PointLight();
45 PointLight(const Vector3 &pos, const Color &col = 1.0);
47 void set_position(const Vector3 &pos);
48 const Vector3 &get_position() const;
50 void set_attenuation(float att_const, float att_lin, float att_quad);
52 void set_radius(float rad);
53 float get_radius() const;
55 virtual void use(int id = 0) const;
57 virtual void draw() const;
58 };
60 class DirLight : public Light {
61 protected:
62 Vector3 dir;
64 bool create_mesh();
66 public:
67 DirLight();
68 DirLight(const Vector3 &dir, const Color &col = 1.0);
70 void set_direction(const Vector3 &dir);
71 const Vector3 &get_direction() const;
73 virtual void use(int id = 0) const;
74 };
77 void set_light(int id, const Light *lt);
80 #endif // LIGHT_H_