aboutsummaryrefslogtreecommitdiff
path: root/src/core/window.h
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-08-27 10:50:02 +0200
committerhachem <im@hachem.wtf>2026-08-27 10:50:02 +0200
commit90398614bcc9e1c1bde7a0f65a0db66173a1d8b4 (patch)
tree1cd0e18d46e6eb16f33afcb9561aad4d4dfb3ba3 /src/core/window.h
parent4b64b2bd17433f427197af3679c9c8f5ad5ad1a4 (diff)
add: window manager and opengl context
Diffstat (limited to 'src/core/window.h')
-rw-r--r--src/core/window.h61
1 files changed, 61 insertions, 0 deletions
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 <cstdint>
+#include <string>
+#include <string_view>
+
+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;
+ };
+}