]> git.tdb.fi Git - libs/gl.git/commitdiff
Make RenderPass easier to use
authorMikko Rasa <tdb@tdb.fi>
Mon, 9 Sep 2013 15:56:15 +0000 (18:56 +0300)
committerMikko Rasa <tdb@tdb.fi>
Mon, 9 Sep 2013 15:56:15 +0000 (18:56 +0300)
source/object.cpp
source/renderpass.cpp
source/renderpass.h

index 769996834bd89692f1be7496e6c2d1a411b0d3b6..6bc872a198553eb38aa65ae67052b32ace758597 100644 (file)
@@ -77,9 +77,7 @@ void Object::render(Renderer &renderer, const Tag &tag) const
                return;
 
        Renderer::Push push(renderer);
-       renderer.set_shader_program(pass->get_shader_program(), pass->get_shader_data());
-       renderer.set_material(pass->get_material());
-       renderer.set_texturing(pass->get_texturing());
+       pass->apply(renderer);
 
        setup_render(renderer, tag);
        meshes.front()->draw(renderer);
@@ -93,9 +91,7 @@ void Object::render(Renderer &renderer, const ObjectInstance &inst, const Tag &t
                return;
 
        Renderer::Push push(renderer);
-       renderer.set_shader_program(pass->get_shader_program(), pass->get_shader_data());
-       renderer.set_material(pass->get_material());
-       renderer.set_texturing(pass->get_texturing());
+       pass->apply(renderer);
 
        setup_render(renderer, tag);
        inst.setup_render(renderer, tag);
index de5ac07f8f6bcf34356eab49bb693c6c26d3ecde..9ee79d4bb464340e438945c5aba50d843ed1ed0d 100644 (file)
@@ -5,6 +5,7 @@
 #include "renderpass.h"
 #include "program.h"
 #include "programdata.h"
+#include "renderer.h"
 #include "texenv.h"
 #include "texture.h"
 #include "texture2d.h"
@@ -64,6 +65,13 @@ int RenderPass::get_texture_index(const string &n) const
        return i->second;
 }
 
+void RenderPass::apply(Renderer &renderer) const
+{
+       renderer.set_texturing(texturing);
+       renderer.set_material(material.get());
+       renderer.set_shader_program(shprog, shdata.get());
+}
+
 
 RenderPass::Loader::Loader(RenderPass &p):
        DataFile::CollectionObjectLoader<RenderPass>(p, 0)
index ac752ae230c5c9b7d6435d2fc8de2938b3426b55..e891802e3fa970e1a9005469a1783800d7cb24d3 100644 (file)
@@ -11,6 +11,7 @@ namespace GL {
 class Material;
 class Program;
 class ProgramData;
+class Renderer;
 class TexEnv;
 class Texture;
 class Texturing;
@@ -77,6 +78,8 @@ public:
        void set_texture(unsigned, const Texture *);
        const Texturing *get_texturing() const { return texturing; }
        int get_texture_index(const std::string &) const;
+
+       void apply(Renderer &) const;
 };
 
 } // namespace GL