]> git.tdb.fi Git - libs/gl.git/blob - source/materials/pointlight.h
Check the flat qualifier from the correct member
[libs/gl.git] / source / materials / pointlight.h
1 #ifndef MSP_GL_POINTLIGHT_H_
2 #define MSP_GL_POINTLIGHT_H_
3
4 #include "light.h"
5 #include "vector.h"
6
7 namespace Msp {
8 namespace GL {
9
10 /**
11 A positional, omnidirectional light source.  The light's strength can be
12 attenuated based on distance.
13 */
14 class PointLight: public Light
15 {
16 public:
17         class Loader: public DataFile::DerivedObjectLoader<PointLight, Light::Loader>
18         {
19         private:
20                 static ActionMap shared_actions;
21
22         public:
23                 Loader(PointLight &);
24
25         private:
26                 virtual void init_actions();
27
28                 void attenuation(float, float, float);
29                 void position(float, float, float);
30         };
31
32 private:
33         Vector3 position = { 0.0f, 0.0f, 0.0f };
34         float attenuation[3] = { 1.0f, 0.0f, 1.0f };
35
36         void update_matrix();
37
38 public:
39         /** Sets the light's position from a matrix.  Only the translation part is
40         used. */
41         virtual void set_matrix(const Matrix &);
42
43         void set_position(const Vector3 &);
44         const Vector3 &get_position();
45
46         /** Sets the constant, linear and quadratic attentuation factors for the
47         light. */
48         void set_attenuation(float, float, float);
49
50         const float *get_attenuation() const { return attenuation; }
51
52 protected:
53         virtual void update_shader_data(ProgramData &, const std::string &) const;
54 };
55
56 } // namespace GL
57 } // namespace Msp
58
59 #endif