From 90398614bcc9e1c1bde7a0f65a0db66173a1d8b4 Mon Sep 17 00:00:00 2001 From: hachem Date: Thu, 27 Aug 2026 10:50:02 +0200 Subject: add: window manager and opengl context --- src/core/window.h | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/core/window.h (limited to 'src/core/window.h') diff --git a/src/core/window.h b/src/core/window.h new file mode 100644 index 0000000..6a4f747 --- /dev/null +++ b/src/core/window.h @@ -0,0 +1,61 @@ +#pragma once + +#include +#include +#include + +struct GLFWwindow; + +namespace Hsdbg +{ + struct WindowSpec + { + std::string title = "hsdbg"; + uint32_t width = 1600; + uint32_t height = 900; + bool vsync = true; + }; + + class Window + { + public: + explicit Window(const WindowSpec& spec); + ~Window(); + + Window(const Window&) = delete; + Window(Window&&) = delete; + auto operator=(const Window&) -> Window& = delete; + auto operator=(Window&&) -> Window& = delete; + + auto should_close() const -> bool; + auto set_should_close(bool value) -> void; + + auto make_context_current() -> void; + auto swap_buffers() -> void; + + auto set_vsync(bool enabled) -> void; + auto set_title(std::string_view title) -> void; + + auto handle() const -> GLFWwindow* { return m_handle; } + auto title() const -> const std::string& { return m_title; } + auto is_vsync() const -> bool { return m_vsync; } + auto is_minimized() const -> bool; + + auto width() const -> uint32_t { return m_width; } + auto height() const -> uint32_t { return m_height; } + auto framebuffer_width() const -> uint32_t { return m_framebuffer_width; } + auto framebuffer_height() const -> uint32_t { return m_framebuffer_height; } + + private: + static auto on_window_size(GLFWwindow* handle, int width, int height) -> void; + static auto on_framebuffer_size(GLFWwindow* handle, int width, int height) -> void; + + GLFWwindow* m_handle = nullptr; + std::string m_title; + uint32_t m_width = 0; + uint32_t m_height = 0; + uint32_t m_framebuffer_width = 0; + uint32_t m_framebuffer_height = 0; + bool m_vsync = true; + }; +} -- cgit v1.3