1 #ifndef MSP_GL_LIGHT_H_
2 #define MSP_GL_LIGHT_H_
5 #include <msp/datafile/dynamicobjectloader.h>
6 #include <msp/datafile/objectloader.h>
16 Base class for light sources. The DirectionalLight and PointLight classes
17 implement different types of lights.
19 Lights are usually grouped with a Lighting object, which can be used in a
22 Shadows can be added to lights by using the ShadowMap effect.
24 class Light: public Placeable
27 class Loader: public DataFile::ObjectLoader<Light>
32 virtual void init_actions();
35 void color(float, float, float);
39 class GenericLoader: public DataFile::DynamicObjectLoader<Light>
44 GenericLoader(Collection &c): DynamicObjectLoader<Light>(&c) { }
47 virtual const TypeRegistry &get_type_registry() const { return Light::get_light_registry(); }
51 Color color = { 1.0f };
52 unsigned generation = 0;
56 virtual ~Light() = default;
58 /** Sets the color of the light. */
59 void set_color(const Color &);
61 const Color &get_color() const { return color; }
63 unsigned get_generation() const { return generation; }
65 /** Updates a ProgramData object with the uniform values for the light. A
66 light source index must be passed in. */
67 void update_shader_data(ProgramData &, unsigned) const;
70 virtual void update_shader_data(ProgramData &, const std::string &) const = 0;
73 static GenericLoader::TypeRegistry &get_light_registry();