]> git.tdb.fi Git - libs/gl.git/blobdiff - source/material.cpp
Add sampler support to materials
[libs/gl.git] / source / material.cpp
index 9109b786ecb4d414a3d455c57fe6421a06a7d314..a99f3c2cccc83f235b1da411f474288f386cffe7 100644 (file)
@@ -55,7 +55,7 @@ void Material::attach_texture_to(const Texture *tex, Texturing &texturing, Progr
        if(unit<0)
                throw runtime_error("no free texunit");
 
-       texturing.attach(unit, *tex);
+       texturing.attach(unit, *tex, sampler);
        tex_shdata.uniform(name, unit);
 }
 
@@ -72,6 +72,25 @@ Material::MaterialRegistry &Material::get_material_registry()
 }
 
 
+Material::Loader::Loader(Material &m):
+       CollectionObjectLoader(m, 0)
+{ }
+
+Material::Loader::Loader(Material &m, Collection &c):
+       CollectionObjectLoader(m, &c)
+{ }
+
+void Material::Loader::init_actions()
+{
+       add("sampler", &Loader::sampler);
+}
+
+void Material::Loader::sampler(const std::string &name)
+{
+       obj.sampler = &get_collection().get<Sampler>(name);
+}
+
+
 DataFile::Loader::ActionMap Material::GenericLoader::shared_actions;
 
 Material::GenericLoader::GenericLoader(DataFile::Collection *c):