]> git.tdb.fi Git - libs/gl.git/blob - source/light.h
Add Vector3 and Vector4 classes
[libs/gl.git] / source / light.h
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2007  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GL_LIGHT_H_
9 #define MSP_GL_LIGHT_H_
10
11 #include <vector>
12 #include "color.h"
13 #include "vector.h"
14
15 namespace Msp {
16 namespace GL {
17
18 class Light
19 {
20 private:
21         Color ambient;
22         Color diffuse;
23         Color specular;
24         Vector4 position;
25         Vector3 spot_dir;
26         float spot_exp;
27         float spot_cutoff;
28         float attenuation[3];
29
30         static unsigned current_unit;
31         static std::vector<const Light *> current_lights;
32
33 public:
34         Light();
35
36         void set_ambient(const Color &c);
37         void set_diffuse(const Color &c);
38         void set_specular(const Color &c);
39         const Color &get_ambient() const { return ambient; }
40         const Color &get_diffuse() const { return diffuse; }
41         const Color &get_specular() const { return specular; }
42
43         void set_position(const Vector4 &);
44         const Vector4 &get_position() const { return position; }
45         void set_spot_direction(const Vector3 &);
46         void set_spot_exponent(float);
47         void set_spot_cutoff(float);
48         const Vector3 &get_spot_direction() const { return spot_dir; }
49         float get_spot_exponent() const { return spot_exp; }
50         float get_spot_cutoff() const { return spot_cutoff; }
51         void set_attenuation(float, float, float);
52         const float *get_attenuation() const { return attenuation; }
53
54         void bind() const;
55         void bind_to(unsigned) const;
56
57         // Deprecated
58         void set_position(float x, float y, float z, float w) { set_position(Vector4(x, y, z, w)); }
59
60         static void activate(unsigned);
61         static void unbind();
62 };
63
64 } // namespace GL
65 } // namespace Msp
66
67 #endif