diff options
author | Juan Linietsky <reduzio@gmail.com> | 2019-01-27 15:47:17 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2019-01-27 15:47:17 -0300 |
commit | 953cd03ea6ee9fd6d0d3fde9658777cc4020d0a7 (patch) | |
tree | 9b3f84f26d0f1a9a80805815c5708a17555da794 /drivers | |
parent | 70d6d0fa69c36cd9a673bc313c711814dc79a4f4 (diff) |
Use transparent framebuffer only when set to transparent, closes #21827
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gles2/rasterizer_canvas_gles2.cpp | 7 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_canvas_gles3.cpp | 8 |
2 files changed, 13 insertions, 2 deletions
diff --git a/drivers/gles2/rasterizer_canvas_gles2.cpp b/drivers/gles2/rasterizer_canvas_gles2.cpp index 6f686690bf..64e4dbdab4 100644 --- a/drivers/gles2/rasterizer_canvas_gles2.cpp +++ b/drivers/gles2/rasterizer_canvas_gles2.cpp @@ -112,9 +112,11 @@ void RasterizerCanvasGLES2::_set_uniforms() { void RasterizerCanvasGLES2::canvas_begin() { state.canvas_shader.bind(); + bool transparent = false; if (storage->frame.current_rt) { glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->fbo); glColorMask(1, 1, 1, 1); + transparent = storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]; } if (storage->frame.clear_request) { @@ -122,11 +124,13 @@ void RasterizerCanvasGLES2::canvas_begin() { glClearColor(storage->frame.clear_request_color.r, storage->frame.clear_request_color.g, storage->frame.clear_request_color.b, - storage->frame.clear_request_color.a); + transparent ? storage->frame.clear_request_color.a : 1.0); glClear(GL_COLOR_BUFFER_BIT); storage->frame.clear_request = false; } + glColorMask(1, 1, 1, transparent ? 1 : 0); + /* if (storage->frame.current_rt) { glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->fbo); @@ -182,6 +186,7 @@ void RasterizerCanvasGLES2::canvas_end() { state.using_texture_rect = false; state.using_skeleton = false; state.using_ninepatch = false; + glColorMask(1, 1, 1, 1); } RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(const RID &p_texture, const RID &p_normal_map) { diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index 79fec63db0..b8f0965af8 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -146,10 +146,15 @@ void RasterizerCanvasGLES3::canvas_begin() { if (storage->frame.current_rt && storage->frame.clear_request) { // a clear request may be pending, so do it + bool transparent = storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]; - glClearColor(storage->frame.clear_request_color.r, storage->frame.clear_request_color.g, storage->frame.clear_request_color.b, storage->frame.clear_request_color.a); + glClearColor(storage->frame.clear_request_color.r, + storage->frame.clear_request_color.g, + storage->frame.clear_request_color.b, + transparent ? storage->frame.clear_request_color.a : 1.0); glClear(GL_COLOR_BUFFER_BIT); storage->frame.clear_request = false; + glColorMask(1, 1, 1, transparent ? 1 : 0); } reset_canvas(); @@ -193,6 +198,7 @@ void RasterizerCanvasGLES3::canvas_end() { glBindVertexArray(0); glBindBufferBase(GL_UNIFORM_BUFFER, 0, 0); + glColorMask(1, 1, 1, 1); state.using_texture_rect = false; state.using_ninepatch = false; |