diff options
Diffstat (limited to 'servers')
-rw-r--r-- | servers/audio/audio_server_sw.cpp | 2 | ||||
-rw-r--r-- | servers/physics_2d/physics_2d_server_sw.cpp | 2 | ||||
-rw-r--r-- | servers/visual/rasterizer.h | 3 | ||||
-rw-r--r-- | servers/visual/rasterizer_dummy.cpp | 8 | ||||
-rw-r--r-- | servers/visual/rasterizer_dummy.h | 3 | ||||
-rw-r--r-- | servers/visual/visual_server_raster.cpp | 74 | ||||
-rw-r--r-- | servers/visual/visual_server_raster.h | 9 | ||||
-rw-r--r-- | servers/visual/visual_server_wrap_mt.h | 4 | ||||
-rw-r--r-- | servers/visual_server.h | 6 |
9 files changed, 101 insertions, 10 deletions
diff --git a/servers/audio/audio_server_sw.cpp b/servers/audio/audio_server_sw.cpp index 069bc414f9..cb08024851 100644 --- a/servers/audio/audio_server_sw.cpp +++ b/servers/audio/audio_server_sw.cpp @@ -927,7 +927,7 @@ AudioServerSW::AudioServerSW(SampleManagerSW *p_sample_manager) { sample_manager=p_sample_manager; String interp = GLOBAL_DEF("audio/mixer_interp","linear"); - Globals::get_singleton()->set_custom_property_info("audio/mixer",PropertyInfo(Variant::STRING,"audio/mixer",PROPERTY_HINT_ENUM,"raw,linear,cubic")); + Globals::get_singleton()->set_custom_property_info("audio/mixer_interp",PropertyInfo(Variant::STRING,"audio/mixer_interp",PROPERTY_HINT_ENUM,"raw,linear,cubic")); if (interp=="raw") mixer_interp=AudioMixerSW::INTERPOLATION_RAW; else if (interp=="cubic") diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp index fd1ea579f0..ee29d3aeff 100644 --- a/servers/physics_2d/physics_2d_server_sw.cpp +++ b/servers/physics_2d/physics_2d_server_sw.cpp @@ -770,7 +770,7 @@ void Physics2DServerSW::body_remove_collision_exception(RID p_body, RID p_body_b Body2DSW *body = body_owner.get(p_body); ERR_FAIL_COND(!body); - body->remove_exception(p_body); + body->remove_exception(p_body_b); }; diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 83031e981a..0b54fec859 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -444,7 +444,7 @@ public: virtual void begin_frame()=0; virtual void set_viewport(const VS::ViewportRect& p_viewport)=0; - virtual void set_render_target(RID p_render_target)=0; + virtual void set_render_target(RID p_render_target,bool p_transparent_bg=false,bool p_vflip=false)=0; virtual void clear_viewport(const Color& p_color)=0; virtual void capture_viewport(Image* r_capture)=0; @@ -494,6 +494,7 @@ public: }; virtual void canvas_begin()=0; + virtual void canvas_disable_blending()=0; virtual void canvas_set_opacity(float p_opacity)=0; virtual void canvas_set_blend_mode(VS::MaterialBlendMode p_mode)=0; virtual void canvas_begin_rect(const Matrix32& p_transform)=0;; diff --git a/servers/visual/rasterizer_dummy.cpp b/servers/visual/rasterizer_dummy.cpp index 694d365d79..bfb427f2e8 100644 --- a/servers/visual/rasterizer_dummy.cpp +++ b/servers/visual/rasterizer_dummy.cpp @@ -1384,7 +1384,7 @@ void RasterizerDummy::set_viewport(const VS::ViewportRect& p_viewport) { } -void RasterizerDummy::set_render_target(RID p_render_target) { +void RasterizerDummy::set_render_target(RID p_render_target, bool p_transparent_bg, bool p_vflip) { } @@ -1455,6 +1455,12 @@ void RasterizerDummy::canvas_begin() { } +void RasterizerDummy::canvas_disable_blending() { + + + +} + void RasterizerDummy::canvas_set_opacity(float p_opacity) { diff --git a/servers/visual/rasterizer_dummy.h b/servers/visual/rasterizer_dummy.h index 7ae03a1c0b..e1fa521284 100644 --- a/servers/visual/rasterizer_dummy.h +++ b/servers/visual/rasterizer_dummy.h @@ -627,7 +627,7 @@ public: virtual void begin_frame(); virtual void set_viewport(const VS::ViewportRect& p_viewport); - virtual void set_render_target(RID p_render_target); + virtual void set_render_target(RID p_render_target,bool p_transparent_bg=false,bool p_vflip=false); virtual void clear_viewport(const Color& p_color); virtual void capture_viewport(Image* r_capture); @@ -652,6 +652,7 @@ public: /* CANVAS API */ virtual void canvas_begin(); + virtual void canvas_disable_blending(); virtual void canvas_set_opacity(float p_opacity); virtual void canvas_set_blend_mode(VS::MaterialBlendMode p_mode); virtual void canvas_begin_rect(const Matrix32& p_transform); diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp index 42b8d484b5..2108e5b9c2 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/visual/visual_server_raster.cpp @@ -1111,12 +1111,12 @@ void VisualServerRaster::viewport_set_render_target_update_mode(RID p_viewport,R Viewport *viewport = viewport_owner.get( p_viewport ); ERR_FAIL_COND(!viewport); - if (viewport->update_list.in_list()) + if (viewport->render_target.is_valid() && viewport->update_list.in_list()) viewport_update_list.remove(&viewport->update_list); viewport->render_target_update_mode=p_mode; - if (viewport->render_target_update_mode!=RENDER_TARGET_UPDATE_DISABLED) + if (viewport->render_target.is_valid() &&viewport->render_target_update_mode!=RENDER_TARGET_UPDATE_DISABLED) viewport_update_list.add(&viewport->update_list); } @@ -1136,6 +1136,34 @@ RID VisualServerRaster::viewport_get_render_target_texture(RID p_viewport) const } +void VisualServerRaster::viewport_set_render_target_vflip(RID p_viewport,bool p_enable) { + + Viewport *viewport = viewport_owner.get( p_viewport ); + ERR_FAIL_COND(!viewport); + + viewport->render_target_vflip=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 ); + ERR_FAIL_COND(!viewport); + + viewport->rt_to_screen_rect=p_rect; + +} + +bool VisualServerRaster::viewport_get_render_target_vflip(RID p_viewport) const{ + + const Viewport *viewport = viewport_owner.get( p_viewport ); + ERR_FAIL_COND_V(!viewport,false); + + return viewport->render_target_vflip; + +} + + void VisualServerRaster::viewport_queue_screen_capture(RID p_viewport) { VS_CHANGED; @@ -1164,6 +1192,9 @@ void VisualServerRaster::viewport_set_rect(RID p_viewport,const ViewportRect& p_ ERR_FAIL_COND(!viewport); viewport->rect=p_rect; + if (viewport->render_target.is_valid()) { + rasterizer->render_target_set_size(viewport->render_target,viewport->rect.width,viewport->rect.height); + } } @@ -5436,6 +5467,8 @@ void VisualServerRaster::_draw_viewport(Viewport *p_viewport,int p_ofs_x, int p_ void VisualServerRaster::_draw_viewports() { //draw viewports for render targets + + List<Viewport*> to_blit; List<Viewport*> to_disable; for(SelfList<Viewport> *E=viewport_update_list.first();E;E=E->next()) { @@ -5450,7 +5483,10 @@ void VisualServerRaster::_draw_viewports() { continue; } - rasterizer->set_render_target(vp->render_target); + if (vp->rt_to_screen_rect!=Rect2()) + to_blit.push_back(vp); + + rasterizer->set_render_target(vp->render_target,vp->transparent_bg,vp->render_target_vflip); _draw_viewport(vp,0,0,vp->rect.width,vp->rect.height); if ( (vp->queue_capture && vp->render_target_update_mode==RENDER_TARGET_UPDATE_DISABLED) || vp->render_target_update_mode==RENDER_TARGET_UPDATE_ONCE) { @@ -5469,6 +5505,38 @@ void VisualServerRaster::_draw_viewports() { to_disable.pop_front(); } + + //draw RTs directly to screen when requested + + for (List<Viewport*>::Element *E=to_blit.front();E;E=E->next()) { + + int window_w = OS::get_singleton()->get_video_mode().width; + int window_h = OS::get_singleton()->get_video_mode().height; + + ViewportRect desired_rect; + desired_rect.x = desired_rect.y = 0; + desired_rect.width = window_w; + desired_rect.height = window_h; + + if ( viewport_rect.x != desired_rect.x || + viewport_rect.y != desired_rect.y || + viewport_rect.width != desired_rect.width || + viewport_rect.height != desired_rect.height ) { + + viewport_rect=desired_rect; + + rasterizer->set_viewport(viewport_rect); + } + + rasterizer->canvas_begin(); + rasterizer->canvas_disable_blending(); + rasterizer->canvas_begin_rect(Matrix32()); + rasterizer->canvas_draw_rect(E->get()->rt_to_screen_rect,0,Rect2(Point2(),E->get()->rt_to_screen_rect.size),E->get()->render_target_texture,Color(1,1,1)); + + } + + + //draw viewports attached to screen for(Map<RID,int>::Element *E=screen_viewports.front();E;E=E->next()) { diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index f0b3a2d13c..d3d504a7c6 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -481,11 +481,13 @@ class VisualServerRaster : public VisualServer { RID render_target; RID render_target_texture; + Rect2 rt_to_screen_rect; + bool hide_scenario; bool hide_canvas; bool transparent_bg; - bool queue_capture; + bool render_target_vflip; Image capture; bool rendered_in_prev_frame; @@ -512,7 +514,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;} + 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;} }; SelfList<Viewport>::List viewport_update_list; @@ -911,6 +913,9 @@ public: virtual void viewport_set_render_target_update_mode(RID p_viewport,RenderTargetUpdateMode p_mode); virtual RenderTargetUpdateMode viewport_get_render_target_update_mode(RID p_viewport) const; 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_to_screen_rect(RID p_viewport,const Rect2& p_rect); virtual void viewport_queue_screen_capture(RID p_viewport); virtual Image viewport_get_screen_capture(RID p_viewport) const; diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index 3a6a3e509a..c8f00c3786 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -889,6 +889,10 @@ public: FUNC1RC(RenderTargetUpdateMode,viewport_get_render_target_update_mode,RID); FUNC1RC(RID,viewport_get_render_target_texture,RID); + 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&); + FUNC1(viewport_queue_screen_capture,RID); FUNC1RC(Image,viewport_get_screen_capture,RID); diff --git a/servers/visual_server.h b/servers/visual_server.h index b3922ab4fc..4cf0c96228 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -592,6 +592,7 @@ public: virtual void viewport_attach_to_screen(RID p_viewport,int p_screen=0)=0; virtual void viewport_detach(RID p_viewport)=0; + virtual void viewport_set_render_target_to_screen_rect(RID p_viewport,const Rect2& p_rect)=0; enum RenderTargetUpdateMode { RENDER_TARGET_UPDATE_DISABLED, @@ -600,14 +601,19 @@ public: RENDER_TARGET_UPDATE_ALWAYS }; + virtual void viewport_set_as_render_target(RID p_viewport,bool p_enable)=0; virtual void viewport_set_render_target_update_mode(RID p_viewport,RenderTargetUpdateMode p_mode)=0; virtual RenderTargetUpdateMode viewport_get_render_target_update_mode(RID p_viewport) const=0; 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_queue_screen_capture(RID p_viewport)=0; virtual Image viewport_get_screen_capture(RID p_viewport) const=0; + + struct ViewportRect { int x,y,width,height; |