diff options
Diffstat (limited to 'scene/main')
-rw-r--r-- | scene/main/viewport.cpp | 36 | ||||
-rw-r--r-- | scene/main/viewport.h | 27 |
2 files changed, 63 insertions, 0 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 95fad83a28..763cac2af4 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -2530,6 +2530,22 @@ Viewport::Usage Viewport::get_usage() const { return usage; } +void Viewport::set_debug_draw(DebugDraw p_debug_draw) { + + debug_draw = p_debug_draw; + VS::get_singleton()->viewport_set_debug_draw(viewport, VS::ViewportDebugDraw(p_debug_draw)); +} + +Viewport::DebugDraw Viewport::get_debug_draw() const { + + return debug_draw; +} + +int Viewport::get_render_info(RenderInfo p_info) { + + return VS::get_singleton()->viewport_get_render_info(viewport, VS::ViewportRenderInfo(p_info)); +} + void Viewport::_bind_methods() { ClassDB::bind_method(D_METHOD("set_size", "size"), &Viewport::set_size); @@ -2586,6 +2602,11 @@ void Viewport::_bind_methods() { ClassDB::bind_method(D_METHOD("set_usage", "usage"), &Viewport::set_usage); ClassDB::bind_method(D_METHOD("get_usage"), &Viewport::get_usage); + ClassDB::bind_method(D_METHOD("set_debug_draw", "debug_draw"), &Viewport::set_debug_draw); + ClassDB::bind_method(D_METHOD("get_debug_draw"), &Viewport::get_debug_draw); + + ClassDB::bind_method(D_METHOD("get_render_info", "info"), &Viewport::get_render_info); + ClassDB::bind_method(D_METHOD("get_texture:ViewportTexture"), &Viewport::get_texture); ClassDB::bind_method(D_METHOD("set_physics_object_picking", "enable"), &Viewport::set_physics_object_picking); @@ -2640,6 +2661,7 @@ void Viewport::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hdr"), "set_hdr", "get_hdr"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disable_3d"), "set_disable_3d", "is_3d_disabled"); ADD_PROPERTY(PropertyInfo(Variant::INT, "usage", PROPERTY_HINT_ENUM, "2D,2D No-Sampling,3D,3D No-Effects"), "set_usage", "get_usage"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "debug_draw", PROPERTY_HINT_ENUM, "Disabled,Unshaded,Overdraw,Wireframe"), "set_debug_draw", "get_debug_draw"); ADD_GROUP("Render Target", "render_target_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "render_target_v_flip"), "set_vflip", "get_vflip"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "render_target_clear_on_new_frame"), "set_clear_on_new_frame", "get_clear_on_new_frame"); @@ -2674,6 +2696,19 @@ void Viewport::_bind_methods() { BIND_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_1024); BIND_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_MAX); + BIND_CONSTANT(RENDER_INFO_OBJECTS_IN_FRAME); + BIND_CONSTANT(RENDER_INFO_VERTICES_IN_FRAME); + BIND_CONSTANT(RENDER_INFO_MATERIAL_CHANGES_IN_FRAME); + BIND_CONSTANT(RENDER_INFO_SHADER_CHANGES_IN_FRAME); + BIND_CONSTANT(RENDER_INFO_SURFACE_CHANGES_IN_FRAME); + BIND_CONSTANT(RENDER_INFO_DRAW_CALLS_IN_FRAME); + BIND_CONSTANT(RENDER_INFO_MAX); + + BIND_CONSTANT(DEBUG_DRAW_DISABLED); + BIND_CONSTANT(DEBUG_DRAW_UNSHADED); + BIND_CONSTANT(DEBUG_DRAW_OVERDRAW); + BIND_CONSTANT(DEBUG_DRAW_WIREFRAME); + BIND_CONSTANT(MSAA_DISABLED); BIND_CONSTANT(MSAA_2X); BIND_CONSTANT(MSAA_4X); @@ -2750,6 +2785,7 @@ Viewport::Viewport() { hdr = false; usage = USAGE_3D; + debug_draw = DEBUG_DRAW_DISABLED; } Viewport::~Viewport() { diff --git a/scene/main/viewport.h b/scene/main/viewport.h index e619199424..378055bef5 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -122,6 +122,24 @@ public: USAGE_3D_NO_EFFECTS, }; + enum RenderInfo { + + RENDER_INFO_OBJECTS_IN_FRAME, + RENDER_INFO_VERTICES_IN_FRAME, + RENDER_INFO_MATERIAL_CHANGES_IN_FRAME, + RENDER_INFO_SHADER_CHANGES_IN_FRAME, + RENDER_INFO_SURFACE_CHANGES_IN_FRAME, + RENDER_INFO_DRAW_CALLS_IN_FRAME, + RENDER_INFO_MAX + }; + + enum DebugDraw { + DEBUG_DRAW_DISABLED, + DEBUG_DRAW_UNSHADED, + DEBUG_DRAW_OVERDRAW, + DEBUG_DRAW_WIREFRAME, + }; + private: friend class ViewportTexture; @@ -204,6 +222,8 @@ private: RID texture_rid; uint32_t texture_flags; + DebugDraw debug_draw; + Usage usage; int shadow_atlas_size; @@ -430,6 +450,11 @@ public: void set_usage(Usage p_usage); Usage get_usage() const; + void set_debug_draw(DebugDraw p_debug_draw); + DebugDraw get_debug_draw() const; + + int get_render_info(RenderInfo p_info); + Viewport(); ~Viewport(); }; @@ -438,5 +463,7 @@ VARIANT_ENUM_CAST(Viewport::UpdateMode); VARIANT_ENUM_CAST(Viewport::ShadowAtlasQuadrantSubdiv); VARIANT_ENUM_CAST(Viewport::MSAA); VARIANT_ENUM_CAST(Viewport::Usage); +VARIANT_ENUM_CAST(Viewport::DebugDraw); +VARIANT_ENUM_CAST(Viewport::RenderInfo); #endif |