From: Mikko Rasa Date: Mon, 20 Aug 2012 12:39:26 +0000 (+0300) Subject: Move PipelinePass inside Pipeline and make the data members private X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=40a0024a6466298d064697ed022465c7d3e9168e;p=libs%2Fgl.git Move PipelinePass inside Pipeline and make the data members private It's really simple and specific to Pipeline, so it doesn't make much sense to have it as a separate class. Encapsulation is necessary for some future plans, and also more consistent with other public interfaces. --- diff --git a/source/pipeline.cpp b/source/pipeline.cpp index 8757ea92..ce155970 100644 --- a/source/pipeline.cpp +++ b/source/pipeline.cpp @@ -58,19 +58,19 @@ void Pipeline::set_camera(const Camera *c) camera = c; } -PipelinePass &Pipeline::add_pass(const Tag &tag) +Pipeline::Pass &Pipeline::add_pass(const Tag &tag) { - PipelinePass &pass = insert_unique(passes, tag, PipelinePass())->second; + Pass &pass = insert_unique(passes, tag, Pass())->second; pass_order.push_back(tag); return pass; } -PipelinePass &Pipeline::get_pass(const Tag &tag) +Pipeline::Pass &Pipeline::get_pass(const Tag &tag) { return get_item(passes, tag); } -const PipelinePass &Pipeline::get_pass(const Tag &tag) const +const Pipeline::Pass &Pipeline::get_pass(const Tag &tag) const { return get_item(passes, tag); } @@ -121,11 +121,11 @@ void Pipeline::add_postprocessor(PostProcessor &pp) void Pipeline::render(Renderer &renderer, const Tag &tag) const { - const PipelinePass &pass = get_pass(tag); + const Pass &pass = get_pass(tag); - Bind bind_depth_test(pass.depth_test); - Bind bind_blend(pass.blend); - Bind bind_lighting(pass.lighting); + Bind bind_depth_test(pass.get_depth_test()); + Bind bind_blend(pass.get_blend()); + Bind bind_lighting(pass.get_lighting()); for(vector::const_iterator i=renderables.begin(); i!=renderables.end(); ++i) if(i->passes.empty() || i->passes.count(tag)) @@ -204,6 +204,28 @@ void Pipeline::create_fbos() } +Pipeline::Pass::Pass(): + lighting(0), + depth_test(0), + blend(0) +{ } + +void Pipeline::Pass::set_lighting(const Lighting *l) +{ + lighting = l; +} + +void Pipeline::Pass::set_depth_test(const DepthTest *d) +{ + depth_test = d; +} + +void Pipeline::Pass::set_blend(const Blend *b) +{ + blend = b; +} + + Pipeline::Slot::Slot(const Renderable *r): renderable(r) { } diff --git a/source/pipeline.h b/source/pipeline.h index 85179b7d..011a96bb 100644 --- a/source/pipeline.h +++ b/source/pipeline.h @@ -3,20 +3,41 @@ #include #include -#include "pipelinepass.h" #include "renderable.h" namespace Msp { namespace GL { +class Blend; class Camera; +class DepthTest; class Framebuffer; +class Lighting; class PostProcessor; class Renderbuffer; class Texture2D; class Pipeline: public Renderable { +public: + class Pass + { + private: + const Lighting *lighting; + const DepthTest *depth_test; + const Blend *blend; + + public: + Pass(); + + void set_lighting(const Lighting *); + void set_depth_test(const DepthTest *); + void set_blend(const Blend *); + const Lighting *get_lighting() const { return lighting; } + const DepthTest *get_depth_test() const { return depth_test; } + const Blend *get_blend() const { return blend; } + }; + private: struct Slot { @@ -26,7 +47,7 @@ private: Slot(const Renderable *); }; - typedef std::map PassMap; + typedef std::map PassMap; PassMap passes; std::vector pass_order; @@ -52,9 +73,9 @@ public: void set_multisample(unsigned); void set_camera(const Camera *); - PipelinePass &add_pass(const Tag &tag); - PipelinePass &get_pass(const Tag &tag); - const PipelinePass &get_pass(const Tag &tag) const; + Pass &add_pass(const Tag &tag); + Pass &get_pass(const Tag &tag); + const Pass &get_pass(const Tag &tag) const; void add_renderable(const Renderable &); void add_renderable_for_pass(const Renderable &, const Tag &); diff --git a/source/pipelinepass.cpp b/source/pipelinepass.cpp deleted file mode 100644 index 2b0b4395..00000000 --- a/source/pipelinepass.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "pipelinepass.h" - -namespace Msp { -namespace GL { - -PipelinePass::PipelinePass(): - lighting(0), - depth_test(0), - blend(0) -{ } - -} // namespace GL -} // namespace Msp diff --git a/source/pipelinepass.h b/source/pipelinepass.h deleted file mode 100644 index e996de0c..00000000 --- a/source/pipelinepass.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef MSP_GL_PIPELINEPASS_H_ -#define MSP_GL_PIPELINEPASS_H_ - -namespace Msp { -namespace GL { - -class Blend; -class DepthTest; -class Lighting; - -struct PipelinePass -{ - const Lighting *lighting; - const DepthTest *depth_test; - const Blend *blend; - - PipelinePass(); -}; - -} // namespace GL -} // namespace Msp - -#endif