]> git.tdb.fi Git - libs/gl.git/blob - source/light.h
Rewrite light binding to match textures
[libs/gl.git] / source / light.h
1 #ifndef MSP_GL_LIGHT_H_
2 #define MSP_GL_LIGHT_H_
3
4 #include <vector>
5 #include "color.h"
6 #include "vector.h"
7
8 namespace Msp {
9 namespace GL {
10
11 class Light
12 {
13 private:
14         Color diffuse;
15         Color specular;
16         Vector4 position;
17         Vector3 spot_dir;
18         float spot_exp;
19         float spot_cutoff;
20         float attenuation[3];
21
22 public:
23         Light();
24
25         void set_diffuse(const Color &c);
26         void set_specular(const Color &c);
27         const Color &get_diffuse() const { return diffuse; }
28         const Color &get_specular() const { return specular; }
29
30         void set_position(const Vector4 &);
31         const Vector4 &get_position() const { return position; }
32         void set_spot_direction(const Vector3 &);
33         void set_spot_exponent(float);
34         void set_spot_cutoff(float);
35         const Vector3 &get_spot_direction() const { return spot_dir; }
36         float get_spot_exponent() const { return spot_exp; }
37         float get_spot_cutoff() const { return spot_cutoff; }
38         void set_attenuation(float, float, float);
39         const float *get_attenuation() const { return attenuation; }
40
41         void bind() const { return bind_to(0); }
42         void bind_to(unsigned) const;
43
44         static const Light *current(unsigned = 0);
45         static void unbind() { return unbind_from(0); }
46         static void unbind_from(unsigned);
47 };
48
49 } // namespace GL
50 } // namespace Msp
51
52 #endif