]> git.tdb.fi Git - libs/gl.git/blob - source/lighting.h
Support hemispherical skylight in ProgramBuilder
[libs/gl.git] / source / lighting.h
1 #ifndef MSP_GL_LIGHTING_H_
2 #define MSP_GL_LIGHTING_H_
3
4 #include <vector>
5 #include <msp/geometry/angle.h>
6 #include "bindable.h"
7 #include "color.h"
8 #include "gl.h"
9 #include "programdata.h"
10
11 namespace Msp {
12 namespace GL {
13
14 class Light;
15
16 /**
17 Encapsulates global lighting parameters and a number of individual lights.
18 */
19 class Lighting: public Bindable<Lighting>
20 {
21 private:
22         Color ambient;
23         Color sky_color;
24         Vector3 sky_direction;
25         Geometry::Angle<float> horizon_angle;
26         std::vector<const Light *> lights;
27
28 public:
29         Lighting();
30
31         void set_ambient(const Color &);
32         const Color &get_ambient() const { return ambient; }
33
34         void set_sky_color(const Color &);
35         void set_sky_direction(const Vector3 &);
36         void set_horizon_angle(const Geometry::Angle<float> &);
37
38         void attach(unsigned, const Light &);
39         void detach(unsigned);
40
41         void update_shader_data(ProgramData &, const Matrix &) const;
42         void bind() const;
43
44         static void unbind();
45 };
46
47 } // namespace GL
48 } // namespace Msp
49
50 #endif