Add rendering debug infos
This commit is contained in:
parent
d6236a7857
commit
ea712fae42
@ -55,6 +55,12 @@ Graphic3DRenderer::Graphic3DRenderer() {
|
||||
mRenderList.push_back(std::make_shared<Tank>());
|
||||
mRenderList.back()->SetPosition(0.f, 0.f, 0.f);
|
||||
mRenderList.back()->SetScale(5.0f);
|
||||
|
||||
for (size_t i = 0; i < 40; i++) {
|
||||
mRenderList.push_back(std::make_shared<Tank>());
|
||||
mRenderList.back()->SetPosition(-100.f + (i * 5.f), 0.f, 8.f);
|
||||
mRenderList.back()->SetScale(5.0f);
|
||||
}
|
||||
}
|
||||
|
||||
Graphic3DRenderer::~Graphic3DRenderer() {}
|
||||
@ -97,6 +103,10 @@ void Graphic3DRenderer::Draw(sf::RenderTexture& context) {
|
||||
sf::BlendMode sBM = sf::BlendNone;
|
||||
sf::RenderStates sRS(sBM);
|
||||
|
||||
#ifdef DEBUG
|
||||
drawnTriCount = 0;
|
||||
#endif
|
||||
|
||||
// Hardcoded debug movement, TODO: remove it
|
||||
UpdateInternalTestObjects();
|
||||
|
||||
@ -231,6 +241,9 @@ void Graphic3DRenderer::Draw(sf::RenderTexture& context) {
|
||||
context.draw(v_tri, 4, sf::Triangles, sRS);
|
||||
#else
|
||||
context.draw(v_tri, 4, sf::LineStrip, sRS);
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
drawnTriCount++;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,11 @@ public:
|
||||
void UpdateCamera(CAMERA_MOVE type, const float value);
|
||||
void Draw(sf::RenderTexture& context);
|
||||
|
||||
// Debug datas
|
||||
#ifdef DEBUG
|
||||
const unsigned int GetDrawTriCount() const noexcept { return drawnTriCount; }
|
||||
#endif
|
||||
|
||||
private:
|
||||
std::unique_ptr<Camera> mMainCamera; // Default player view
|
||||
sf::Vector2f mRTSize;
|
||||
@ -40,5 +45,10 @@ private:
|
||||
|
||||
void UpdateInternalTestObjects();
|
||||
float ComputeSGRatio();
|
||||
|
||||
// Debug datas
|
||||
#ifdef DEBUG
|
||||
unsigned int drawnTriCount;
|
||||
#endif
|
||||
|
||||
};
|
@ -14,22 +14,23 @@ DebugUI::DebugUI() {
|
||||
gDbgText.setFillColor(sf::Color::White);
|
||||
}
|
||||
|
||||
void DebugUI::UpdateDebugData(const double cpu_usage, const double cpu_time, const double cycle_time, const int fps, const std::size_t ram_virt_usage, const std::size_t ram_phys_usage) {
|
||||
void DebugUI::UpdateDebugData(const double cpu_usage, const double cpu_time, const double cycle_time, const int fps, const std::size_t ram_virt_usage, const std::size_t ram_phys_usage, const unsigned int drawnTriCount) {
|
||||
gDbgStats.cpu_usage = cpu_usage;
|
||||
gDbgStats.cpu_time = cpu_time;
|
||||
gDbgStats.cycle_time = cycle_time;
|
||||
gDbgStats.fps = fps;
|
||||
gDbgStats.ram_virt_usage = ram_virt_usage;
|
||||
gDbgStats.ram_phys_usage = ram_phys_usage;
|
||||
gDbgStats.drawnTriCount = drawnTriCount;
|
||||
}
|
||||
|
||||
void DebugUI::DrawDebugData(std::shared_ptr<sf::RenderWindow> context) {
|
||||
std::ostringstream outStrStream;
|
||||
outStrStream << std::fixed;
|
||||
|
||||
outStrStream << std::setprecision(0) << "CPU: " << gDbgStats.cpu_usage << "% (cycle: " << std::setprecision(3) << gDbgStats.cpu_time << "/" << gDbgStats.cycle_time << "ms)" << std::endl;
|
||||
outStrStream << std::setprecision(1) << "RAM: " << gDbgStats.ram_virt_usage << "MB(V)/" << gDbgStats.ram_phys_usage << "MB(P)" << std::endl;
|
||||
outStrStream << std::setprecision(0) << "FPS: " << gDbgStats.fps;
|
||||
outStrStream << std::setprecision(0) << "CPU: " << gDbgStats.cpu_usage << "% (cycle: " << std::setprecision(3) << gDbgStats.cpu_time << "/" << gDbgStats.cycle_time << "ms) - Triangles: " << gDbgStats.drawnTriCount << '\n';
|
||||
outStrStream << std::setprecision(1) << "RAM: " << gDbgStats.ram_virt_usage << "MB(V)/" << gDbgStats.ram_phys_usage << "MB(P)\n";
|
||||
outStrStream << std::setprecision(0) << "FPS: " << gDbgStats.fps << std::flush;
|
||||
|
||||
gDbgText.setString(outStrStream.str());
|
||||
context->draw(gDbgText);
|
||||
|
@ -14,6 +14,7 @@ struct sDbgStats {
|
||||
int fps;
|
||||
std::size_t ram_virt_usage;
|
||||
std::size_t ram_phys_usage;
|
||||
unsigned int drawnTriCount;
|
||||
};
|
||||
|
||||
class DebugUI {
|
||||
@ -21,7 +22,7 @@ public:
|
||||
DebugUI();
|
||||
~DebugUI() {}
|
||||
|
||||
void UpdateDebugData(const double cpu_usage, const double cpu_time, const double cycle_time, const int fps, const std::size_t ram_virt_usage, const std::size_t ram_phys_usage);
|
||||
void UpdateDebugData(const double cpu_usage, const double cpu_time, const double cycle_time, const int fps, const std::size_t ram_virt_usage, const std::size_t ram_phys_usage, const unsigned int drawnTriCount);
|
||||
void DrawDebugData(std::shared_ptr<sf::RenderWindow> context);
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user