X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmaterial.cpp;h=810ecd174d81fb407730b33b0488b456dcee4f86;hb=bec07999d95b76f4b47cffcc564d0cd0afc0435e;hp=9109b786ecb4d414a3d455c57fe6421a06a7d314;hpb=f7d6481be3511153ded018e119bcac852faa0766;p=libs%2Fgl.git diff --git a/source/material.cpp b/source/material.cpp index 9109b786..810ecd17 100644 --- a/source/material.cpp +++ b/source/material.cpp @@ -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); } @@ -65,6 +65,7 @@ Material::MaterialRegistry &Material::get_material_registry() static bool initialized = false; if(!initialized) { + initialized = true; registry.register_type("basic"); registry.register_type("pbr"); } @@ -72,6 +73,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(name); +} + + DataFile::Loader::ActionMap Material::GenericLoader::shared_actions; Material::GenericLoader::GenericLoader(DataFile::Collection *c):