16 void Material::update_parameter(int mask) const
22 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.r);
24 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse.r);
26 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &specular.r);
28 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, &emission.r);
30 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess);
33 void Material::set_ambient(const Color &a)
36 shdata.uniform("material.ambient", ambient);
37 update_parameter(AMBIENT);
40 void Material::set_diffuse(const Color &d)
43 shdata.uniform("material.diffuse", diffuse);
44 update_parameter(DIFFUSE);
47 void Material::set_specular(const Color &s)
50 shdata.uniform("material.specular", specular);
51 update_parameter(SPECULAR);
54 void Material::set_emission(const Color &e)
57 shdata.uniform("material.emission", emission);
58 update_parameter(EMISSION);
61 void Material::set_shininess(float s)
64 shdata.uniform("material.shininess", shininess);
65 update_parameter(SHININESS);
68 void Material::bind() const
75 Material::Loader::Loader(Material &m):
76 DataFile::ObjectLoader<Material>(m)
78 add("ambient", &Loader::ambient);
79 add("diffuse", &Loader::diffuse);
80 add("specular", &Loader::specular);
81 add("emission", &Loader::emission);
82 add("shininess", &Loader::shininess);
85 void Material::Loader::ambient(float r, float g, float b, float a)
87 obj.set_ambient(GL::Color(r, g, b, a));
90 void Material::Loader::diffuse(float r, float g, float b, float a)
92 obj.set_diffuse(GL::Color(r, g, b, a));
95 void Material::Loader::specular(float r, float g, float b, float a)
97 obj.set_specular(GL::Color(r, g, b, a));
100 void Material::Loader::emission(float r, float g, float b, float a)
102 obj.set_emission(GL::Color(r, g, b, a));
105 void Material::Loader::shininess(float s)
107 obj.set_shininess(s);