]> git.tdb.fi Git - libs/gl.git/commitdiff
Support collectionless loading of Technique and RenderPass
authorMikko Rasa <tdb@tdb.fi>
Tue, 23 Feb 2010 14:42:09 +0000 (14:42 +0000)
committerMikko Rasa <tdb@tdb.fi>
Tue, 23 Feb 2010 14:42:09 +0000 (14:42 +0000)
source/object.cpp
source/renderpass.cpp
source/renderpass.h
source/technique.cpp
source/technique.h

index 0a03b7a81a151da82ac76c41e04159e23fc4a963..2423fcdab3fa353c47639484953e07cef1a68a5f 100644 (file)
@@ -125,9 +125,12 @@ void Object::Loader::mesh(const std::string &n)
 
 void Object::Loader::technique()
 {
-       RefPtr<Technique> tch=new Technique;
-       load_sub(*tch, get_collection());
-       obj.technique=tch.release();
+       RefPtr<Technique> tech=new Technique;
+       if(coll)
+               load_sub(*tech, get_collection());
+       else
+               load_sub(*tech);
+       obj.technique=tech.release();
        obj.own_technique=true;
 }
 
index 9e5b71d91f6a7a778902400d58fb0f5316dc40b7..06726086bffd9067c6c88332ca8db52c01efa12f 100644 (file)
@@ -111,8 +111,19 @@ void RenderPass::unbind()
 }
 
 
+RenderPass::Loader::Loader(RenderPass &p):
+       DataFile::CollectionObjectLoader<RenderPass>(p, 0)
+{
+       init();
+}
+
 RenderPass::Loader::Loader(RenderPass &p, Collection &c):
        DataFile::CollectionObjectLoader<RenderPass>(p, &c)
+{
+       init();
+}
+
+void RenderPass::Loader::init()
 {
        allow_pointer_reload=false;
 
index 223f57dc410c9dedd5264cd554a0004cefb53a4d..94c6bc02b085885a4e7dea3bdad21447b33922f7 100644 (file)
@@ -28,9 +28,11 @@ public:
        class Loader: public DataFile::CollectionObjectLoader<RenderPass>
        {
        public:
+               Loader(RenderPass &);
                Loader(RenderPass &, Collection &);
 
        private:
+               void init();
                virtual void finish();
                void material();
                void shader(const std::string &);
index 78060e01f9b89e80e28f7171fc40cea23188d327..d913f4d1aa490b0264c8f94600c9ed93d571f55d 100644 (file)
@@ -34,8 +34,19 @@ const RenderPass &Technique::get_pass(const GL::Tag &tag) const
 }
 
 
+Technique::Loader::Loader(Technique &t):
+       DataFile::CollectionObjectLoader<Technique>(t, 0)
+{
+       init();
+}
+
 Technique::Loader::Loader(Technique &t, Collection &c):
        DataFile::CollectionObjectLoader<Technique>(t, &c)
+{
+       init();
+}
+
+void Technique::Loader::init()
 {
        add("inherit", &Loader::inherit);
        add("pass", &Loader::pass);
@@ -55,7 +66,10 @@ void Technique::Loader::pass(const string &n)
                throw KeyError("Duplicate pass name", n);
 
        RenderPass p;
-       load_sub(p, *coll);
+       if(coll)
+               load_sub(p, get_collection());
+       else
+               load_sub(p);
        obj.passes.insert(PassMap::value_type(tag, p));
 }
 
index ce12b4f41f0e765c24705f5c94f5d0914c7661c4..6633ad7d6e80abe370aba33838f8ff1062892833 100644 (file)
@@ -25,9 +25,11 @@ public:
        class Loader: public Msp::DataFile::CollectionObjectLoader<Technique>
        {
        public:
+               Loader(Technique &);
                Loader(Technique &, Collection &);
 
        private:
+               void init();
                void inherit(const std::string &);
                void pass(const std::string &);
        };