15 void Material::update_parameter(int mask) const
21 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.r);
23 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse.r);
25 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &specular.r);
27 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, &emission.r);
29 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess);
32 void Material::set_ambient(const Color &a)
35 update_parameter(AMBIENT);
38 void Material::set_diffuse(const Color &d)
41 update_parameter(DIFFUSE);
44 void Material::set_specular(const Color &s)
47 update_parameter(SPECULAR);
50 void Material::set_emission(const Color &e)
53 update_parameter(EMISSION);
56 void Material::set_shininess(float s)
59 update_parameter(SHININESS);
62 void Material::bind() const
69 Material::Loader::Loader(Material &m):
70 DataFile::ObjectLoader<Material>(m)
72 add("ambient", &Loader::ambient);
73 add("diffuse", &Loader::diffuse);
74 add("specular", &Loader::specular);
75 add("emission", &Loader::emission);
76 add("shininess", &Material::shininess);
79 void Material::Loader::ambient(float r, float g, float b, float a)
81 obj.ambient = GL::Color(r, g, b, a);
84 void Material::Loader::diffuse(float r, float g, float b, float a)
86 obj.diffuse = GL::Color(r, g, b, a);
89 void Material::Loader::specular(float r, float g, float b, float a)
91 obj.specular = GL::Color(r, g, b, a);
94 void Material::Loader::emission(float r, float g, float b, float a)
96 obj.emission = GL::Color(r, g, b, a);