summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
authorawsker <asker@sealhunter.com>2022-05-02 11:03:39 +0200
committerawsker <asker@sealhunter.com>2022-05-02 11:03:39 +0200
commit9522419e97607bf1eebf805571baa308dd4f0b26 (patch)
treef1a2e5e1d200729bf7866ac936bfe5fe818ff290 /servers
parent5c52b304713b07f2285047f018560d7492692a2a (diff)
Viewport would be cleared even when clear_mode was set to VIEWPORT_CLEAR_NEVER
Diffstat (limited to 'servers')
-rw-r--r--servers/rendering/renderer_viewport.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp
index 8507e20648..99e8d22b75 100644
--- a/servers/rendering/renderer_viewport.cpp
+++ b/servers/rendering/renderer_viewport.cpp
@@ -195,8 +195,6 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
}
}
- Color bgcolor = RSG::storage->get_default_clear_color();
-
if (!p_viewport->disable_2d && !p_viewport->disable_environment && RSG::scene->is_scenario(p_viewport->scenario)) {
RID environment = RSG::scene->scenario_get_environment(p_viewport->scenario);
if (RSG::scene->is_environment(environment)) {
@@ -207,15 +205,6 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
bool can_draw_3d = RSG::scene->is_camera(p_viewport->camera) && !p_viewport->disable_3d;
- if (p_viewport->clear_mode != RS::VIEWPORT_CLEAR_NEVER) {
- if (p_viewport->transparent_bg) {
- bgcolor = Color(0, 0, 0, 0);
- }
- if (p_viewport->clear_mode == RS::VIEWPORT_CLEAR_ONLY_NEXT_FRAME) {
- p_viewport->clear_mode = RS::VIEWPORT_CLEAR_NEVER;
- }
- }
-
if ((scenario_draw_canvas_bg || can_draw_3d) && !p_viewport->render_buffers.is_valid()) {
//wants to draw 3D but there is no render buffer, create
p_viewport->render_buffers = RSG::scene->render_buffers_create();
@@ -223,7 +212,14 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
_configure_3d_render_buffers(p_viewport);
}
- RSG::texture_storage->render_target_request_clear(p_viewport->render_target, bgcolor);
+ Color bgcolor = p_viewport->transparent_bg ? Color(0, 0, 0, 0) : RSG::storage->get_default_clear_color();
+
+ if (p_viewport->clear_mode != RS::VIEWPORT_CLEAR_NEVER) {
+ RSG::texture_storage->render_target_request_clear(p_viewport->render_target, bgcolor);
+ if (p_viewport->clear_mode == RS::VIEWPORT_CLEAR_ONLY_NEXT_FRAME) {
+ p_viewport->clear_mode = RS::VIEWPORT_CLEAR_NEVER;
+ }
+ }
if (!scenario_draw_canvas_bg && can_draw_3d) {
_draw_3d(p_viewport);