dl
dl_tool_debug_info.h
浏览该文件的文档.
1
11#pragma once
12
13#include <render/dl_factory.h>
14#include <render/dl_camera.h>
15
16namespace dl::Tool
17{
19{
20public:
25 static DebugInfo* Create()
26 {
27 DebugInfo* ret = new DebugInfo;
28 ret->_init();
29 return ret;
30 }
31
33 {
34 return _txt;
35 }
36
37 void Render(std::string_view str = "")
38 {
39 const RenderInfo2D ri_2d = g_system->GetRenderInfo2D();
40 const RenderInfo3D ri_3d = g_system->GetRenderInfo3D();
41
42 std::string str_all = fmt::format(
43 "fps:[t_4][c_yellow]{}[c]\n"
44 "dc2d:[t_4][c_yellow]{}+{}[c]\n"
45 "spr:[t_4][c_yellow]{}+{}[c]\n"
46 "order:[t_4][c_yellow]{}[c]\n"
47 "dc3d:[t_4][c_yellow]{}[c]\n"
48 "actor:[t_4][c_yellow]{}[c]\n"
49 "light:[t_4][c_yellow]{}, {}, {}[c]\n"
50 "size:[t_4][c_yellow]{}[c]\n"
51 "mouse:[t_4][c_yellow]{}[c]\n"
52 "camera:[t_4][c_yellow]{}[c]",
53 g_time->GetFPS(),
57 ri_3d._numDrawCall,
58 ri_3d._numActor,
59 ri_3d._numLightDir, ri_3d._numLightDot, ri_3d._numLightSpot,
63
64 if (!str.empty())
65 {
66 str_all += "\n";
67 str_all += str;
68 }
69 _coor->SetScale(g_ui->GetScale());
70 _txt->SetString(str_all);
71 _txt->Render();
72 }
74 {
75 delete _coor;
76 }
77private:
78 Coor* _coor;
79 gcText _txt;
80
81 void _init()
82 {
83 _coor = Coor::Create();
84 _txt = g_factory->CreateText(0, 16, ColorDef::GREEN);
85 _txt->GetCoor()->SetParent(_coor);
86 _txt->SetBackground(true);
87 _txt->SetFormat(true);
88 }
89};
90
91}
Position3 GetPosition()
Definition: dl_camera.h:32
2d坐标系
Definition: dl_coor.h:27
void SetParent(Coor *coor)
static Coor * Create(Coor *parent=nullptr)
void SetScale(const Position &scale)
gcText CreateText(size_t font_id=0, unsigned font_size=16, const Color &col=ColorDef::WHITE, unsigned font_outline=0, const Color &col_outline=ColorDef::BLACK, unsigned font_shadow=0, const Color &col_shadow=ColorDef::BLACK)
创建一个文本
Camera * GetCamera()
返回相机(3d)
Point GetCursorPosition()
返回鼠标位置。限制到窗口范围
Size GetWindowSize()
返回窗口大小
const RenderInfo2D & GetRenderInfo2D()
返回上一帧绘图信息
const RenderInfo3D & GetRenderInfo3D()
void Render()
绘制
bool SetString(std::string_view str)
设置内容
void SetFormat(bool open)
设置是否要格式化字符串(默认为否)
Definition: dl_text.h:121
Coor * GetCoor()
返回坐标系
Definition: dl_text.h:250
void SetBackground(bool open, const Color &col=ColorDef::TEXT_BG)
设置背景精灵
unsigned GetFPS()
返回fps
Definition: dl_time.h:48
void Render(std::string_view str="")
static DebugInfo * Create()
构造
float GetOrderPickup()
float GetScale()
返回ui缩放
摄像机(3d)
资源工厂
constexpr Color GREEN
Definition: dl_color.h:253
std::string to_string(const SpriteID &id)
Definition: dl_sprite.h:50
Input * g_input
Factory * g_factory
System * g_system
Time * g_time
UI::Manager * g_ui
绘图信息2d
Definition: dl_type_user.h:20
size_t _numSpriteTranslucent
绘制半透明精灵数量
Definition: dl_type_user.h:24
size_t _numDrawCall
drawcall数量
Definition: dl_type_user.h:21
size_t _numSprite
绘制精灵数量
Definition: dl_type_user.h:23
size_t _numDrawCallTranslucent
半透明drawcall数量
Definition: dl_type_user.h:22
绘图信息3d
Definition: dl_type_user.h:34
size_t _numLightDir
平行光
Definition: dl_type_user.h:37
size_t _numLightDot
点光源
Definition: dl_type_user.h:38
size_t _numDrawCall
drawcall数量
Definition: dl_type_user.h:35
size_t _numActor
actor数量
Definition: dl_type_user.h:36
size_t _numLightSpot
聚光灯
Definition: dl_type_user.h:39