Rendering Engine 0.2.0
Modular Graphics Rendering Engine | v0.2.0
Loading...
Searching...
No Matches
standalone_window_system.hpp
Go to the documentation of this file.
1// This file is part of the Rendering Engine project.
2// Author: Alexander Obzherin <alexanderobzherin@gmail.com>
3// Copyright (c) 2025 Alexander Obzherin
4// Distributed under the terms of the zlib License. See LICENSE.md for details.
5#pragma once
6
7#include "i_window_system.hpp"
8
9class GLFWwindow;
10
11namespace rendering_engine
12{
13class IApplication;
14
15/**
16 * @class StandaloneDesktopWindow
17 * @brief Desktop implementation of the IWindowSystem interface using GLFW.
18 *
19 * Provides window creation, event polling, and framebuffer resize handling
20 * for standalone desktop environments. This class represents the concrete
21 * platform layer for rendering contexts that rely on desktop windowing systems
22 * (e.g., Windows, Linux, FreeBSD).
23 *
24 * @see IWindowSystem
25 * @see IApplication
26 */
28{
29public:
30 /**
31 * @brief Constructs a desktop window system instance.
32 * @param app Reference to the associated application.
33 */
35 /** @copydoc IWindowSystem::CreateAppWindow */
36 void CreateAppWindow(unsigned int width, unsigned int height, const std::string& title) override;
37 /** @copydoc IWindowSystem::PollEvents */
38 void PollEvents() override;
39 /** @copydoc IWindowSystem::ShouldClose */
40 bool ShouldClose() const override;
41 /** @copydoc IWindowSystem::GetNativeHandle */
42 void* GetNativeHandle() const override;
43 /** @copydoc IWindowSystem::Shutdown */
44 void Shutdown() override;
45 /** @copydoc IWindowSystem::GetApplication */
46 const IApplication& GetApplication() override;
47 /** @copydoc IWindowSystem::IsFramebufferResized */
48 bool IsFramebufferResized() const override { return mFramebufferResized; }
49 /** @copydoc IWindowSystem::ResetFramebufferResizedFlag */
50 void ResetFramebufferResizedFlag() override { mFramebufferResized = false; }
51 /**
52 * @brief GLFW framebuffer resize callback.
53 *
54 * This static function is registered with GLFW to detect when the framebuffer
55 * size changes. It sets the internal resize flag for synchronization with
56 * the rendering system.
57 *
58 * @param window Pointer to the GLFW window instance.
59 * @param width New framebuffer width.
60 * @param height New framebuffer height.
61 */
62 static void FramebufferResizeCallback(GLFWwindow* window, int width, int height);
63 /** @copydoc IWindowSystem::GetFullScreenResolution */
65
66private:
67 IApplication& mApp;
68 GLFWwindow* mWindow;
69 bool mFramebufferResized;
70 WindowResolution mFullScreenRes;
71};
72} //rendering_engine
Defines a generic application interface for rendering-based programs.
Abstract interface for platform-specific window management.
bool ShouldClose() const override
Checks whether the user has requested to close the window.
StandaloneDesktopWindow(IApplication &app)
Constructs a desktop window system instance.
void CreateAppWindow(unsigned int width, unsigned int height, const std::string &title) override
Creates the main application window.
const IApplication & GetApplication() override
Retrieves a reference to the owning application instance.
void ResetFramebufferResizedFlag() override
Resets the framebuffer resized flag after handling a resize event.
void PollEvents() override
Polls and processes OS-level window events (input, resize, close, etc.).
WindowResolution GetFullScreenResolution() const override
Queries the resolution of the full-screen display mode.
void Shutdown() override
Performs cleanup and releases window-related resources.
static void FramebufferResizeCallback(GLFWwindow *window, int width, int height)
GLFW framebuffer resize callback.
void * GetNativeHandle() const override
Returns a pointer to the underlying native window handle.
bool IsFramebufferResized() const override
Checks if the framebuffer has been resized since the last frame.
Represents the pixel resolution of a window or display.