return (i!=textures.end() ? i->tag : Tag());
}
-void RenderPass::set_texture(unsigned index, const Texture *tex, const Sampler *samp)
-{
- if(!shprog)
- throw invalid_operation("RenderPass::set_texture");
-
- const vector<ReflectData::UniformInfo> &uniforms = shprog->get_uniforms();
- for(const ReflectData::UniformInfo &u: uniforms)
- if(is_image(u.type) && u.binding==static_cast<int>(index))
- return set_texture(u.tag, tex, samp);
-
- if(shdata)
- {
- for(Tag t: shdata->get_uniform_tags())
- {
- auto j = find_member(uniforms, t, &ReflectData::UniformInfo::tag);
- if(j==uniforms.end() || !is_image(j->type))
- continue;
- if(const Uniform1i *uni1i = dynamic_cast<const Uniform1i *>(shdata->find_uniform(t)))
- if(uni1i->get()==static_cast<int>(index))
- return set_texture(t, tex, samp);
- }
- }
-}
-
-int RenderPass::get_texture_index(const string &n) const
-{
- auto i = find_member(textures, n, &TextureSlot::slot_name);
- return (shprog && i!=textures.end() ? shprog->get_uniform_binding(i->tag) : -1);
-}
-
void RenderPass::set_face_cull(CullMode fc)
{
face_cull = fc;
add("uniforms", &Loader::uniforms);
add("uniform_slot", &Loader::uniform_slot);
add("uniform_slot", &Loader::uniform_slot2);
-
- // Deprecated
- add("texunit", &Loader::texunit);
- add("texunit", &Loader::texture);
- add("texunit", &Loader::texunit_named);
}
void RenderPass::Loader::set_inline_base_name(const string &n)
load_sub_with(ldr);
}
-void RenderPass::Loader::texunit(unsigned)
-{
- IO::print(IO::cerr, "Warning: specifying textures by unit number is deprecated and may not produce expected results");
- string name;
- if(obj.shprog)
- {
- for(const ReflectData::UniformInfo &u: obj.shprog->get_uniforms())
- if(is_image(u.type) && u.binding>=0)
- {
- if(!name.empty())
- {
- name.clear();
- break;
- }
- name = u.name;
- }
- }
-
- if(name.empty())
- throw runtime_error("Could not determine name for texture");
-
- texture(name);
-}
-
-void RenderPass::Loader::texunit_named(unsigned, const string &n)
-{
- texture(n);
-}
-
void RenderPass::Loader::uniforms()
{
if(!obj.shprog || obj.shprog_from_material)
void material(const std::string &);
void shader(const std::string &);
void texture(const std::string &);
- void texunit(unsigned);
- void texunit_named(unsigned, const std::string &);
void uniforms();
void uniform_slot(const std::string &);
void uniform_slot2(const std::string &, const std::string &);
const std::string &get_material_slot_name() const { return material_slot; }
void set_texture(Tag, const Texture *, const Sampler * = 0);
Tag get_texture_tag(const std::string &) const;
- DEPRECATED void set_texture(unsigned, const Texture *, const Sampler * = 0);
- DEPRECATED int get_texture_index(const std::string &) const;
void set_face_cull(CullMode);
CullMode get_face_cull() const { return face_cull; }
void set_receive_shadows(bool);