From: Mikko Rasa Date: Sat, 28 Jan 2023 19:59:09 +0000 (+0200) Subject: Create the rendering sequence dynamically X-Git-Url: https://git.tdb.fi/?a=commitdiff_plain;h=ee14f96ada514ea2dec303069e4447b20803dac4;p=libs%2Fgame.git Create the rendering sequence dynamically Sequence templates are a bit too rigid for games where it's desirable to tune many different graphics quality settings independently. --- diff --git a/source/game/camera.h b/source/game/camera.h index e981afc..f09c105 100644 --- a/source/game/camera.h +++ b/source/game/camera.h @@ -43,7 +43,6 @@ public: float get_near_clip() const { return read().near_clip; } float get_far_clip() const { return read().far_clip; } CameraScaling get_scaling() const { return setup.scaling; } - const std::string &get_sequence_name() const { return setup.sequence_name; } }; } // namespace Msp::Game diff --git a/source/game/setups.mgs b/source/game/setups.mgs index 6bd13bc..3392df1 100644 --- a/source/game/setups.mgs +++ b/source/game/setups.mgs @@ -16,7 +16,6 @@ component Camera field near_clip float { default "0.1f"; }; field far_clip float { default "100.0f"; }; field scaling CameraScaling { default "SCALE_TO_FIT"; }; - field sequence_name string; }; enum LightType diff --git a/source/gameview/renderer.cpp b/source/gameview/renderer.cpp index e6b2696..bbdc23c 100644 --- a/source/gameview/renderer.cpp +++ b/source/gameview/renderer.cpp @@ -4,8 +4,7 @@ #include #include #include -#include -#include +#include #include #include #include "lightemitter.h" @@ -87,15 +86,21 @@ void Renderer::camera_changed(const Game::Events::CameraChanged &event) active_camera = event.camera; if(event.camera) { - const string &seq_name = event.camera->get_sequence_name(); - if(seq_name!=current_seq_name) - { - current_seq_name = seq_name; - GL::SequenceBuilder bld(stage.get_resources().get(seq_name)); - bld.set_renderable("content", scene); - sequence.reset(bld.build(view)); - view.set_content(sequence.get()); - } + GL::FrameFormat fmt = (GL::COLOR_ATTACHMENT,GL::RGBA8, GL::DEPTH_ATTACHMENT); + sequence = make_unique(view.get_width(), view.get_height(), fmt); + sequence->set_clear_enabled(true); + sequence->set_clear_colors({ GL::Color(0.0f) }); + + GL::Sequence::Step &opaque = sequence->add_step(GL::Tag(), scene); + opaque.set_depth_test(GL::LEQUAL); + opaque.set_lighting(&lighting); + + unique_ptr colorcurve = make_unique(); + colorcurve->set_srgb(); + sequence->add_postprocessor(*colorcurve); + sequence->add_owned(colorcurve.release()); + + view.set_content(sequence.get()); } } diff --git a/source/gameview/renderer.h b/source/gameview/renderer.h index 54d1365..23ea5b4 100644 --- a/source/gameview/renderer.h +++ b/source/gameview/renderer.h @@ -38,7 +38,6 @@ private: GL::Lighting lighting; Game::Handle active_camera; GL::Camera gl_camera; - std::string current_seq_name; std::unique_ptr sequence; public: