dl
dl_tool_debug_info.h
浏览该文件的文档.
1
11#pragma once
12
13#ifndef DL_DISABLE_RENDER
14#include <render/dl_factory.h>
15#include <render/dl_camera.h>
16
17namespace dl::Tool
18{
19
22{
23public:
28 static DebugInfo* Create()
29 {
30 DebugInfo* ret = new DebugInfo;
31 ret->_init();
32 return ret;
33 }
34
36 {
37 return _txt;
38 }
39
40 void Render(std::string_view str = "")
41 {
42 const RenderInfo2D ri_2d = g_system->GetRenderInfo2D();
43 const RenderInfo3D ri_3d = g_system->GetRenderInfo3D();
44
45 std::string str_all = fmt::format(
46 "fps:[t_4][c_yellow]{}[c]\n"
47 "dc2d:[t_4][c_yellow]{}+{}({})[c]\n"
48 "spr:[t_4][c_yellow]{}+{}[c]\n"
49 "gfx:[t_4][c_yellow]{}[c]\n"
50 "order:[t_4][c_yellow]{}({})[c]\n"
51 "dc3d:[t_4][c_yellow]{}[c]\n"
52 "actor:[t_4][c_yellow]{}[c]\n"
53 "light:[t_4][c_yellow]{}, {}, {}[c]\n"
54 "size:[t_4][c_yellow]{}({})[c]\n"
55 "mouse:[t_4][c_yellow]{}[c]\n"
56 "camera:[t_4][c_yellow]{}[c]",
57 g_time->GetFPS(),
61 g_ui->GetPanelAll().GetSize(), g_factory->GetOrderPickup(),
62 ri_3d._numDrawCall,
63 ri_3d._numActor,
64 ri_3d._numLightDir, ri_3d._numLightDot, ri_3d._numLightSpot,
65 to_string(g_system->GetWindowSize()), to_string(g_ui->GetStandardSize()),
66 to_string(g_input->GetCursorPosition()),
67 to_string(g_factory->GetCamera()->GetPosition()));
68
69 if (!str.empty())
70 {
71 str_all += "\n";
72 str_all += str;
73 }
74 _coor->SetScale(g_ui->GetScale());
75 _txt->SetString(str_all);
76 _txt->Render();
77 }
79 {
80 delete _coor;
81 }
82private:
83 Coor* _coor;
84 gcText _txt;
85
86 void _init()
87 {
88 _coor = Coor::Create();
89 _txt = g_factory->CreateText(0, 16, ColorDef::GREEN);
90 _txt->GetCoor()->SetParent(_coor);
91 _txt->SetBackground(true);
92 _txt->SetFormat(true);
93 }
94};
95
96}
97#endif
2d坐标系
void SetParent(Coor *coor)
static Coor * Create(Coor *parent=nullptr)
void SetFormat(bool open)
设置是否要格式化字符串(默认为否)
Coor * GetCoor()
返回坐标系
void SetBackground(bool open, const Color &col=ColorDef::TEXT_BG)
设置背景精灵
常见调试信息打印
void Render(std::string_view str="")
static DebugInfo * Create()
构造
摄像机(3d)
资源工厂
constexpr auto Add(const C &container)
求和sum
constexpr Color GREEN
Input * g_input
Factory * g_factory
std::string to_string(T v)
to_string包装
GC< Text > gcText
System * g_system
Time * g_time
UI::Manager * g_ui
size_t _numSwitchPso
PSO切换次数
std::array< size_t, 16 > _numGfx
GFX顶点数
size_t _numSpriteTranslucent
绘制半透明精灵数量
size_t _numDrawCall
drawcall数量
size_t _numSprite
绘制精灵数量
size_t _numDrawCallTranslucent
半透明drawcall数量
size_t _numLightDir
平行光
size_t _numLightDot
点光源
size_t _numDrawCall
drawcall数量
size_t _numActor
actor数量
size_t _numLightSpot
聚光灯