16 void Lighting::set_ambient(const Color &a)
21 void Lighting::attach(unsigned i, const Light &l)
23 if(i>=LightUnit::get_n_units())
24 throw out_of_range("Lighting::attach");
34 void Lighting::detach(unsigned i)
41 Light::unbind_from(i);
44 void Lighting::update_shader_data(const Matrix &view_matrix)
46 shdata.uniform("ambient_color", ambient);
47 for(unsigned i=0; i<lights.size(); ++i)
49 lights[i]->update_shader_data(shdata, view_matrix, i);
52 void Lighting::bind() const
54 if(!set_current(this))
58 glLightModelfv(GL_LIGHT_MODEL_AMBIENT, &ambient.r);
59 for(unsigned i=0; i<lights.size(); ++i)
61 lights[i]->bind_to(i);
64 void Lighting::unbind()
66 const Lighting *old = current();
70 for(unsigned i=0; i<old->lights.size(); ++i)
72 Light::unbind_from(i);