X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Frenderpass.cpp;h=b95bd4bcfe1977c9ce327c0e5189883efd97800a;hb=6c2cb15dca6c24642f5026b06e6168c0d820355f;hp=d15a70983637f876de06a12bc3a0b9a8a393b4f8;hpb=5172d32d67595ea0b70184fadcfcb8e023cccbc8;p=libs%2Fgl.git diff --git a/source/renderpass.cpp b/source/renderpass.cpp index d15a7098..b95bd4bc 100644 --- a/source/renderpass.cpp +++ b/source/renderpass.cpp @@ -33,7 +33,8 @@ RenderPass::RenderPass(const RenderPass &other): shprog(other.shprog), shdata(other.shdata ? new ProgramData(*other.shdata) : 0), material(other.material), - texturing(other.texturing ? new Texturing(*other.texturing) : 0) + texturing(other.texturing ? new Texturing(*other.texturing) : 0), + tex_names(other.tex_names) { } RenderPass::~RenderPass() @@ -56,6 +57,14 @@ void RenderPass::set_texture(unsigned index, const Texture *tex) texturing->attach(index, *tex); } +int RenderPass::get_texture_index(const string &n) const +{ + map::const_iterator i = tex_names.find(n); + if(i==tex_names.end()) + return -1; + return i->second; +} + RenderPass::Loader::Loader(RenderPass &p): DataFile::CollectionObjectLoader(p, 0) @@ -77,6 +86,7 @@ void RenderPass::Loader::init() add("material", &Loader::material_inline); add("material", &Loader::material); add("texunit", &Loader::texunit); + add("texunit", &Loader::texunit_named); add("uniforms", &Loader::uniforms); } @@ -101,6 +111,12 @@ void RenderPass::Loader::texunit(unsigned i) load_sub_with(ldr); } +void RenderPass::Loader::texunit_named(unsigned i, const string &n) +{ + texunit(i); + obj.tex_names[n] = i; +} + void RenderPass::Loader::uniforms() { if(!obj.shprog)