dungeon_crawler

view prototype/src/light.h @ 79:110b2af4b9d8

fixed the shader non-conformity by explicitly converting 2.2 to vec3 before passing it to pow for the texel inverse-gamma thing
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 27 Oct 2012 01:54:39 +0300
parents aa86119e3295
children
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;
40 static int subdiv;
42 bool create_mesh();
44 public:
45 PointLight();
46 PointLight(const Vector3 &pos, const Color &col = 1.0);
48 void set_position(const Vector3 &pos);
49 const Vector3 &get_position() const;
51 void set_attenuation(float att_const, float att_lin, float att_quad);
53 void set_radius(float rad);
54 float get_radius() const;
56 virtual void use(int id = 0) const;
58 virtual void draw() const;
59 };
61 class DirLight : public Light {
62 protected:
63 Vector3 dir;
65 bool create_mesh();
67 public:
68 DirLight();
69 DirLight(const Vector3 &dir, const Color &col = 1.0);
71 void set_direction(const Vector3 &dir);
72 const Vector3 &get_direction() const;
74 virtual void use(int id = 0) const;
75 };
78 void set_light(int id, const Light *lt);
81 #endif // LIGHT_H_