]> git.tdb.fi Git - libs/gl.git/blobdiff - source/basicmaterial.cpp
Remove the deprecated ProgramBuilder class
[libs/gl.git] / source / basicmaterial.cpp
index 858c65daf56e8a31e5cdb9c22f1ab0da3f43ae57..362fc9db14e6a8636960bec3a746cd8e62715ed8 100644 (file)
@@ -5,7 +5,8 @@ using namespace std;
 namespace Msp {
 namespace GL {
 
-BasicMaterial::BasicMaterial()
+BasicMaterial::BasicMaterial():
+       receive_shadows(false)
 {
        set_diffuse(Color(1.0f));
        set_specular(Color(0.0f));
@@ -41,6 +42,8 @@ string BasicMaterial::create_program_source() const
                if (reflectivity.texture)
                        source += "const bool use_reflectivity_map = true;\n";
        }
+       if(receive_shadows)
+               source += "const bool use_shadow_map = true;\n";
        return source;
 }
 
@@ -114,29 +117,36 @@ void BasicMaterial::set_reflectivity_map(const Texture *tex)
        reflectivity.texture = tex;
 }
 
+void BasicMaterial::set_receive_shadows(bool s)
+{
+       receive_shadows = s;
+}
+
 
 DataFile::Loader::ActionMap BasicMaterial::Loader::shared_actions;
 
 BasicMaterial::Loader::Loader(BasicMaterial &m):
-       DerivedObjectLoader<BasicMaterial, Material::LoaderBase<BasicMaterial> >(m)
+       DerivedObjectLoader<BasicMaterial, Material::PropertyLoader<BasicMaterial> >(m)
 {
        set_actions(shared_actions);
 }
 
 BasicMaterial::Loader::Loader(BasicMaterial &m, Collection &c):
-       DerivedObjectLoader<BasicMaterial, Material::LoaderBase<BasicMaterial> >(m, c)
+       DerivedObjectLoader<BasicMaterial, Material::PropertyLoader<BasicMaterial> >(m, c)
 {
        set_actions(shared_actions);
 }
 
 void BasicMaterial::Loader::init_actions()
 {
+       Material::PropertyLoader<BasicMaterial>::init_actions();
        add_property("diffuse", &BasicMaterial::set_diffuse, &BasicMaterial::set_diffuse_map, true);
        add_property("specular", &BasicMaterial::set_specular, &BasicMaterial::set_specular_map, false);
        add_property("normal", &BasicMaterial::set_normal_map);
        add_property("emission", &BasicMaterial::set_emission, &BasicMaterial::set_emission_map, false);
        add_property("shininess", &BasicMaterial::set_shininess, &BasicMaterial::set_shininess_map);
        add_property("reflectivity", &BasicMaterial::set_reflectivity, &BasicMaterial::set_reflectivity_map);
+       add("receive_shadows", &BasicMaterial::receive_shadows);
 }
 
 } // namespace GL