From 705e3914e4e820c3ac92892c32c93479691a09e7 Mon Sep 17 00:00:00 2001 From: hachem Date: Thu, 27 Aug 2026 14:17:34 +0200 Subject: add: debugger interface --- src/core/application.cpp | 13 +++++++------ src/core/application.h | 3 +++ src/core/result.h | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 src/core/result.h (limited to 'src/core') diff --git a/src/core/application.cpp b/src/core/application.cpp index 7c2d9a3..1e6d343 100644 --- a/src/core/application.cpp +++ b/src/core/application.cpp @@ -4,6 +4,7 @@ #include "core/log.h" #include "core/window.h" #include "core/window_manager.h" +#include "debugger/debugger.h" #include @@ -16,9 +17,6 @@ namespace Hsdbg using Clock = std::chrono::steady_clock; constexpr float MAX_DELTA_TIME = 0.25f; - - // a minimized window has no framebuffer to draw into, so idle instead of - // burning a core on frames nobody can see constexpr double MINIMIZED_WAIT_TIMEOUT = 0.1; } @@ -41,10 +39,14 @@ namespace Hsdbg window_spec.vsync = m_spec.vsync; m_window = &m_window_manager->create_window(window_spec); + + m_debugger = std::make_unique(); } Application::~Application() { + m_debugger.reset(); + m_window = nullptr; m_window_manager.reset(); @@ -103,15 +105,14 @@ namespace Hsdbg auto Application::update() -> void { + m_debugger->update(); } auto Application::render() -> void { - glViewport(0, - 0, + glViewport(0, 0, static_cast(m_window->framebuffer_width()), static_cast(m_window->framebuffer_height())); - glClearColor(0.09f, 0.09f, 0.11f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } diff --git a/src/core/application.h b/src/core/application.h index 8df5afb..2f5ffbe 100644 --- a/src/core/application.h +++ b/src/core/application.h @@ -6,6 +6,7 @@ namespace Hsdbg { + class Debugger; class Window; class WindowManager; @@ -34,6 +35,7 @@ namespace Hsdbg auto close() -> void; auto window() -> Window& { return *m_window; } + auto debugger() -> Debugger& { return *m_debugger; } auto spec() const -> const ApplicationSpec& { return m_spec; } auto is_running() const -> bool { return m_running; } auto delta_time() const -> float { return m_delta_time; } @@ -48,6 +50,7 @@ namespace Hsdbg ApplicationSpec m_spec; std::unique_ptr m_window_manager; + std::unique_ptr m_debugger; Window* m_window = nullptr; bool m_running = false; float m_delta_time = 0.0f; diff --git a/src/core/result.h b/src/core/result.h new file mode 100644 index 0000000..a516336 --- /dev/null +++ b/src/core/result.h @@ -0,0 +1,18 @@ +#pragma once + +#include +#include +#include +#include + +namespace Hsdbg +{ + template + using Result = std::expected; + + template + auto fail(std::format_string fmt, Args&&... args) -> std::unexpected + { + return std::unexpected(std::format(fmt, std::forward(args)...)); + } +} -- cgit v1.3