92 lines
1.8 KiB
C++
92 lines
1.8 KiB
C++
/**
|
|
* @file DND.ToolShowFps.ixx
|
|
* @brief 显示FPS等信息
|
|
*
|
|
*
|
|
* @version 1.0
|
|
* @author lveyou
|
|
* @date 21-12-24
|
|
*
|
|
*/
|
|
#pragma once
|
|
|
|
#include <render/dl_factory.h>
|
|
#include <render/dl_camera.h>]
|
|
|
|
namespace dl::Tool
|
|
{
|
|
class DebugInfo
|
|
{
|
|
public:
|
|
/**
|
|
* @brief 构造
|
|
* @note 使用0号字体
|
|
*/
|
|
static DebugInfo* Create()
|
|
{
|
|
DebugInfo* ret = new DebugInfo;
|
|
ret->_init();
|
|
return ret;
|
|
}
|
|
|
|
gcText GetText()
|
|
{
|
|
return _txt;
|
|
}
|
|
|
|
void Render(std::string_view str = "")
|
|
{
|
|
const RenderInfo2D ri_2d = g_system->GetRenderInfo2D();
|
|
const RenderInfo3D ri_3d = g_system->GetRenderInfo3D();
|
|
|
|
std::string str_all = fmt::format(
|
|
"fps:[t_4][c_yellow]{}[c]\n"
|
|
"dc2d:[t_4][c_yellow]{}+{}[c]\n"
|
|
"spr:[t_4][c_yellow]{}+{}[c]\n"
|
|
"order:[t_4][c_yellow]{}[c]\n"
|
|
"dc3d:[t_4][c_yellow]{}[c]\n"
|
|
"actor:[t_4][c_yellow]{}[c]\n"
|
|
"light:[t_4][c_yellow]{}, {}, {}[c]\n"
|
|
"size:[t_4][c_yellow]{}[c]\n"
|
|
"mouse:[t_4][c_yellow]{}[c]\n"
|
|
"camera:[t_4][c_yellow]{}[c]",
|
|
g_time->GetFPS(),
|
|
ri_2d._numDrawCall, ri_2d._numDrawCallTranslucent,
|
|
ri_2d._numSprite, ri_2d._numSpriteTranslucent,
|
|
g_ui->GetOrderPickup(),
|
|
ri_3d._numDrawCall,
|
|
ri_3d._numActor,
|
|
ri_3d._numLightDir, ri_3d._numLightDot, ri_3d._numLightSpot,
|
|
to_string(g_system->GetWindowSize()),
|
|
to_string(g_input->GetCursorPosition()),
|
|
to_string(g_factory->GetCamera()->GetPosition()));
|
|
|
|
if (!str.empty())
|
|
{
|
|
str_all += "\n";
|
|
str_all += str;
|
|
}
|
|
_coor->SetScale(g_ui->GetScale());
|
|
_txt->SetString(str_all);
|
|
_txt->Render();
|
|
}
|
|
~DebugInfo()
|
|
{
|
|
delete _coor;
|
|
}
|
|
private:
|
|
Coor* _coor;
|
|
gcText _txt;
|
|
|
|
void _init()
|
|
{
|
|
_coor = Coor::Create();
|
|
_txt = g_factory->CreateText(0, 16, ColorDef::GREEN);
|
|
_txt->GetCoor()->SetParent(_coor);
|
|
_txt->SetBackground(true);
|
|
_txt->SetFormat(true);
|
|
}
|
|
};
|
|
|
|
}
|