summaryrefslogtreecommitdiff
path: root/servers/visual
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-02-21 10:41:53 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-02-21 10:41:53 -0300
commit57183a778367b1b6e846e188ce3549c6f6c4fea9 (patch)
tree4789b091847c52c1536b2c939e9decc7c50ca44d /servers/visual
parent31e076d16affca682e956c966c0a8f9218a2b192 (diff)
parentf4312a5076061862908c6df732157d452c2d37b8 (diff)
Merge pull request #1410 from romulox-x/viewport_clear
added option to disable automatic clearing of viewport render buffer
Diffstat (limited to 'servers/visual')
-rw-r--r--servers/visual/visual_server_raster.cpp31
-rw-r--r--servers/visual/visual_server_raster.h7
-rw-r--r--servers/visual/visual_server_wrap_mt.h4
3 files changed, 40 insertions, 2 deletions
diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp
index cef6fe567d..4c12ac9670 100644
--- a/servers/visual/visual_server_raster.cpp
+++ b/servers/visual/visual_server_raster.cpp
@@ -1576,6 +1576,15 @@ void VisualServerRaster::viewport_set_render_target_vflip(RID p_viewport,bool p_
}
+void VisualServerRaster::viewport_set_render_target_clear_on_new_frame(RID p_viewport,bool p_enable) {
+
+ Viewport *viewport = viewport_owner.get( p_viewport );
+ ERR_FAIL_COND(!viewport);
+
+ viewport->render_target_clear_on_new_frame=p_enable;
+
+}
+
void VisualServerRaster::viewport_set_render_target_to_screen_rect(RID p_viewport,const Rect2& p_rect) {
Viewport *viewport = viewport_owner.get( p_viewport );
@@ -1594,6 +1603,23 @@ bool VisualServerRaster::viewport_get_render_target_vflip(RID p_viewport) const{
}
+bool VisualServerRaster::viewport_get_render_target_clear_on_new_frame(RID p_viewport) const{
+
+ const Viewport *viewport = viewport_owner.get( p_viewport );
+ ERR_FAIL_COND_V(!viewport,false);
+
+ return viewport->render_target_clear_on_new_frame;
+
+}
+
+void VisualServerRaster::viewport_render_target_clear(RID p_viewport) {
+
+ Viewport *viewport = viewport_owner.get( p_viewport );
+ ERR_FAIL_COND(!viewport);
+
+ viewport->render_target_clear=true;
+
+}
void VisualServerRaster::viewport_queue_screen_capture(RID p_viewport) {
@@ -6605,7 +6631,10 @@ void VisualServerRaster::_draw_viewport(Viewport *p_viewport,int p_ofs_x, int p_
} else if (true /*|| !p_viewport->canvas_list.empty()*/){
//clear the viewport black because of no camera? i seriously should..
- rasterizer->clear_viewport(clear_color);
+ if (p_viewport->render_target_clear_on_new_frame || p_viewport->render_target_clear) {
+ rasterizer->clear_viewport(clear_color);
+ p_viewport->render_target_clear=false;
+ }
}
if (!p_viewport->hide_canvas) {
diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h
index eec677068e..78a4e77170 100644
--- a/servers/visual/visual_server_raster.h
+++ b/servers/visual/visual_server_raster.h
@@ -468,6 +468,8 @@ class VisualServerRaster : public VisualServer {
bool transparent_bg;
bool queue_capture;
bool render_target_vflip;
+ bool render_target_clear_on_new_frame;
+ bool render_target_clear;
Image capture;
bool rendered_in_prev_frame;
@@ -494,7 +496,7 @@ class VisualServerRaster : public VisualServer {
SelfList<Viewport> update_list;
- Viewport() : update_list(this) { transparent_bg=false; render_target_update_mode=RENDER_TARGET_UPDATE_WHEN_VISIBLE; queue_capture=false; rendered_in_prev_frame=false; render_target_vflip=false;}
+ Viewport() : update_list(this) { transparent_bg=false; render_target_update_mode=RENDER_TARGET_UPDATE_WHEN_VISIBLE; queue_capture=false; rendered_in_prev_frame=false; render_target_vflip=false; render_target_clear_on_new_frame=true; render_target_clear=true;}
};
SelfList<Viewport>::List viewport_update_list;
@@ -957,6 +959,9 @@ public:
virtual RID viewport_get_render_target_texture(RID p_viewport) const;
virtual void viewport_set_render_target_vflip(RID p_viewport,bool p_enable);
virtual bool viewport_get_render_target_vflip(RID p_viewport) const;
+ virtual void viewport_set_render_target_clear_on_new_frame(RID p_viewport,bool p_enable);
+ virtual bool viewport_get_render_target_clear_on_new_frame(RID p_viewport) const;
+ virtual void viewport_render_target_clear(RID p_viewport);
virtual void viewport_set_render_target_to_screen_rect(RID p_viewport,const Rect2& p_rect);
virtual void viewport_queue_screen_capture(RID p_viewport);
diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h
index c94425c586..cb69f79cbc 100644
--- a/servers/visual/visual_server_wrap_mt.h
+++ b/servers/visual/visual_server_wrap_mt.h
@@ -967,6 +967,10 @@ public:
FUNC2(viewport_set_render_target_vflip,RID,bool);
FUNC1RC(bool,viewport_get_render_target_vflip,RID);
FUNC2(viewport_set_render_target_to_screen_rect,RID,const Rect2&);
+
+ FUNC2(viewport_set_render_target_clear_on_new_frame,RID,bool);
+ FUNC1RC(bool,viewport_get_render_target_clear_on_new_frame,RID);
+ FUNC1(viewport_render_target_clear,RID);
FUNC1(viewport_queue_screen_capture,RID);
FUNC1RC(Image,viewport_get_screen_capture,RID);