summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main')
-rw-r--r--scene/main/viewport.cpp24
-rw-r--r--scene/main/viewport.h5
2 files changed, 29 insertions, 0 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index fa163bf96d..02e009866f 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -972,6 +972,22 @@ bool Viewport::get_render_target_vflip() const{
return render_target_vflip;
}
+void Viewport::set_render_target_clear_on_new_frame(bool p_enable) {
+
+ render_target_clear_on_new_frame=p_enable;
+ VisualServer::get_singleton()->viewport_set_render_target_clear_on_new_frame(viewport,p_enable);
+}
+
+bool Viewport::get_render_target_clear_on_new_frame() const{
+
+ return render_target_clear_on_new_frame;
+}
+
+void Viewport::render_target_clear() {
+
+ //render_target_clear=true;
+ VisualServer::get_singleton()->viewport_render_target_clear(viewport);
+}
void Viewport::set_render_target_filter(bool p_enable) {
@@ -1264,6 +1280,11 @@ void Viewport::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_render_target_vflip","enable"), &Viewport::set_render_target_vflip);
ObjectTypeDB::bind_method(_MD("get_render_target_vflip"), &Viewport::get_render_target_vflip);
+
+ ObjectTypeDB::bind_method(_MD("set_render_target_clear_on_new_frame","enable"), &Viewport::set_render_target_clear_on_new_frame);
+ ObjectTypeDB::bind_method(_MD("get_render_target_clear_on_new_frame"), &Viewport::get_render_target_clear_on_new_frame);
+
+ ObjectTypeDB::bind_method(_MD("render_target_clear"), &Viewport::render_target_clear);
ObjectTypeDB::bind_method(_MD("set_render_target_filter","enable"), &Viewport::set_render_target_filter);
ObjectTypeDB::bind_method(_MD("get_render_target_filter"), &Viewport::get_render_target_filter);
@@ -1306,6 +1327,7 @@ void Viewport::_bind_methods() {
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"transparent_bg"), _SCS("set_transparent_background"), _SCS("has_transparent_background") );
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target/enabled"), _SCS("set_as_render_target"), _SCS("is_set_as_render_target") );
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target/v_flip"), _SCS("set_render_target_vflip"), _SCS("get_render_target_vflip") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target/clear_on_new_frame"), _SCS("set_render_target_clear_on_new_frame"), _SCS("get_render_target_clear_on_new_frame") );
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target/filter"), _SCS("set_render_target_filter"), _SCS("get_render_target_filter") );
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target/gen_mipmaps"), _SCS("set_render_target_gen_mipmaps"), _SCS("get_render_target_gen_mipmaps") );
ADD_PROPERTY( PropertyInfo(Variant::INT,"render_target/update_mode",PROPERTY_HINT_ENUM,"Disabled,Once,When Visible,Always"), _SCS("set_render_target_update_mode"), _SCS("get_render_target_update_mode") );
@@ -1344,6 +1366,8 @@ Viewport::Viewport() {
render_target_gen_mipmaps=false;
render_target=false;
render_target_vflip=false;
+ render_target_clear_on_new_frame=true;
+ //render_target_clear=true;
render_target_update_mode=RENDER_TARGET_UPDATE_WHEN_VISIBLE;
render_target_texture = Ref<RenderTargetTexture>( memnew( RenderTargetTexture(this) ) );
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 832a6b6107..d2a22401bd 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -114,6 +114,7 @@ friend class RenderTargetTexture;
bool transparent_bg;
bool render_target_vflip;
+ bool render_target_clear_on_new_frame;
bool render_target_filter;
bool render_target_gen_mipmaps;
@@ -220,6 +221,10 @@ public:
void set_render_target_vflip(bool p_enable);
bool get_render_target_vflip() const;
+ void set_render_target_clear_on_new_frame(bool p_enable);
+ bool get_render_target_clear_on_new_frame() const;
+ void render_target_clear();
+
void set_render_target_filter(bool p_enable);
bool get_render_target_filter() const;