- if(!tex)
- return;
-
- int unit = -1;
-
- if(const Uniform *uni = tex_shdata.find_uniform(name))
- if(const Uniform1i *uni_int = dynamic_cast<const Uniform1i *>(uni))
- unit = uni_int->get();
-
- if(unit<0)
- unit = texturing.find_free_unit(name);
- if(unit<0)
- throw runtime_error("no free texunit");
-
- texturing.attach(unit, *tex, sampler);
- tex_shdata.uniform(name, unit);