mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-06-18 00:27:02 +08:00
feat: add DebugCollector
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include <Cubed/app.hpp>
|
||||
#include <Cubed/camera.hpp>
|
||||
#include <Cubed/config.hpp>
|
||||
#include <Cubed/debug_collector.hpp>
|
||||
#include <Cubed/gameplay/player.hpp>
|
||||
#include <Cubed/gameplay/world.hpp>
|
||||
#include <Cubed/texture_manager.hpp>
|
||||
@@ -117,18 +118,7 @@ const Shader& Renderer::get_shader(const std::string& name) const {
|
||||
void Renderer::init_text() {
|
||||
const auto& shader = get_shader("text");
|
||||
Text::set_loc(shader);
|
||||
m_version_text
|
||||
.position(0.0f, 100.0f)
|
||||
.scale(0.8f)
|
||||
.color(Color::WHITE)
|
||||
.text("Version: v0.0.1-Debug");
|
||||
m_fps_text
|
||||
.position(0.0f, 50.0f)
|
||||
.text("FPS: 0");
|
||||
m_player_pos_text
|
||||
.position(0.0f, 150.0f)
|
||||
.scale(0.8f)
|
||||
.text("x: 0.00 y: 0.00 z: 0.00");
|
||||
DebugCollector::get().init_text();
|
||||
}
|
||||
|
||||
void Renderer::render() {
|
||||
@@ -211,16 +201,12 @@ void Renderer::render_text() {
|
||||
m_proj_loc = shader.loc("projection");
|
||||
|
||||
glUniformMatrix4fv(m_proj_loc, 1, GL_FALSE, glm::value_ptr(m_ui_proj));
|
||||
m_fps_text.text(std::string{"FPS: " + std::to_string(static_cast<int>(App::get_fps()))});
|
||||
const auto& player = m_world.get_player("TestPlayer");
|
||||
const auto& pos = player.get_player_pos();
|
||||
std::string player_pos = std::format("x: {:.2f} y: {:.2f} z: {:.2f}", pos.x, pos.y, pos.z);
|
||||
m_player_pos_text.text(player_pos);
|
||||
|
||||
m_fps_text.render();
|
||||
m_player_pos_text.render();
|
||||
m_version_text.render();
|
||||
|
||||
auto& texts = DebugCollector::get().all_texts();
|
||||
for (auto& t : texts) {
|
||||
t.second.render();
|
||||
}
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user