]> git.tdb.fi Git - libs/gl.git/blobdiff - source/renderpass.cpp
Drop Id tags and copyright notices from files
[libs/gl.git] / source / renderpass.cpp
index d15a70983637f876de06a12bc3a0b9a8a393b4f8..4ab07347824ef68765a72becd9e35f9a1151fe28 100644 (file)
@@ -1,10 +1,3 @@
-/* $Id$
-
-This file is part of libmspgl
-Copyright © 2007-2008, 2010-2011  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
 #include <msp/core/refptr.h>
 #include <msp/datafile/collection.h>
 #include <msp/strings/formatter.h>
@@ -33,7 +26,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 +50,14 @@ void RenderPass::set_texture(unsigned index, const Texture *tex)
        texturing->attach(index, *tex);
 }
 
+int RenderPass::get_texture_index(const string &n) const
+{
+       map<string, unsigned>::const_iterator i = tex_names.find(n);
+       if(i==tex_names.end())
+               return -1;
+       return i->second;
+}
+
 
 RenderPass::Loader::Loader(RenderPass &p):
        DataFile::CollectionObjectLoader<RenderPass>(p, 0)
@@ -77,6 +79,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 +104,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)