galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
Window.hpp
Go to the documentation of this file.
1
7
8#ifndef GALAXY_CORE_WINDOW_HPP_
9#define GALAXY_CORE_WINDOW_HPP_
10
11#include <string>
12
13#include <entt/signal/fwd.hpp>
14#include <glm/vec2.hpp>
15#include <SDL3/SDL_events.h>
16#include <SDL3/SDL_video.h>
17
20
24union SDL_Event;
25
26namespace galaxy
27{
32 class Window final
33 {
34 public:
38 Window();
39
43 ~Window();
44
50 void process_events(entt::dispatcher& dispatcher);
51
57 void close() noexcept;
58
62 void swap() const noexcept;
63
67 void show() const noexcept;
68
72 void hide() const noexcept;
73
77 void minimize() const noexcept;
78
82 void maximize() const noexcept;
83
87 void restore() const noexcept;
88
92 void raise() const noexcept;
93
97 void request_attention() const noexcept;
98
105 void resize(const int width, const int height) const noexcept;
106
112 void set_fullscreen(const bool fullscreen) const noexcept;
113
119 void set_taskbar_progress(const float progress) noexcept;
120
128 void append_title(const std::string& append);
129
135 void set_icon(const std::string& icon) noexcept;
136
142 [[nodiscard]]
143 bool is_open() const noexcept;
144
150 [[nodiscard]]
151 Mouse& get_mouse() noexcept;
152
158 [[nodiscard]]
159 Keyboard& get_keyboard() noexcept;
160
166 [[nodiscard]]
167 glm::ivec2 get_pixel_size() noexcept;
168
174 [[nodiscard]]
175 SDL_Window* handle() const noexcept;
176
182 [[nodiscard]]
183 SDL_GLContext context() const noexcept;
184
185 private:
189 Window(const Window&) = delete;
190
194 Window(Window&&) = delete;
195
199 Window& operator=(const Window&) = delete;
200
204 Window& operator=(Window&&) = delete;
205
206 private:
210 SDL_Window* m_window;
211
215 SDL_GLContext m_context;
216
220 bool m_open;
221
225 SDL_Event m_events;
226
231
236 };
237} // namespace galaxy
238
239#endif
Physical keyboard device and state management.
Definition Keyboard.hpp:23
Physical mouse device and state management.
Definition Mouse.hpp:22
RAII Window. Handles events, input & display.
Definition Window.hpp:33
SDL_Window * m_window
SDL window handle.
Definition Window.hpp:210
void set_fullscreen(const bool fullscreen) const noexcept
Toggle fullscreen.
Definition Window.cpp:508
~Window()
Destructor.
Definition Window.cpp:202
SDL_Window * handle() const noexcept
Get SDL window pointer.
Definition Window.cpp:576
SDL_GLContext context() const noexcept
Get SDL GL context.
Definition Window.cpp:581
void swap() const noexcept
Swap backbuffer with window framebuffer.
Definition Window.cpp:457
Window(const Window &)=delete
Copy constructor.
bool is_open() const noexcept
Is the window open or closed.
Definition Window.cpp:553
void raise() const noexcept
Raise the window to be on top of other windows.
Definition Window.cpp:492
void resize(const int width, const int height) const noexcept
Resizes window.
Definition Window.cpp:502
Window & operator=(Window &&)=delete
Move assignment operator.
Window()
Window creation constructor.
Definition Window.cpp:39
void maximize() const noexcept
Maximize window.
Definition Window.cpp:478
Keyboard & get_keyboard() noexcept
Get keyboard.
Definition Window.cpp:563
void append_title(const std::string &append)
Append to window title.
Definition Window.cpp:519
Mouse m_mouse
Mouse assigned to window.
Definition Window.hpp:235
Keyboard m_keyboard
Keyboard assigned to window.
Definition Window.hpp:230
void close() noexcept
Close window.
Definition Window.cpp:452
void set_taskbar_progress(const float progress) noexcept
Sets the taskbar icon progress overlay.
Definition Window.cpp:514
bool m_open
Window state flag.
Definition Window.hpp:220
glm::ivec2 get_pixel_size() noexcept
Get window size in pixels.
Definition Window.cpp:568
void hide() const noexcept
Hide window.
Definition Window.cpp:467
void process_events(entt::dispatcher &dispatcher)
Handles all events for the window in this frame and sends to the dispatcher.
Definition Window.cpp:212
SDL_GLContext m_context
SDL OpenGL context.
Definition Window.hpp:215
void show() const noexcept
Show window.
Definition Window.cpp:462
Window(Window &&)=delete
Move constructor.
Window & operator=(const Window &)=delete
Copy assignment operator.
void minimize() const noexcept
Minimize window.
Definition Window.cpp:472
SDL_Event m_events
Core event data.
Definition Window.hpp:225
Mouse & get_mouse() noexcept
Get mouse cursor.
Definition Window.cpp:558
void set_icon(const std::string &icon) noexcept
Set window icon.
Definition Window.cpp:525
void request_attention() const noexcept
Flash window on taskbar for user attention.
Definition Window.cpp:497
void restore() const noexcept
Restore window to previous *mize state.
Definition Window.cpp:485
Animated.cpp galaxy.
Definition Animated.cpp:16