From e34e82619af0704b465e081f257f9952972e04b2 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 24 May 2019 22:29:41 +0300 Subject: [PATCH] Create Stage pipeline when added to a view Also remove add_postprocessor since it's kinda useless when the pipeline is create at some random time during playback. --- source/stage.cpp | 16 ++++++++++------ source/stage.h | 6 +++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/source/stage.cpp b/source/stage.cpp index e1ce352..0ca5c5e 100644 --- a/source/stage.cpp +++ b/source/stage.cpp @@ -6,7 +6,8 @@ using namespace std; using namespace Msp; Stage::Stage(): - pipeline(0) + pipeline(0), + last_view(0) { } Stage::~Stage() @@ -19,11 +20,6 @@ void Stage::add_things(Demo::ThingMap &things, const string &prefix) things[prefix+"camera"] = static_cast(&camera); } -void Stage::add_postprocessor(GL::PostProcessor &pp) -{ - pipeline->add_postprocessor(pp); -} - void Stage::set_camera(const GL::Camera &c) { camera.set_object_matrix(c.get_object_matrix()); @@ -53,6 +49,14 @@ void Stage::UseInView::validate() const void Stage::UseInView::start(float, float) { + if(!stage->pipeline || view!=stage->last_view) + { + stage->create_pipeline(*view); + if(!stage->pipeline) + throw logic_error("null pipeline"); + stage->last_view = view; + } + view->set_camera(&stage->camera); view->set_content(stage->pipeline); } diff --git a/source/stage.h b/source/stage.h index c108f6f..7d4664f 100644 --- a/source/stage.h +++ b/source/stage.h @@ -64,15 +64,19 @@ public: protected: Msp::GL::Pipeline *pipeline; Msp::GL::Camera camera; + Msp::GL::View *last_view; public: Stage(); ~Stage(); virtual void add_things(Demo::ThingMap &, const std::string &); - void add_postprocessor(Msp::GL::PostProcessor &); + void set_camera(const Msp::GL::Camera &); Msp::GL::Camera &get_camera() { return camera; } + +protected: + virtual void create_pipeline(Msp::GL::View &) = 0; }; #endif -- 2.45.2