- const Texture *tex=(n.empty() ? 0 : get_collection().get<Texture>(n));
- TextureSlot slot(tex);
- slot.name=(obj.textures.empty() ? "texture" : format("texture%d", obj.textures.size()));
- load_sub(slot);
- obj.textures.push_back(slot);
+ obj.shprog = &get_collection().get<Program>(n);
+ obj.shprog.keep();
+ obj.shprog_from_material = false;
+ if(obj.shdata)
+ obj.shdata = new ProgramData(*obj.shdata, obj.shprog.get());
+ if(obj.material)
+ obj.finalize_material(coll);
+}
+
+void RenderPass::Loader::texunit(unsigned i)
+{
+ if(!obj.texturing)
+ obj.texturing = new Texturing;
+ TextureLoader ldr(*obj.texturing, i, coll);
+ load_sub_with(ldr);
+}
+
+void RenderPass::Loader::texunit_auto(const string &n)
+{
+ if(!obj.texturing)
+ obj.texturing = new Texturing;
+ int i = obj.texturing->find_free_unit(n);
+ if(i<0)
+ throw runtime_error("no free texunit");
+ texunit_named(i, n);
+}
+
+void RenderPass::Loader::texunit_named(unsigned i, const string &n)
+{
+ texunit(i);
+ obj.tex_names[n] = i;
+ obj.ensure_private_shader_data();
+ obj.shdata->uniform(n, static_cast<int>(i));