X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Frender%2Fsequence.cpp;h=4ccf540809d4a3138f4e30e3d23a0ca3e0e35370;hb=18fda5b5a13215c500cb402f7d2b081e439a1f0e;hp=254a6c462abcbdc01aa232a104c05cf5380db269;hpb=ff8a8bfa114a690b7b25d9503bb5ed811d6aeca9;p=libs%2Fgl.git diff --git a/source/render/sequence.cpp b/source/render/sequence.cpp index 254a6c46..4ccf5408 100644 --- a/source/render/sequence.cpp +++ b/source/render/sequence.cpp @@ -1,10 +1,9 @@ -#include -#include "blend.h" +#include #include "error.h" -#include "framebuffer.h" #include "lighting.h" #include "postprocessor.h" #include "renderer.h" +#include "rendertarget.h" #include "sequence.h" #include "texture2d.h" @@ -13,20 +12,12 @@ using namespace std; namespace Msp { namespace GL { -Sequence::Sequence(): - width(0), - height(0), - target{0, 0}, - target_ms(0), - clear_enabled(false) -{ } +Tag Sequence::noclear_tag = "noclear"; Sequence::Sequence(unsigned w, unsigned h, const FrameFormat &f): width(w), height(h), - target_format(f), - target_ms(0), - clear_enabled(false) + target_format(f) { if(target_format.empty()) throw invalid_argument("Sequence::Sequence"); @@ -55,6 +46,24 @@ void Sequence::set_clear_enabled(bool c) clear_enabled = c; } +void Sequence::set_clear_colors(const vector &c) +{ + clear_enabled = true; + clear_colors = c; +} + +void Sequence::set_clear_depth(float d) +{ + clear_enabled = true; + clear_depth = d; +} + +void Sequence::set_clear_stencil(int s) +{ + clear_enabled = true; + clear_stencil = s; +} + Sequence::Step &Sequence::add_step(Tag tag, Renderable &r) { steps.push_back(Step(tag, &r)); @@ -98,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); @@ -108,8 +117,30 @@ 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) - renderer.clear(); + if(clear_enabled && tag!=noclear_tag) + { + const Framebuffer *target_fbo = renderer.get_framebuffer(); + if(!target_fbo) + throw invalid_operation("Sequence::render"); + + const FrameFormat &format = target_fbo->get_format(); + ClearValue clear_values[7]; + unsigned i = 0; + Color default_color = (clear_colors.empty() ? Color(0.0f, 0.0f, 0.0f, 0.0f) : clear_colors.front()); + ClearValue *cv = clear_values; + for(FrameAttachment a: format) + { + if(get_attach_point(a)==get_attach_point(DEPTH_ATTACHMENT)) + cv->depth_stencil.depth = clear_depth; + else if(get_attach_point(a)==get_attach_point(STENCIL_ATTACHMENT)) + cv->depth_stencil.stencil = clear_stencil; + else + cv->color = (iget_shader_data()); - renderer.set_clipping(s.get_clipping()); if(const Renderable *renderable = s.get_renderable()) renderer.render(*renderable, s.get_tag()); @@ -130,7 +159,7 @@ void Sequence::render(Renderer &renderer, Tag tag) const if(target[0]) { if(target_ms) - renderer.resolve_multisample(target[0]->get_framebuffer(), COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT); + renderer.resolve_multisample(target[0]->get_framebuffer()); renderer.set_depth_test(0); renderer.set_stencil_test(0); @@ -164,7 +193,6 @@ void Sequence::set_debug_name(const string &name) Sequence::Step::Step(Tag t, Renderable *r): tag(t), lighting(0), - clipping(0), renderable(r) { } @@ -183,15 +211,5 @@ void Sequence::Step::set_stencil_test(const StencilTest &st) stencil_test = st; } -void Sequence::Step::set_blend(const Blend &b) -{ - blend = b; -} - -void Sequence::Step::set_clipping(const Clipping *c) -{ - clipping = c; -} - } // namespace GL } // namespace Msp