From 8697b05bf71c49882fe15d53aa4f502aa2b5f9a3 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 10 Feb 2020 00:00:26 +0200 Subject: [PATCH] Add a function to clear all FBO component buffers --- source/environmentmap.cpp | 2 +- source/framebuffer.cpp | 5 +++++ source/framebuffer.h | 1 + source/pipeline.cpp | 2 +- source/view.cpp | 2 +- 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/source/environmentmap.cpp b/source/environmentmap.cpp index 1cc58914..bf2a6359 100644 --- a/source/environmentmap.cpp +++ b/source/environmentmap.cpp @@ -82,7 +82,7 @@ void EnvironmentMap::setup_frame(Renderer &renderer) { TextureCubeFace face = TextureCube::enumerate_faces(i); fbo[i].bind(); - fbo[i].clear(COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT); + fbo[i].clear(); camera.set_look_direction(env_tex.get_face_direction(face)); camera.set_up_direction(env_tex.get_t_direction(face)); renderer.set_camera(camera); diff --git a/source/framebuffer.cpp b/source/framebuffer.cpp index 659b14e7..c90bb224 100644 --- a/source/framebuffer.cpp +++ b/source/framebuffer.cpp @@ -308,6 +308,11 @@ void Framebuffer::reset_viewport() viewport(0, 0, width, height); } +void Framebuffer::clear() +{ + clear(COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT|STENCIL_BUFFER_BIT); +} + void Framebuffer::clear(BufferBits bits) { BindRestore _bind(this); diff --git a/source/framebuffer.h b/source/framebuffer.h index f977ad7e..3054bd64 100644 --- a/source/framebuffer.h +++ b/source/framebuffer.h @@ -138,6 +138,7 @@ public: void viewport(int, int, unsigned, unsigned); void reset_viewport(); + void clear(); void clear(BufferBits); /** Blits a region from another framebuffer into this one. If the source diff --git a/source/pipeline.cpp b/source/pipeline.cpp index b98ddb8a..02ccc22e 100644 --- a/source/pipeline.cpp +++ b/source/pipeline.cpp @@ -171,7 +171,7 @@ void Pipeline::render(Renderer &renderer, const Tag &tag) const { Framebuffer &fbo = (samples ? target_ms : target[0])->get_framebuffer(); fbo.bind(); - fbo.clear(COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT); + fbo.clear(); } for(PassList::const_iterator i=passes.begin(); i!=passes.end(); ++i) diff --git a/source/view.cpp b/source/view.cpp index 19d583ae..005904f2 100644 --- a/source/view.cpp +++ b/source/view.cpp @@ -40,7 +40,7 @@ void View::render() void View::render(Renderer &renderer) { Bind bind_fbo(target); - target.clear(COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT); + target.clear(); if(content) { Renderer::Push push(renderer); -- 2.43.0