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.cpp
Go to the documentation of this file.
1
7
8#include <entt/signal/dispatcher.hpp>
9#include <glad/glad.h>
10#include <stb_image.h>
11
12#include "galaxy/core/ServiceLocator.hpp"
13#include "galaxy/error/Log.hpp"
15#include "galaxy/events/KeyChar.hpp"
16#include "galaxy/events/KeyPress.hpp"
17#include "galaxy/events/KeyRepeat.hpp"
18#include "galaxy/events/MouseEnter.hpp"
29#include "galaxy/input/InputMods.hpp"
33
34#include "Window.hpp"
35
36#ifdef GALAXY_WIN_PLATFORM
37#pragma warning(push)
38#pragma warning(disable : 26462)
39#endif
40
41void* glfw_alloc(size_t size, void* user)
42{
43 return mi_malloc(size);
44}
45
46void* glfw_realloc(void* block, size_t size, void* user)
47{
48 return mi_realloc(block, size);
49}
50
51void glfw_dealloc(void* block, void* user)
52{
53 mi_free(block);
54}
55
56namespace galaxy
57{
58 namespace core
59 {
61 : m_window {nullptr}
62 , m_dispatcher {nullptr}
63 , m_title {settings.title}
64 , m_window_width {settings.window_width}
65 , m_window_height {settings.window_height}
66 , m_frame_width {settings.frame_width}
67 , m_frame_height {settings.frame_height != 0 ? settings.frame_height : 1}
68 , m_aspect_ratio {static_cast<float>(m_frame_width / m_frame_height)}
69 {
70 m_glfw_allocator.allocate = &glfw_alloc;
71 m_glfw_allocator.reallocate = &glfw_realloc;
72 m_glfw_allocator.deallocate = &glfw_dealloc;
73
74 // Set error handling callback.
75 glfwSetErrorCallback([](int error, const char* description) {
76 GALAXY_LOG(GALAXY_ERROR, "[GLFW] Code: {0}, Desc: {1}.", error, description);
77 });
78
79 glfwInitAllocator(&m_glfw_allocator);
80
81 glfwInitHint(GLFW_JOYSTICK_HAT_BUTTONS, GLFW_FALSE);
82 if (!glfwInit())
83 {
84 GALAXY_LOG(GALAXY_FATAL, "Failed to initialize glfw!");
85 }
86 else
87 {
88 m_cursor.init();
89
90 // Configure window setup using hints.
91 // If not here, then default is the preference.
92 glfwWindowHint(GLFW_MOUSE_PASSTHROUGH, GLFW_FALSE);
93 glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
94 glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
95 glfwWindowHint(GLFW_DECORATED, GLFW_TRUE);
96 glfwWindowHint(GLFW_FOCUSED, GLFW_TRUE);
97 glfwWindowHint(GLFW_AUTO_ICONIFY, GLFW_TRUE);
98 glfwWindowHint(GLFW_CENTER_CURSOR, GLFW_TRUE);
99 glfwWindowHint(GLFW_FOCUS_ON_SHOW, GLFW_TRUE);
100 glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE);
101
102 // Configure framebuffer setup.
103 auto* vm = glfwGetVideoMode(glfwGetPrimaryMonitor());
104
105 glfwWindowHint(GLFW_RED_BITS, vm->redBits); // 8
106 glfwWindowHint(GLFW_GREEN_BITS, vm->greenBits); // 8
107 glfwWindowHint(GLFW_BLUE_BITS, vm->blueBits); // 8
108 glfwWindowHint(GLFW_REFRESH_RATE, vm->refreshRate);
109 glfwWindowHint(GLFW_ALPHA_BITS, 8);
110 glfwWindowHint(GLFW_DEPTH_BITS, 24);
111 glfwWindowHint(GLFW_STENCIL_BITS, 8);
112 glfwWindowHint(GLFW_STEREO, GLFW_FALSE);
113 glfwWindowHint(GLFW_SAMPLES, 0); // 4
114 glfwWindowHint(GLFW_SRGB_CAPABLE, GLFW_TRUE);
115 glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_TRUE);
116
117 // Configure OpenGL context hints.
118 glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API);
119 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
120 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6);
121 glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
122 glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, settings.debug);
123 glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
124
125 m_window = glfwCreateWindow(m_window_width, m_window_height, m_title.c_str(), nullptr, nullptr);
126 if (m_window)
127 {
128 if (!settings.maximized && !settings.fullscreen)
129 {
130 int sx = 0, sy = 0;
131 int px = 0, py = 0;
132 int mx = 0, my = 0;
133 int monitor_count = 0;
134 int best_area = 0;
135 int final_x = 0, final_y = 0;
136
137 glfwGetWindowSize(m_window, &sx, &sy);
138 glfwGetWindowPos(m_window, &px, &py);
139
140 auto m = glfwGetMonitors(&monitor_count);
141
142 for (auto j = 0; j < monitor_count; ++j)
143 {
144 glfwGetMonitorPos(m[j], &mx, &my);
145 auto mode = glfwGetVideoMode(m[j]);
146 if (!mode)
147 {
148 continue;
149 }
150
151 const auto min_x = std::max(mx, px);
152 const auto min_y = std::max(my, py);
153
154 const auto max_x = std::min(mx + mode->width, px + sx);
155 const auto max_y = std::min(my + mode->height, py + sy);
156
157 const auto area = std::max(max_x - min_x, 0) * std::max(max_y - min_y, 0);
158
159 if (area > best_area)
160 {
161 final_x = mx + (mode->width - sx) / 2;
162 final_y = my + (mode->height - sy) / 2;
163
164 best_area = area;
165 }
166 }
167
168 if (best_area)
169 {
170 glfwSetWindowPos(m_window, final_x, final_y);
171 }
172 else
173 {
174 auto primary = glfwGetPrimaryMonitor();
175 if (primary)
176 {
177 auto desktop = glfwGetVideoMode(primary);
178 if (desktop)
179 {
180 glfwSetWindowPos(m_window, (desktop->width - sx) / 2, (desktop->height - sy) / 2);
181 }
182 }
183 }
184 }
185 else if (settings.fullscreen)
186 {
187 fullscreen();
188 }
189 else if (settings.maximized)
190 {
191 maximize();
192 }
193
194 glfwShowWindow(m_window);
195 glfwSetInputMode(m_window, GLFW_LOCK_KEY_MODS, GLFW_TRUE);
196 glfwGetWindowSize(m_window, &m_window_width, &m_window_height); // Correct window size after setup.
197
198 // Set input devices.
199 m_keyboard.set_window(m_window);
200 m_mouse.set_window(m_window);
201 m_cursor.set_window(m_window);
202 m_clipboard.set_window(m_window);
203 input::Input::s_window = m_window;
204
205 // Set close callback.
206 glfwSetWindowCloseCallback(m_window, [](GLFWwindow* window) {
207 auto* win = static_cast<Window*>(glfwGetWindowUserPointer(window));
208 if (win->m_dispatcher)
209 {
210 win->m_dispatcher->trigger<events::WindowClosed>();
211 }
212 });
213
214 // Set resize callback.
215 glfwSetFramebufferSizeCallback(m_window, [](GLFWwindow* window, int width, int height) {
216 auto* win = static_cast<Window*>(glfwGetWindowUserPointer(window));
217 if (win->m_dispatcher)
218 {
219 // clang-format off
220 events::WindowResized wr
221 {
222 .width = width,
223 .height = height
224 };
225 // clang-format on
226
228 win->m_dispatcher->trigger(wr);
229 }
230
231 win->m_window_width = width;
232 win->m_window_height = height;
233 });
234
235 // Content scale callback.
236 glfwSetWindowContentScaleCallback(m_window, [](GLFWwindow* window, float xscale, float yscale) {
237 auto* win = static_cast<Window*>(glfwGetWindowUserPointer(window));
238 if (win->m_dispatcher)
239 {
240 // clang-format off
241 events::ContentScale sc
242 {
243 .xscale = xscale,
244 .yscale = yscale
245 };
246 // clang-format on
247
248 win->m_dispatcher->trigger(sc);
249 }
250
251 if (!ServiceLocator<graphics::FontContext>::empty())
252 {
253 auto& fc = ServiceLocator<graphics::FontContext>::ref();
254 fc.set_dpi(xscale * 96.0f, yscale * 96.0f);
255 }
256
257 if (ui::imgui_loaded())
258 {
260 }
261 });
262
263 // Key input callback.
264 glfwSetKeyCallback(m_window, [](GLFWwindow* window, int key, int scancode, int action, int mods) {
265 auto* win = static_cast<Window*>(glfwGetWindowUserPointer(window));
266 if (win->m_dispatcher && !win->m_keyboard.is_text_input_enabled())
267 {
268 // clang-format off
269 events::KeyPress kp
270 {
271 .keycode = input::int_to_key(key),
272 .mod = input::int_to_mod(mods),
273 .scancode = scancode,
274 .pressed = action == GLFW_PRESS,
275 .repeat = action == GLFW_REPEAT
276 };
277 // clang-format on
278
279 win->m_dispatcher->trigger(kp);
280 }
281 });
282
283 // Text input callback.
284 glfwSetCharCallback(m_window, [](GLFWwindow* window, unsigned int codepoint) {
285 auto* win = static_cast<Window*>(glfwGetWindowUserPointer(window));
286 if (win->m_dispatcher && win->m_keyboard.is_text_input_enabled())
287 {
288 // clang-format off
289 events::KeyChar kc
290 {
291 .codepoint = codepoint
292 };
293 // clang-format on
294
295 win->m_dispatcher->trigger(kc);
296 }
297 });
298
299 // Mouse entered callback.
300 glfwSetCursorEnterCallback(m_window, [](GLFWwindow* window, int entered) {
301 auto* win = static_cast<Window*>(glfwGetWindowUserPointer(window));
302 if (win->m_dispatcher)
303 {
304 // clang-format off
305 events::MouseEnter me
306 {
307 .entered = static_cast<bool>(entered)
308 };
309 // clang-format on
310
311 win->m_dispatcher->trigger(me);
312 }
313 });
314
315 // Mouse movement callback.
316 glfwSetCursorPosCallback(m_window, [](GLFWwindow* window, double xpos, double ypos) {
317 auto* win = static_cast<Window*>(glfwGetWindowUserPointer(window));
318 if (win->m_dispatcher)
319 {
320 // clang-format off
321 events::MouseMoved mm
322 {
323 .xpos = xpos,
324 .ypos = ypos
325 };
326 // clang-format on
327
328 win->m_dispatcher->trigger(mm);
329 }
330 });
331
332 // Mouse button callback.
333 glfwSetMouseButtonCallback(m_window, [](GLFWwindow* window, int button, int action, int mods) {
334 auto* win = static_cast<Window*>(glfwGetWindowUserPointer(window));
335 if (win->m_dispatcher)
336 {
337 const auto pos = win->m_mouse.get_pos();
338
339 // clang-format off
340 switch (action)
341 {
342 case GLFW_PRESS:
343 {
344 events::MousePressed mp
345 {
346 .xpos = pos.x,
347 .ypos = pos.y,
348 .button = input::int_to_mouse(button),
349 .mod = input::int_to_mod(mods)
350 };
351
352 win->m_dispatcher->trigger(mp);
353 }
354 break;
355
356 case GLFW_RELEASE:
357 {
358 events::MouseReleased mr
359 {
360 .xpos = pos.x,
361 .ypos = pos.y,
362 .button = input::int_to_mouse(button),
363 .mod = input::int_to_mod(mods)
364 };
365
366 win->m_dispatcher->trigger(mr);
367 }
368 break;
369
370 default:
371 break;
372 }
373 // clang-format on
374 }
375 });
376
377 // Set scroll wheel callback.
378 glfwSetScrollCallback(m_window, [](GLFWwindow* window, double xoffset, double yoffset) {
379 auto* win = static_cast<Window*>(glfwGetWindowUserPointer(window));
380 if (win->m_dispatcher)
381 {
382 // clang-format off
383 events::MouseWheel mw
384 {
385 .xoff = xoffset,
386 .yoff = yoffset
387 };
388 // clang-format on
389
390 win->m_dispatcher->trigger(mw);
391 }
392 });
393
394 // clang-format off
395 #ifdef GALAXY_WIN_PLATFORM
398 #endif
399 // clang-format on
400
401 // Set dropped item callback.
402 glfwSetDropCallback(m_window, [](GLFWwindow* window, int count, const char** paths) {
403 auto* win = static_cast<Window*>(glfwGetWindowUserPointer(window));
404
405 win->m_drop_paths.clear();
406 for (auto i = 0; i < count; i++)
407 {
408 win->m_drop_paths.emplace_back(paths[i]);
409 }
410 });
411
412 // clang-format off
413 #ifdef GALAXY_WIN_PLATFORM
415 #endif
416 // clang-format on
417
418 glfwMakeContextCurrent(m_window);
419 glfwSetWindowUserPointer(m_window, this);
420
421 // Set up glad.
422 if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
423 {
424 GALAXY_LOG(GALAXY_FATAL, "Failed to initialize glad.");
425 }
426 else
427 {
428 // Set vsync.
429 glfwSwapInterval(settings.vsync);
430
431 // Debug configuration.
432 if (settings.debug)
433 {
434 glEnable(GL_DEBUG_OUTPUT);
435 glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
436
437 glDebugMessageCallback(
438 [](GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam) {
439 GALAXY_UNUSED(source);
440 GALAXY_UNUSED(type);
441 GALAXY_UNUSED(id);
442 GALAXY_UNUSED(length);
443 GALAXY_UNUSED(userParam);
444
445 switch (severity)
446 {
447 case GL_DEBUG_SEVERITY_HIGH:
448 GALAXY_LOG(GALAXY_ERROR, "[OpenGL] - {0}", message);
449 break;
450 case GL_DEBUG_SEVERITY_MEDIUM:
451 GALAXY_LOG(GALAXY_WARNING, "[OpenGL] - {0}", message);
452 break;
453 case GL_DEBUG_SEVERITY_LOW:
454 GALAXY_LOG(GALAXY_DEBUG, "[OpenGL] - {0}", message);
455 break;
456 default:
457 GALAXY_LOG(GALAXY_INFO, "[OpenGL] - {0}", message);
458 break;
459 };
460 },
461 nullptr
462 );
463
464 glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_NOTIFICATION, 0, nullptr, GL_FALSE);
465 }
466
467 // Configure global GL state.
468 glDisable(GL_FRAMEBUFFER_SRGB);
469 glDisable(GL_CULL_FACE);
470 glDisable(GL_SCISSOR_TEST);
471 glDisable(GL_MULTISAMPLE); // Use provided SMAA.
472
473 glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
474 glEnable(GL_PROGRAM_POINT_SIZE);
475 glEnable(GL_DEPTH_TEST);
476 glEnable(GL_STENCIL_TEST);
477 glEnable(GL_BLEND);
478
479 // GL state function configuration.
480 glCullFace(GL_BACK);
481 glDepthFunc(GL_LEQUAL);
482 glBlendEquation(GL_FUNC_ADD);
483 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
484 }
485 }
486 else
487 {
488 GALAXY_LOG(GALAXY_FATAL, "Failed to create window.");
489 }
490 }
491 }
492
494 {
495 // Call again to ensure everything is cleaned up.
496 // Has checks to ensure no null data is destroyed.
497 destroy();
498 }
499
500 void Window::set_title(const std::string& title)
501 {
502 glfwSetWindowTitle(m_window, title.c_str());
503 }
504
505 void Window::append_title(const std::string& append)
506 {
507 auto title = m_title + append;
508 glfwSetWindowTitle(m_window, title.c_str());
509 }
510
511 void Window::set_icon(const std::string& icon)
512 {
513 if (!icon.empty())
514 {
515 auto& fs = ServiceLocator<fs::VirtualFileSystem>::ref();
516
517 auto data = fs.read_binary(icon);
518 if (!data.empty())
519 {
520 // Fill glfw-compatible struct.
521 stbi_set_flip_vertically_on_load(true);
522
523 GLFWimage img = {};
524 img.pixels = stbi_load_from_memory(data.data(), static_cast<int>(data.size()), &img.width, &img.height, nullptr, STBI_rgb_alpha);
525
526 if (img.pixels)
527 {
528 // Copies data so safe to destroy.
529 glfwSetWindowIcon(m_window, 1, &img);
530 }
531 else
532 {
533 GALAXY_LOG(GALAXY_ERROR, "Failed to load image '{0}' for window icon.", icon);
534 }
535
536 stbi_image_free(img.pixels);
537 }
538 else
539 {
540 GALAXY_LOG(GALAXY_ERROR, "Failed to read '{0}' from the vfs.", icon);
541 }
542 }
543 }
544
545 void Window::set_icon(std::span<std::uint8_t> buffer)
546 {
547 if (!buffer.empty())
548 {
549 // Fill glfw-compatible struct.
550 stbi_set_flip_vertically_on_load(true);
551
552 GLFWimage img = {};
553 img.pixels = stbi_load_from_memory(buffer.data(), static_cast<int>(buffer.size_bytes()), &img.width, &img.height, nullptr, STBI_rgb_alpha);
554
555 if (img.pixels)
556 {
557 // Copies data so safe to destroy.
558 glfwSetWindowIcon(m_window, 1, &img);
559 }
560 else
561 {
562 GALAXY_LOG(GALAXY_ERROR, "Failed to load window icon from memory");
563 }
564
565 stbi_image_free(img.pixels);
566 }
567 }
568
569 void Window::set_dispatcher(entt::dispatcher* dispatcher)
570 {
571 m_dispatcher = dispatcher;
572 }
573
574 bool Window::is_open() const
575 {
576 return !glfwWindowShouldClose(m_window);
577 }
578
580 {
581 glfwSetWindowShouldClose(m_window, GLFW_TRUE);
582 }
583
585 {
586 if (m_window != nullptr)
587 {
588 m_cursor.destroy();
589 m_cursor.destroy_system_cursors();
590
591 glfwDestroyWindow(m_window);
592
593 m_window = nullptr;
594 input::Input::s_window = nullptr;
595
596 input::Input::s_cursor_pos.x = 0.0;
597 input::Input::s_cursor_pos.y = 0.0;
598
599 glfwTerminate();
600 }
601 }
602
604 {
605 glfwPollEvents();
606 }
607
608 void Window::resize(const int width, const int height)
609 {
610 m_window_width = width;
611 m_window_height = height;
612
613 glfwSetWindowSize(m_window, m_window_width, m_window_height);
614 }
615
617 {
618 glfwRequestWindowAttention(m_window);
619 }
620
621 void Window::focus() const
622 {
623 glfwFocusWindow(m_window);
624 }
625
627 {
628 glfwMaximizeWindow(m_window);
629 glfwGetWindowSize(m_window, &m_window_width, &m_window_height);
630 }
631
633 {
634 glfwRestoreWindow(m_window);
635 glfwGetWindowSize(m_window, &m_window_width, &m_window_height);
636 }
637
638 void Window::minimize() const
639 {
640 glfwIconifyWindow(m_window);
641 }
642
644 {
645 auto* monitor = glfwGetPrimaryMonitor();
646 auto* mode = glfwGetVideoMode(monitor);
647
648 glfwSetWindowMonitor(m_window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate);
649 glfwGetWindowSize(m_window, &m_window_width, &m_window_height);
650 }
651
653 {
654 return glfwGetWindowAttrib(m_window, GLFW_FOCUSED);
655 }
656
658 {
659 return m_window_width;
660 }
661
663 {
664 return m_window_height;
665 }
666
668 {
669 return m_frame_width;
670 }
671
673 {
674 return m_frame_height;
675 }
676
678 {
679 return m_aspect_ratio;
680 }
681
682 const meta::vector<std::string>& Window::get_drop_paths() const
683 {
684 return m_drop_paths;
685 }
686
688 {
689 glm::ivec2 size;
690 glfwGetFramebufferSize(m_window, &size.x, &size.y);
691
692 return size;
693 }
694
696 {
697 glm::vec2 size;
698 glfwGetWindowContentScale(m_window, &size.x, &size.y);
699
700 return size;
701 }
702
704 {
705 const auto scale = get_content_scale();
706 return std::max(scale.x, scale.y);
707 }
708
709 GLFWwindow* Window::handle()
710 {
711 return m_window;
712 }
713 } // namespace core
714} // namespace galaxy
715
716#ifdef GALAXY_WIN_PLATFORM
717#pragma warning(pop)
718#endif
#define GALAXY_INFO
Log.hpp galaxy.
Definition Log.hpp:22
#define GALAXY_LOG(level, msg,...)
Definition Log.hpp:28
#define GALAXY_FATAL
Definition Log.hpp:25
#define GALAXY_ERROR
Definition Log.hpp:24
#define GALAXY_DISABLE_WARNING_POP
Definition Pragma.hpp:57
#define GALAXY_DISABLE_WARNING(x)
Definition Pragma.hpp:58
#define GALAXY_UNUSED(var)
Pragma.hpp galaxy.
Definition Pragma.hpp:16
#define GALAXY_DISABLE_WARNING_PUSH
Macro for windows platform detection.
Definition Pragma.hpp:56
Handles events, input & display.
Definition Window.hpp:29
input::Keyboard m_keyboard
Keyboard assigned to window.
Definition Window.hpp:290
void set_title(const std::string &title)
Set window title.
Definition Window.cpp:500
std::string m_title
Window title.
Definition Window.hpp:245
void destroy()
Destroys Window and related context and data.
Definition Window.cpp:584
int m_window_height
Height of window (or fullscreen).
Definition Window.hpp:255
meta::vector< std::string > m_drop_paths
Cache of last dropped paths.
Definition Window.hpp:310
void poll_events()
Poll for events.
Definition Window.cpp:603
input::Clipboard m_clipboard
Clipboard access.
Definition Window.hpp:305
input::Cursor m_cursor
Mouse cursor.
Definition Window.hpp:300
void append_title(const std::string &append)
Append to window title.
Definition Window.cpp:505
int window_height() const
Definition Window.cpp:662
void minimize() const
Minimize window.
Definition Window.cpp:638
Window()=delete
Constructor.
void close()
Closes the current window.
Definition Window.cpp:579
int frame_width() const
Definition Window.cpp:667
glm::vec2 get_content_scale()
Get window content scale.
Definition Window.cpp:695
float get_content_scale_max()
Get max window content scale.
Definition Window.cpp:703
~Window()
Destructor.
Definition Window.cpp:493
float m_aspect_ratio
Window aspect ratio.
Definition Window.hpp:270
bool is_focused() const
Check if windows is in focus.
Definition Window.cpp:652
glm::ivec2 get_framebuffer_size()
Get framebuffer size taking into account DPI.
Definition Window.cpp:687
float aspect_ratio() const
Definition Window.cpp:677
int frame_height() const
Definition Window.cpp:672
bool is_open() const
Checks if window is currently open or not.
Definition Window.cpp:574
void request_attention()
Notify's user of an event without interrupting.
Definition Window.cpp:616
entt::dispatcher * m_dispatcher
Currently active event dispatcher.
Definition Window.hpp:280
void focus() const
Force window into focus.
Definition Window.cpp:621
void set_icon(const std::string &icon)
Set window icon.
Definition Window.cpp:511
int window_width() const
Definition Window.cpp:657
GLFWwindow * m_window
GLFW window data.
Definition Window.hpp:275
input::Mouse m_mouse
Mouse assigned to window.
Definition Window.hpp:295
int m_frame_height
The virtual or final framebuffer height.
Definition Window.hpp:265
void restore()
Restore window.
Definition Window.cpp:632
int m_frame_width
The virtual or final framebuffer width.
Definition Window.hpp:260
void resize(const int width, const int height)
Resizes window.
Definition Window.cpp:608
int m_window_width
Width of window (or fullscreen).
Definition Window.hpp:250
void set_dispatcher(entt::dispatcher *dispatcher)
Set current event dispatcher to use.
Definition Window.cpp:569
void maximize()
Maximize window.
Definition Window.cpp:626
GLFWwindow * handle()
Retrieve pointer to GLFWwindow object.
Definition Window.cpp:709
const meta::vector< std::string > & get_drop_paths() const
Get a list of paths dropped on window.
Definition Window.cpp:682
GLFWallocator m_glfw_allocator
Custom GLFW window allocator.
Definition Window.hpp:285
void fullscreen()
Set window into borderless fullscreen mode.
Definition Window.cpp:643
static Renderer & ref()
Get reference to renderer singleton.
Definition Renderer.cpp:19
void on_window_resized(const events::WindowResized &e)
Event processing method for window size change.
Definition Renderer.cpp:71
void glfw_dealloc(void *block, void *user)
Definition Window.cpp:51
void * glfw_realloc(void *block, size_t size, void *user)
Definition Window.cpp:46
void * glfw_alloc(size_t size, void *user)
Window.cpp galaxy.
Definition Window.cpp:41
bool imgui_loaded()
Is ImGui loaded?
void scale_and_load_fonts()
Scale and load fonts.
Animated.cpp galaxy.
Definition Animated.cpp:16
Script.hpp galaxy.
Definition Script.hpp:16
Holds window related settings.
bool debug
Enable debug api calls.
bool fullscreen
Open window fullscreen. Has priority over maximized.
bool maximized
Open window maximized.