24 void Light::set_diffuse(const Color &c)
29 void Light::set_specular(const Color &c)
34 void Light::set_position(const Vector4 &p)
39 void Light::set_spot_direction(const Vector3 &d)
44 void Light::set_spot_exponent(float e)
49 void Light::set_spot_cutoff(float c)
54 void Light::set_attenuation(float c, float l, float q)
61 void Light::bind_to(unsigned i) const
63 LightUnit &unit = LightUnit::get_unit(i);
64 if(unit.set_light(this))
66 GLenum l = GL_LIGHT0+unit.get_index();
68 glLightfv(l, GL_DIFFUSE, &diffuse.r);
69 glLightfv(l, GL_SPECULAR, &specular.r);
70 glLightfv(l, GL_POSITION, &position.x);
71 glLightfv(l, GL_SPOT_DIRECTION, &spot_dir.x);
72 glLightf(l, GL_SPOT_EXPONENT, spot_exp);
73 glLightf(l, GL_SPOT_CUTOFF, spot_cutoff);
74 glLightf(l, GL_CONSTANT_ATTENUATION, attenuation[0]);
75 glLightf(l, GL_LINEAR_ATTENUATION, attenuation[1]);
76 glLightf(l, GL_QUADRATIC_ATTENUATION, attenuation[2]);
80 const Light *Light::current(unsigned i)
82 return LightUnit::get_unit(i).get_light();
85 void Light::unbind_from(unsigned i)
87 LightUnit &unit = LightUnit::get_unit(i);
89 disable(GL_LIGHT0+unit.get_index());