mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 12:12:28 +00:00
added option to disable automatic clearing of viewport render buffer
This commit is contained in:
parent
31e076d16a
commit
f4312a5076
@ -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) ) );
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -684,6 +684,9 @@ public:
|
||||
virtual RID viewport_get_render_target_texture(RID p_viewport) const=0;
|
||||
virtual void viewport_set_render_target_vflip(RID p_viewport,bool p_enable)=0;
|
||||
virtual bool viewport_get_render_target_vflip(RID p_viewport) const=0;
|
||||
virtual void viewport_set_render_target_clear_on_new_frame(RID p_viewport,bool p_enable)=0;
|
||||
virtual bool viewport_get_render_target_clear_on_new_frame(RID p_viewport) const=0;
|
||||
virtual void viewport_render_target_clear(RID p_viewport)=0;
|
||||
|
||||
virtual void viewport_queue_screen_capture(RID p_viewport)=0;
|
||||
virtual Image viewport_get_screen_capture(RID p_viewport) const=0;
|
||||
|
Loading…
Reference in New Issue
Block a user