18 void Material::update_parameter(int mask) const
24 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.r);
26 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse.r);
28 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &specular.r);
30 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, &emission.r);
32 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess);
35 void Material::set_ambient(const Color &a)
38 shdata.uniform("material.ambient", ambient);
39 update_parameter(AMBIENT);
42 void Material::set_diffuse(const Color &d)
45 shdata.uniform("material.diffuse", diffuse);
46 update_parameter(DIFFUSE);
49 void Material::set_specular(const Color &s)
52 shdata.uniform("material.specular", specular);
53 update_parameter(SPECULAR);
56 void Material::set_emission(const Color &e)
59 shdata.uniform("material.emission", emission);
60 update_parameter(EMISSION);
63 void Material::set_shininess(float s)
66 shdata.uniform("material.shininess", shininess);
67 update_parameter(SHININESS);
70 void Material::set_reflectivity(float r)
73 shdata.uniform("reflectivity", reflectivity);
76 void Material::bind() const
83 Material::Loader::Loader(Material &m):
84 DataFile::CollectionObjectLoader<Material>(m, 0)
89 Material::Loader::Loader(Material &m, Collection &c):
90 DataFile::CollectionObjectLoader<Material>(m, &c)
95 void Material::Loader::init()
97 if(Resources *res = dynamic_cast<Resources *>(coll))
98 srgb = res->get_srgb_conversion();
102 add("ambient", &Loader::ambient);
103 add("diffuse", &Loader::diffuse);
104 add("specular", &Loader::specular);
105 add("emission", &Loader::emission);
106 add("shininess", &Loader::shininess);
107 add("reflectivity", &Loader::reflectivity);
110 Color Material::Loader::make_color(float r, float g, float b, float a)
118 void Material::Loader::ambient(float r, float g, float b, float a)
120 obj.set_ambient(make_color(r, g, b, a));
123 void Material::Loader::diffuse(float r, float g, float b, float a)
125 obj.set_diffuse(make_color(r, g, b, a));
128 void Material::Loader::specular(float r, float g, float b, float a)
130 obj.set_specular(make_color(r, g, b, a));
133 void Material::Loader::emission(float r, float g, float b, float a)
135 obj.set_emission(make_color(r, g, b, a));
138 void Material::Loader::shininess(float s)
140 obj.set_shininess(s);
143 void Material::Loader::reflectivity(float r)
145 obj.set_reflectivity(r);