Debug Draw 3D (and 2D) 1.4.5
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
14class DataGraphManager;
19class GroupedText;
20
27class DebugDraw2D : public Object {
28 GDCLASS(DebugDraw2D, Object)
29
30 friend DebugDrawManager;
31 static DebugDraw2D *singleton;
32
33private:
34 DebugDrawManager *root_node = nullptr;
35
36 // 2d
37 const static char *s_marked_dirty;
38
39 bool _is_drawing_frame = true;
40 bool _canvas_need_update = true;
41 Ref<Font> _font;
42 Ref<DebugDraw2DStats> stats_2d;
43
44 Callable call_canvas_item_draw_cache;
45 uint64_t default_control_id = 0;
46
47#ifndef DISABLE_DEBUG_RENDERING
48 std::unique_ptr<GroupedText> grouped_text;
49 std::unique_ptr<DataGraphManager> data_graphs;
50#endif
51
52#ifndef DISABLE_DEBUG_RENDERING
53 void _finish_frame_and_update();
54 void _clear_all_internal();
55 void _set_custom_canvas_internal(Control *_canvas);
56#endif
57
58 void _on_canvas_item_draw(Control *ci);
59 inline bool _is_enabled_override() const;
60
61 void process_start(double delta);
62 void process_end(double delta);
63 void physics_process_start(double delta);
64 void physics_process_end(double delta);
65
66#pragma region Exposed Parameter Values
67
68 // GENERAL
69
70 bool debug_enabled = true;
71 uint64_t custom_control_id = 0;
72
73 Ref<DebugDraw2DConfig> config;
74
75#pragma endregion // Exposed Parameter Values
76
77protected:
79 static void _bind_methods();
80
81public:
84
86 void init(DebugDrawManager *root);
87
92 return singleton;
93 };
95 void mark_canvas_dirty();
97 bool is_drawing_frame() const;
98
100 Node *get_root_node();
101
102#pragma region Exposed Parameters
104 void set_empty_color(const Color &_col);
108 Color get_empty_color() const;
109
113 void set_debug_enabled(const bool &_state);
114 bool is_debug_enabled() const;
115
119 void set_config(Ref<DebugDraw2DConfig> _cfg);
123 Ref<DebugDraw2DConfig> get_config() const;
124
130 void set_custom_canvas(Control *_canvas);
131 Control *get_custom_canvas() const;
132#pragma endregion // Exposed Parametes
133
134#pragma region Exposed Draw Functions
135
141 Ref<DebugDraw2DStats> get_render_stats();
142
146 void clear_all();
147
148#pragma region Text
159 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);
175 void set_text(String key, Variant value = Variant(), int priority = 0, Color color_of_value = Colors::empty_color, real_t duration = -1);
176
181#pragma endregion // Text
182#pragma region Graphs
183
191 Ref<DebugDraw2DGraph> create_graph(const StringName &title);
192
197 Ref<DebugDraw2DGraph> create_fps_graph(const StringName &title);
198
204 void graph_update_data(const StringName &title, real_t data);
205
210 void remove_graph(const StringName &title);
211
216
221 Ref<DebugDraw2DGraph> get_graph(const StringName &title);
222
226 PackedStringArray get_graph_names();
227
228#pragma endregion // Graphs
229#pragma endregion // Exposed Draw Functions
230};
This is a class for storing part of the DebugDraw2D configuration.
Definition config_2d.h:20
Base class for drawing graphs.
Definition graphs.h:26
You can get basic statistics about 2D rendering from this class.
Definition stats_2d.h:18
Singleton class for calling debugging 2D methods.
Definition debug_draw_2d.h:27
Ref< DebugDraw2DConfig > get_config() const
void set_custom_canvas(Control *_canvas)
Ref< DebugDraw2DGraph > create_fps_graph(const StringName &title)
void set_debug_enabled(const bool &_state)
void clear_graphs()
Ref< DebugDraw2DGraph > get_graph(const StringName &title)
Color get_empty_color() const
void remove_graph(const StringName &title)
void graph_update_data(const StringName &title, real_t data)
Ref< DebugDraw2DStats > get_render_stats()
void clear_texts()
Ref< DebugDraw2DGraph > create_graph(const StringName &title)
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:91
PackedStringArray get_graph_names()
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