X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Frenderpass.cpp;h=835e78a672cd6203649cdd9cbba4345421fa41b8;hp=b6eb1d954a958990716a730fd90702ee5341f092;hb=bec07999d95b76f4b47cffcc564d0cd0afc0435e;hpb=fd62e55d37716787fe909883a1b18e5b8128ec80 diff --git a/source/renderpass.cpp b/source/renderpass.cpp index b6eb1d95..835e78a6 100644 --- a/source/renderpass.cpp +++ b/source/renderpass.cpp @@ -128,7 +128,7 @@ void RenderPass::set_texture(unsigned index, const Texture *tex) if(!texturing) texturing = new Texturing; - texturing->attach(index, *tex); + texturing->attach(index, *tex, texturing->get_attached_sampler(index)); } int RenderPass::get_texture_index(const string &n) const @@ -172,6 +172,7 @@ void RenderPass::Loader::init() add("texunit", &Loader::texunit_named); add("uniforms", &Loader::uniforms); add("uniform_slot", &Loader::uniform_slot); + add("uniform_slot", &Loader::uniform_slot2); } void RenderPass::Loader::material_inline() @@ -245,34 +246,30 @@ void RenderPass::Loader::uniform_slot2(const string &name, const string &slot) RenderPass::TextureLoader::TextureLoader(Texturing &t, unsigned i, Collection *c): DataFile::CollectionObjectLoader(t, c), - index(i) + index(i), + tex(0), + samp(0) { + add("sampler", &TextureLoader::sampler); add("texture", &TextureLoader::texture); - add("texture2d", &TextureLoader::texture2d); } void RenderPass::TextureLoader::finish() { if(tex) - { - obj.attach(index, *tex); - tex.release(); - } + obj.attach(index, *tex, samp); + else if(samp) + obj.attach(index, *samp); } -void RenderPass::TextureLoader::texture(const string &name) +void RenderPass::TextureLoader::sampler(const string &name) { - tex = &get_collection().get(name); - tex.keep(); + samp = &get_collection().get(name); } -void RenderPass::TextureLoader::texture2d() +void RenderPass::TextureLoader::texture(const string &name) { - tex = new Texture2D; - if(coll) - load_sub(static_cast(*tex), get_collection()); - else - load_sub(static_cast(*tex)); + tex = &get_collection().get(name); } } // namespace GL