1 #ifndef MSP_GL_LIGHTING_H_
2 #define MSP_GL_LIGHTING_H_
5 #include <msp/geometry/angle.h>
7 #include "programdata.h"
15 Combines multiple light sources with global lighting parameters.
17 This class also stores ProgramData for using the lights in shaders.
22 class Loader: public DataFile::CollectionObjectLoader<Lighting>
25 static ActionMap shared_actions;
28 Loader(Lighting &, Collection &);
31 virtual void init_actions();
33 void ambient(float, float, float);
34 void fog_color(float, float, float);
35 void fog_density(float);
36 void fog_half_distance(float);
37 void light(const std::string &);
45 mutable unsigned generation;
47 AttachedLight(const Light *l): light(l), generation(0) { }
53 std::vector<AttachedLight> lights;
54 mutable ProgramData shdata;
59 /** Sets the ambient lighting color. Affects all surfaces in an equal
61 void set_ambient(const Color &);
63 const Color &get_ambient() const { return ambient; }
65 /** Sets the fog color, which is blended into distant surfaces. */
66 void set_fog_color(const Color &);
68 /** Sets the density of the fog. Zero means no fog. */
69 void set_fog_density(float);
71 /** Sets the density of the fog so that the blending factor at the given
73 void set_fog_half_distance(float);
75 /** Attaches a light source. If the light was already attached, does
77 void attach(const Light &);
79 /** Detaches a light source. If the light was not attached, does nothing. */
80 void detach(const Light &);
82 int find_light_index(const Light &) const;
84 const ProgramData &get_shader_data() const;
86 void set_debug_name(const std::string &);