17 void Material::update_parameter(int mask) const
23 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.r);
25 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse.r);
27 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &specular.r);
29 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, &emission.r);
31 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess);
34 void Material::set_ambient(const Color &a)
37 shdata.uniform("material.ambient", ambient);
38 update_parameter(AMBIENT);
41 void Material::set_diffuse(const Color &d)
44 shdata.uniform("material.diffuse", diffuse);
45 update_parameter(DIFFUSE);
48 void Material::set_specular(const Color &s)
51 shdata.uniform("material.specular", specular);
52 update_parameter(SPECULAR);
55 void Material::set_emission(const Color &e)
58 shdata.uniform("material.emission", emission);
59 update_parameter(EMISSION);
62 void Material::set_shininess(float s)
65 shdata.uniform("material.shininess", shininess);
66 update_parameter(SHININESS);
69 void Material::bind() const
76 Material::Loader::Loader(Material &m):
77 DataFile::CollectionObjectLoader<Material>(m, 0)
82 Material::Loader::Loader(Material &m, Collection &c):
83 DataFile::CollectionObjectLoader<Material>(m, &c)
88 void Material::Loader::init()
90 if(Resources *res = dynamic_cast<Resources *>(coll))
91 srgb = res->get_srgb_conversion();
95 add("ambient", &Loader::ambient);
96 add("diffuse", &Loader::diffuse);
97 add("specular", &Loader::specular);
98 add("emission", &Loader::emission);
99 add("shininess", &Loader::shininess);
102 Color Material::Loader::make_color(float r, float g, float b, float a)
110 void Material::Loader::ambient(float r, float g, float b, float a)
112 obj.set_ambient(make_color(r, g, b, a));
115 void Material::Loader::diffuse(float r, float g, float b, float a)
117 obj.set_diffuse(make_color(r, g, b, a));
120 void Material::Loader::specular(float r, float g, float b, float a)
122 obj.set_specular(make_color(r, g, b, a));
125 void Material::Loader::emission(float r, float g, float b, float a)
127 obj.set_emission(make_color(r, g, b, a));
130 void Material::Loader::shininess(float s)
132 obj.set_shininess(s);