]> git.tdb.fi Git - libs/game.git/commitdiff
Create the rendering sequence dynamically
authorMikko Rasa <tdb@tdb.fi>
Sat, 28 Jan 2023 19:59:09 +0000 (21:59 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 28 Jan 2023 20:55:12 +0000 (22:55 +0200)
Sequence templates are a bit too rigid for games where it's desirable to
tune many different graphics quality settings independently.

source/game/camera.h
source/game/setups.mgs
source/gameview/renderer.cpp
source/gameview/renderer.h

index e981afcd3b2e85dfaf4d34d8d5f6ce65413e27b8..f09c1050be225122f87b28e7f92189f0c9adeea7 100644 (file)
@@ -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
index 6bd13bce23c21a8f8d87062b8e98784697914aa0..3392df1ce07a2875bafe38b23ea9c53e5cc663e1 100644 (file)
@@ -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
index e6b2696c9755571f68cd550846923bc1c752b28f..bbdc23c2fbf6f0ea111558d4cfcd357a4b6d20f6 100644 (file)
@@ -4,8 +4,7 @@
 #include <msp/game/meshsource.h>
 #include <msp/game/stage.h>
 #include <msp/game/transform.h>
-#include <msp/gl/sequencebuilder.h>
-#include <msp/gl/sequencetemplate.h>
+#include <msp/gl/colorcurve.h>
 #include <msp/gl/directionallight.h>
 #include <msp/gl/pointlight.h>
 #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<GL::SequenceTemplate>(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<GL::Sequence>(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<GL::ColorCurve> colorcurve = make_unique<GL::ColorCurve>();
+               colorcurve->set_srgb();
+               sequence->add_postprocessor(*colorcurve);
+               sequence->add_owned(colorcurve.release());
+
+               view.set_content(sequence.get());
        }
 }
 
index 54d13653189f9349c01f270b3a074bcd22c1f117..23ea5b4a247276b304792663768d41feac3ba1ad 100644 (file)
@@ -38,7 +38,6 @@ private:
        GL::Lighting lighting;
        Game::Handle<Game::Camera> active_camera;
        GL::Camera gl_camera;
-       std::string current_seq_name;
        std::unique_ptr<GL::Sequence> sequence;
 
 public: