]> git.tdb.fi Git - libs/gl.git/blobdiff - source/material.cpp
Support for loading materials from datafiles
[libs/gl.git] / source / material.cpp
index 58cd15cb8e122169803ce5015be54681df948173..f165c744fcdf06277c362977954b800c06e6e6df 100644 (file)
@@ -52,5 +52,36 @@ void Material::apply() const
        glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess);
 }
 
+
+Material::Loader::Loader(Material &m):
+       mat(m)
+{
+       add("ambient",   &Loader::ambient);
+       add("diffuse",   &Loader::diffuse);
+       add("specular",  &Loader::specular);
+       add("emission",  &Loader::emission);
+       add("shininess", &Material::shininess);
+}
+
+void Material::Loader::ambient(float r, float g, float b, float a)
+{
+       mat.ambient=GL::Color(r, g, b, a);
+}
+
+void Material::Loader::diffuse(float r, float g, float b, float a)
+{
+       mat.diffuse=GL::Color(r, g, b, a);
+}
+
+void Material::Loader::specular(float r, float g, float b, float a)
+{
+       mat.specular=GL::Color(r, g, b, a);
+}
+
+void Material::Loader::emission(float r, float g, float b, float a)
+{
+       mat.emission=GL::Color(r, g, b, a);
+}
+
 } // namespace GL
 } // namespace Msp