MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
GlfwWindow.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <GLFW/glfw3.h>
7
8namespace MayaFlux::Core {
9/**
10 * @class GlfwWindow
11 * @brief Platform-agnostic window wrapper
12 *
13 * Wraps a GLFW window and provides a unified interface
14 * for window management, event handling, and state tracking.
15 */
16class MAYAFLUX_API GlfwWindow : public Window {
17public:
18 /**
19 * @brief Creates a window with the given configuration
20 * @param create_info Window creation parameters
21 * @param surface_info Graphics surface parameters
22 * @param api Requested graphics API
23 * @param pre_init_config Optional pre-initialization configuration
24 */
25 GlfwWindow(const WindowCreateInfo& create_info,
26 const GraphicsSurfaceInfo& surface_info, GlobalGraphicsConfig::GraphicsApi api, GlfwPreInitConfig pre_init_config = {});
27
28 ~GlfwWindow() override;
29
30 GlfwWindow(const GlfwWindow&) = delete;
31 GlfwWindow& operator=(const GlfwWindow&) = delete;
32 GlfwWindow(GlfwWindow&&) noexcept;
33 GlfwWindow& operator=(GlfwWindow&&) noexcept;
34
35 void show() override;
36
37 void hide() override;
38
39 [[nodiscard]] bool should_close() const override;
40
41 [[nodiscard]] inline const WindowState& get_state() const override
42 {
43 return m_state;
44 }
45
46 [[nodiscard]] inline const WindowCreateInfo& get_create_info() const override
47 {
48 return m_create_info;
49 }
50
51 inline void set_input_config(const InputConfig& config) override
52 {
53 m_input_config = config;
54 }
55
56 [[nodiscard]] inline const InputConfig& get_input_config() const override
57 {
58 return m_input_config;
59 }
60
61 void set_event_callback(WindowEventCallback callback) override;
62
63 [[nodiscard]] void* get_native_handle() const override;
64
65 [[nodiscard]] void* get_native_display() const override;
66
67 [[nodiscard]] inline GLFWwindow* get_glfw_handle() const { return m_window; }
68
69 void set_title(const std::string& title) override;
70
71 void set_size(uint32_t width, uint32_t height) override;
72
73 void set_position(uint32_t x, uint32_t y) override;
74
75 Vruta::EventSource& get_event_source() override { return m_event_source; }
76 [[nodiscard]] const Vruta::EventSource& get_event_source() const override { return m_event_source; }
77
78 /**
79 * @brief Check if window is registered with graphics subsystem
80 */
81 [[nodiscard]] bool is_graphics_registered() const override { return m_graphics_registered.load(); }
82
83 /**
84 * @brief Mark window as registered/unregistered with graphics
85 * Called by GraphicsSubsystem during register/unregister
86 */
87 void set_graphics_registered(bool registered) override;
88
89private:
90 GLFWwindow* m_window = nullptr;
95
96 std::atomic<bool> m_graphics_registered { false };
97
99
100 void configure_window_hints(const GraphicsSurfaceInfo& surface_info, GlobalGraphicsConfig::GraphicsApi api) const;
101 void setup_callbacks();
102
103 static void glfw_window_size_callback(GLFWwindow* window, int width, int height);
104 static void glfw_window_close_callback(GLFWwindow* window);
105 static void glfw_window_focus_callback(GLFWwindow* window, int focused);
106 static void glfw_framebuffer_size_callback(GLFWwindow* window, int width, int height);
107 static void glfw_key_callback(GLFWwindow* window, int key, int scancode, int action, int mods);
108 static void glfw_cursor_pos_callback(GLFWwindow* window, double xpos, double ypos);
109 static void glfw_mouse_button_callback(GLFWwindow* window, int button, int action, int mods);
110 static void glfw_scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
111};
112}
bool is_graphics_registered() const override
Check if window is registered with graphics subsystem.
Vruta::EventSource m_event_source
const InputConfig & get_input_config() const override
Get current input configuration.
GlfwWindow(const GlfwWindow &)=delete
WindowCreateInfo m_create_info
void set_input_config(const InputConfig &config) override
Set input configuration (keyboard, mouse, cursor)
const Vruta::EventSource & get_event_source() const override
const WindowCreateInfo & get_create_info() const override
GlfwWindow & operator=(const GlfwWindow &)=delete
GLFWwindow * get_glfw_handle() const
Vruta::EventSource & get_event_source() override
Gets the event source for awaiting events.
WindowEventCallback m_event_callback
Platform-agnostic window wrapper.
Platform-agnostic window wrapper.
Definition Window.hpp:18
Awaitable event stream for window events.
std::function< void(const WindowEvent &)> WindowEventCallback
Configuration hints for GLFW initialization.
System-wide configuration for visual stream processing.
Input configuration for a window.
Configuration for creating a single window instance.
Runtime state of a window (mutable by system, read by user)