]> git.tdb.fi Git - libs/gl.git/commitdiff
Allow suppressing clear in a sequence by passing in a special tag
authorMikko Rasa <tdb@tdb.fi>
Mon, 11 Oct 2021 12:25:52 +0000 (15:25 +0300)
committerMikko Rasa <tdb@tdb.fi>
Mon, 11 Oct 2021 12:25:52 +0000 (15:25 +0300)
Sequence doesn't pass on the tag it receives, so it can be used to
control the sequence's own behaviour instead.

source/render/sequence.cpp
source/render/sequence.h

index e0fb408fad95aa274d63171c5b8f5b012c56d50a..f7dea9bf617ebf1db173fec541408b0735b4989b 100644 (file)
@@ -12,6 +12,8 @@ using namespace std;
 namespace Msp {
 namespace GL {
 
+Tag Sequence::noclear_tag = "noclear";
+
 Sequence::Sequence(unsigned w, unsigned h, const FrameFormat &f):
        width(w),
        height(h),
@@ -105,7 +107,7 @@ void Sequence::finish_frame()
 
 void Sequence::render(Renderer &renderer, Tag tag) const
 {
-       if(tag.id)
+       if(tag.id && tag!=noclear_tag)
                return;
 
        Renderer::Push _push(renderer);
@@ -115,7 +117,7 @@ void Sequence::render(Renderer &renderer, Tag tag) const
        if(target[0])
                renderer.set_framebuffer(&(target_ms ? target_ms : target[0])->get_framebuffer());
 
-       if(clear_enabled)
+       if(clear_enabled && tag!=noclear_tag)
        {
                const Framebuffer *target_fbo = renderer.get_framebuffer();
                if(!target_fbo)
index 9a3d0207191bb79e5ca9f6e9614440aeee75d4c9..efead27f98e9fcc45490ba5dffff351666c598f9 100644 (file)
@@ -79,6 +79,8 @@ private:
        float clear_depth = 1.0f;
        int clear_stencil = 0;
 
+       static Tag noclear_tag;
+
 public:
        Sequence() = default;
        Sequence(unsigned, unsigned, const FrameFormat &);