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
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()
RenderPass::TextureLoader::TextureLoader(Texturing &t, unsigned i, Collection *c):
DataFile::CollectionObjectLoader<Texturing>(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<Texture>(name);
- tex.keep();
+ samp = &get_collection().get<Sampler>(name);
}
-void RenderPass::TextureLoader::texture2d()
+void RenderPass::TextureLoader::texture(const string &name)
{
- tex = new Texture2D;
- if(coll)
- load_sub(static_cast<Texture2D &>(*tex), get_collection());
- else
- load_sub(static_cast<Texture2D &>(*tex));
+ tex = &get_collection().get<Texture>(name);
}
} // namespace GL