From 72790b3aba8ddc1a6d020646fb7312959729777b Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 9 Sep 2013 18:56:15 +0300 Subject: [PATCH] Make RenderPass easier to use --- source/object.cpp | 8 ++------ source/renderpass.cpp | 8 ++++++++ source/renderpass.h | 3 +++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/source/object.cpp b/source/object.cpp index 76999683..6bc872a1 100644 --- a/source/object.cpp +++ b/source/object.cpp @@ -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); diff --git a/source/renderpass.cpp b/source/renderpass.cpp index de5ac07f..9ee79d4b 100644 --- a/source/renderpass.cpp +++ b/source/renderpass.cpp @@ -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(p, 0) diff --git a/source/renderpass.h b/source/renderpass.h index ac752ae2..e891802e 100644 --- a/source/renderpass.h +++ b/source/renderpass.h @@ -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 -- 2.45.2