From: Mikko Rasa Date: Sun, 9 Feb 2020 22:00:26 +0000 (+0200) Subject: Add a function to clear all FBO component buffers X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=8697b05bf71c49882fe15d53aa4f502aa2b5f9a3;p=libs%2Fgl.git Add a function to clear all FBO component buffers --- 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);