diff options
Diffstat (limited to 'servers')
-rw-r--r-- | servers/visual/rasterizer.h | 1 | ||||
-rw-r--r-- | servers/visual/visual_server_raster.h | 3 | ||||
-rw-r--r-- | servers/visual/visual_server_viewport.cpp | 41 | ||||
-rw-r--r-- | servers/visual/visual_server_viewport.h | 27 | ||||
-rw-r--r-- | servers/visual_server.h | 5 |
5 files changed, 61 insertions, 16 deletions
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 6a6eb7ad20..865298f64e 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -233,7 +233,6 @@ public: virtual RID render_target_create()=0; virtual void render_target_set_size(RID p_render_target,int p_width, int p_height)=0; virtual RID render_target_get_texture(RID p_render_target) const=0; - virtual Image render_target_get_image(RID p_render_target) const=0; virtual void render_target_set_flag(RID p_render_target,RenderTargetFlags p_flag,bool p_value)=0; virtual bool render_target_renedered_in_frame(RID p_render_target)=0; diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index cd6d7b38d3..2171998f3f 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -807,6 +807,7 @@ public: BIND3(viewport_set_size,RID,int ,int ) BIND2(viewport_set_active,RID ,bool ) + BIND2(viewport_set_parent_viewport,RID,RID) BIND2(viewport_set_clear_mode,RID,ViewportClearMode ) @@ -818,11 +819,11 @@ public: BIND1RC(RID,viewport_get_texture,RID ) - BIND1RC(Image,viewport_capture,RID ) BIND2(viewport_set_hide_scenario,RID,bool ) BIND2(viewport_set_hide_canvas,RID,bool ) BIND2(viewport_set_disable_environment,RID,bool ) + BIND2(viewport_set_disable_3d,RID,bool ) BIND2(viewport_attach_camera,RID,RID ) BIND2(viewport_set_scenario,RID,RID ) diff --git a/servers/visual/visual_server_viewport.cpp b/servers/visual/visual_server_viewport.cpp index b30a57a5b8..baf18b7a56 100644 --- a/servers/visual/visual_server_viewport.cpp +++ b/servers/visual/visual_server_viewport.cpp @@ -1,6 +1,7 @@ #include "visual_server_viewport.h" #include "visual_server_global.h" #include "visual_server_canvas.h" +#include "globals.h" void VisualServerViewport::_draw_viewport(Viewport *p_viewport) { @@ -50,7 +51,12 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport) { } #endif - VSG::rasterizer->clear_render_target(Color(0.5,0.5,0.5,1.0)); + if (p_viewport->clear_mode!=VS::VIEWPORT_CLEAR_NEVER) { + VSG::rasterizer->clear_render_target(clear_color); + if (p_viewport->clear_mode==VS::VIEWPORT_CLEAR_ONLY_NEXT_FRAME) { + p_viewport->clear_mode=VS::VIEWPORT_CLEAR_NEVER; + } + } if (!p_viewport->hide_canvas) { int i=0; @@ -161,10 +167,10 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport) { light=light->shadows_next_ptr; } - VSG::rasterizer->restore_render_target(); // VSG::canvas_render->reset_canvas(); } + VSG::rasterizer->restore_render_target(); #if 0 @@ -175,6 +181,8 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport) { } #endif + + for (Map<Viewport::CanvasKey,Viewport::CanvasData*>::Element *E=canvas_map.front();E;E=E->next()) { VisualServerCanvas::Canvas *canvas = static_cast<VisualServerCanvas::Canvas*>(E->get()->canvas); @@ -226,6 +234,10 @@ void VisualServerViewport::draw_viewports() { //draw viewports + clear_color=GLOBAL_DEF("rendering/viewport/default_clear_color",Color(0.5,0.5,0.5)); + + + active_viewports.sort_custom<ViewportSort>(); for(int i=0;i<active_viewports.size();i++) { @@ -297,6 +309,14 @@ void VisualServerViewport::viewport_set_active(RID p_viewport,bool p_active) { } +void VisualServerViewport::viewport_set_parent_viewport(RID p_viewport,RID p_parent_viewport) { + + Viewport * viewport = viewport_owner.getornull(p_viewport); + ERR_FAIL_COND(!viewport); + + viewport->parent=p_parent_viewport; +} + void VisualServerViewport::viewport_set_clear_mode(RID p_viewport,VS::ViewportClearMode p_clear_mode) { Viewport * viewport = viewport_owner.getornull(p_viewport); @@ -350,13 +370,6 @@ RID VisualServerViewport::viewport_get_texture(RID p_viewport) const{ return VSG::storage->render_target_get_texture(viewport->render_target); } -Image VisualServerViewport::viewport_capture(RID p_viewport) const{ - - const Viewport * viewport = viewport_owner.getornull(p_viewport); - ERR_FAIL_COND_V(!viewport,Image()); - return VSG::storage->render_target_get_image(viewport->render_target); - -} void VisualServerViewport::viewport_set_hide_scenario(RID p_viewport,bool p_hide){ @@ -381,6 +394,16 @@ void VisualServerViewport::viewport_set_disable_environment(RID p_viewport,bool viewport->disable_environment=p_disable; } +void VisualServerViewport::viewport_set_disable_3d(RID p_viewport,bool p_disable){ + + Viewport * viewport = viewport_owner.getornull(p_viewport); + ERR_FAIL_COND(!viewport); + + + viewport->disable_3d=p_disable; + VSG::storage->render_target_set_flag(viewport->render_target,RasterizerStorage::RENDER_TARGET_NO_3D,p_disable); +} + void VisualServerViewport::viewport_attach_camera(RID p_viewport,RID p_camera){ Viewport * viewport = viewport_owner.getornull(p_viewport); diff --git a/servers/visual/visual_server_viewport.h b/servers/visual/visual_server_viewport.h index e5c888fbcb..cba33a3b2d 100644 --- a/servers/visual/visual_server_viewport.h +++ b/servers/visual/visual_server_viewport.h @@ -13,6 +13,8 @@ public: }; + + struct Viewport : public RID_Data { RID self; @@ -32,8 +34,8 @@ public: bool hide_scenario; bool hide_canvas; bool disable_environment; + bool disable_3d; - Image capture; VS::ViewportClearMode clear_mode; @@ -70,8 +72,27 @@ public: }; mutable RID_Owner<Viewport> viewport_owner; + + + struct ViewportSort { + _FORCE_INLINE_ bool operator()(const Viewport*p_left,const Viewport* p_right) const { + + bool left_to_screen = p_left->viewport_to_screen_rect.size!=Size2(); + bool right_to_screen = p_right->viewport_to_screen_rect.size!=Size2(); + + if (left_to_screen==right_to_screen) { + + return p_left->parent==p_right->self; + } else { + return right_to_screen; + } + } + }; + + Vector<Viewport*> active_viewports; private: + Color clear_color; void _draw_viewport(Viewport *p_viewport); public: @@ -84,7 +105,7 @@ public: void viewport_detach(RID p_viewport); void viewport_set_active(RID p_viewport,bool p_active); - + void viewport_set_parent_viewport(RID p_viewport,RID p_parent_viewport); void viewport_set_update_mode(RID p_viewport,VS::ViewportUpdateMode p_mode); void viewport_set_vflip(RID p_viewport,bool p_enable); @@ -92,11 +113,11 @@ public: void viewport_set_clear_mode(RID p_viewport,VS::ViewportClearMode p_clear_mode); RID viewport_get_texture(RID p_viewport) const; - Image viewport_capture(RID p_viewport) const; void viewport_set_hide_scenario(RID p_viewport,bool p_hide); void viewport_set_hide_canvas(RID p_viewport,bool p_hide); void viewport_set_disable_environment(RID p_viewport,bool p_disable); + void viewport_set_disable_3d(RID p_viewport,bool p_disable); void viewport_attach_camera(RID p_viewport,RID p_camera); void viewport_set_scenario(RID p_viewport,RID p_scenario); diff --git a/servers/visual_server.h b/servers/visual_server.h index 4eb2b2a5fa..238bcc216d 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -424,6 +424,7 @@ public: virtual void viewport_set_size(RID p_viewport,int p_width,int p_height)=0; virtual void viewport_set_active(RID p_viewport,bool p_active)=0; + virtual void viewport_set_parent_viewport(RID p_viewport,RID p_parent_viewport)=0; virtual void viewport_attach_to_screen(RID p_viewport,const Rect2& p_rect=Rect2(),int p_screen=0)=0; virtual void viewport_detach(RID p_viewport)=0; @@ -442,18 +443,18 @@ public: enum ViewportClearMode { VIEWPORT_CLEAR_ALWAYS, - VIWEPORT_CLEAR_NEVER, + VIEWPORT_CLEAR_NEVER, VIEWPORT_CLEAR_ONLY_NEXT_FRAME }; virtual void viewport_set_clear_mode(RID p_viewport,ViewportClearMode p_clear_mode)=0; virtual RID viewport_get_texture(RID p_viewport) const=0; - virtual Image viewport_capture(RID p_viewport) const=0; virtual void viewport_set_hide_scenario(RID p_viewport,bool p_hide)=0; virtual void viewport_set_hide_canvas(RID p_viewport,bool p_hide)=0; virtual void viewport_set_disable_environment(RID p_viewport,bool p_disable)=0; + virtual void viewport_set_disable_3d(RID p_viewport,bool p_disable)=0; virtual void viewport_attach_camera(RID p_viewport,RID p_camera)=0; virtual void viewport_set_scenario(RID p_viewport,RID p_scenario)=0; |