]> git.tdb.fi Git - libs/gl.git/blob - source/materials/light.cpp
Validate the presence of in/out layout qualifiers for geometry shaders
[libs/gl.git] / source / materials / light.cpp
1 #include <stdexcept>
2 #include <msp/strings/format.h>
3 #include "directionallight.h"
4 #include "light.h"
5 #include "pointlight.h"
6
7 using namespace std;
8
9 namespace Msp {
10 namespace GL {
11
12 void Light::set_color(const Color &c)
13 {
14         color = c;
15         ++generation;
16 }
17
18 void Light::update_shader_data(ProgramData &shdata, unsigned i) const
19 {
20         update_shader_data(shdata, format("light_sources[%d]", i));
21 }
22
23 Light::GenericLoader::TypeRegistry &Light::get_light_registry()
24 {
25         static GenericLoader::TypeRegistry registry;
26         static bool initialized = false;
27         if(!initialized)
28         {
29                 initialized = true;
30                 registry.register_type<DirectionalLight>("directional");
31                 registry.register_type<PointLight>("point");
32         }
33         return registry;
34 }
35
36
37 Light::Loader::Loader(Light &l):
38         DataFile::ObjectLoader<Light>(l)
39 { }
40
41 void Light::Loader::init_actions()
42 {
43         add("color", &Loader::color);
44 }
45
46 void Light::Loader::color(float r, float g, float b)
47 {
48         obj.set_color(Color(r, g, b));
49 }
50
51 } // namespace GL
52 } // namespace Msp