Debug Draw 3D (and 2D) 1.5.0
Draw 3D debug graphics and 2D overlays with this add-on.
Loading...
Searching...
No Matches
debug_draw_2d.h
1#pragma once
2
3#include "common/colors.h"
4#include "utils/compiler.h"
5
6#include <memory>
7
8GODOT_WARNING_DISABLE()
9#include <godot_cpp/classes/control.hpp>
10#include <godot_cpp/classes/font.hpp>
11GODOT_WARNING_RESTORE()
12using namespace godot;
13
17class GroupedText;
18
25class DebugDraw2D : public Object {
26 GDCLASS(DebugDraw2D, Object)
27
28 friend DebugDrawManager;
29 static DebugDraw2D *singleton;
30
31private:
32 DebugDrawManager *root_node = nullptr;
33
34 // 2d
35 const static char *s_marked_dirty;
36
37 bool _canvas_need_update = true;
38 Ref<Font> _font;
39 Ref<DebugDraw2DStats> stats_2d;
40
41 Callable call_canvas_item_draw_cache;
42 uint64_t default_control_id = 0;
43
44#ifndef DISABLE_DEBUG_RENDERING
45 std::unique_ptr<GroupedText> grouped_text;
46#endif
47
48#ifndef DISABLE_DEBUG_RENDERING
49 void _finish_frame_and_update();
50 void _clear_all_internal();
51 void _set_custom_canvas_internal(Control *_canvas);
52#endif
53
54 void _on_canvas_item_draw(Control *ci);
55 inline bool _is_enabled_override() const;
56
57 void process_start(double delta);
58 void process_end(double delta);
59 void physics_process_start(double delta);
60 void physics_process_end(double delta);
61
62#pragma region Exposed Parameter Values
63
64 // GENERAL
65
66 bool debug_enabled = true;
67 uint64_t custom_control_id = 0;
68
69 Ref<DebugDraw2DConfig> config;
70
71#pragma endregion // Exposed Parameter Values
72
73protected:
75 static void _bind_methods();
76
77public:
78 DebugDraw2D();
79 ~DebugDraw2D();
80
82 void init(DebugDrawManager *root);
83
87 static DebugDraw2D *get_singleton() {
88 return singleton;
89 };
90
91 void mark_canvas_dirty();
92
94 Node *get_root_node();
95
96#pragma region Exposed Parameters
98 void set_empty_color(const Color &_col);
102 Color get_empty_color() const;
103
107 void set_debug_enabled(const bool &_state);
108 bool is_debug_enabled() const;
109
113 void set_config(Ref<DebugDraw2DConfig> _cfg);
117 Ref<DebugDraw2DConfig> get_config() const;
118
124 void set_custom_canvas(Control *_canvas);
125 Control *get_custom_canvas() const;
126#pragma endregion // Exposed Parametes
127
128#pragma region Exposed Draw Functions
129
135 Ref<DebugDraw2DStats> get_render_stats();
136
140 void clear_all();
141
142#pragma region Text
153 void begin_text_group(String group_title, int group_priority = 0, Color group_color = Colors::white_smoke, bool show_title = true, int title_size = 14, int text_size = 12);
169 void set_text(String key, Variant value = Variant(), int priority = 0, Color color_of_value = Colors::empty_color, real_t duration = -1);
170
175#pragma endregion // Text
176#pragma endregion // Exposed Draw Functions
177};
This is a class for storing part of the DebugDraw2D configuration.
Definition config_2d.h:20
You can get basic statistics about 2D rendering from this class.
Definition stats_2d.h:18
Ref< DebugDraw2DConfig > get_config() const
void set_custom_canvas(Control *_canvas)
void set_debug_enabled(const bool &_state)
Color get_empty_color() const
Ref< DebugDraw2DStats > get_render_stats()
void clear_texts()
void set_text(String key, Variant value=Variant(), int priority=0, Color color_of_value=Colors::empty_color, real_t duration=-1)
void clear_all()
static DebugDraw2D * get_singleton()
Definition debug_draw_2d.h:87
void begin_text_group(String group_title, int group_priority=0, Color group_color=Colors::white_smoke, bool show_title=true, int title_size=14, int text_size=12)
void set_config(Ref< DebugDraw2DConfig > _cfg)
void end_text_group()
The main singleton class that handles DebugDraw2D and DebugDraw3D.
Definition debug_draw_manager.h:54