1 #ifndef MSP_GL_LIGHT_H_
2 #define MSP_GL_LIGHT_H_
15 Stores properties of a single light source.
17 Lights do not cast shadows by themselves. See ShadowMap for that.
46 void update_parameter(int, int = -1) const;
49 /** Sets the diffuse (direction-independent) color of the Light. Provided
50 to shaders with the name light_sources[i].diffuse. */
51 void set_diffuse(const Color &c);
53 /** Sets the specular (direction-dependent) color of the Light. Provided to
54 shaders with the name light_sources[i].diffuse. */
55 void set_specular(const Color &c);
57 const Color &get_diffuse() const { return diffuse; }
58 const Color &get_specular() const { return specular; }
60 /** Sets the position of the Light. For a directional light, set the xyz
61 components to a vector pointing towards the light and the w component to 0. */
62 void set_position(const Vector4 &);
64 const Vector4 &get_position() const { return position; }
66 void set_spot_direction(const Vector3 &);
67 void set_spot_exponent(float);
68 void set_spot_cutoff(float);
69 const Vector3 &get_spot_direction() const { return spot_dir; }
70 float get_spot_exponent() const { return spot_exp; }
71 float get_spot_cutoff() const { return spot_cutoff; }
72 void set_attenuation(float, float, float);
73 const float *get_attenuation() const { return attenuation; }
75 /** Updates a ProgramData object with the uniforms for the Light. A view
76 matrix and light source index must be passed in. */
77 void update_shader_data(ProgramData &, const Matrix &, unsigned) const;
79 void bind() const { return bind_to(0); }
80 void bind_to(unsigned) const;
82 static const Light *current(unsigned = 0);
83 static void unbind() { return unbind_from(0); }
84 static void unbind_from(unsigned);