Rendering Engine 0.2.0
Modular Graphics Rendering Engine | v0.2.0
Loading...
Searching...
No Matches
rendering_engine::StandaloneDesktopWindow Class Reference

Desktop implementation of the IWindowSystem interface using GLFW. More...

#include <standalone_window_system.hpp>

Inherits rendering_engine::IWindowSystem.

Public Member Functions

 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.
void PollEvents () override
 Polls and processes OS-level window events (input, resize, close, etc.).
bool ShouldClose () const override
 Checks whether the user has requested to close the window.
void * GetNativeHandle () const override
 Returns a pointer to the underlying native window handle.
void Shutdown () override
 Performs cleanup and releases window-related resources.
const IApplicationGetApplication () override
 Retrieves a reference to the owning application instance.
bool IsFramebufferResized () const override
 Checks if the framebuffer has been resized since the last frame.
void ResetFramebufferResizedFlag () override
 Resets the framebuffer resized flag after handling a resize event.
WindowResolution GetFullScreenResolution () const override
 Queries the resolution of the full-screen display mode.
Public Member Functions inherited from rendering_engine::IWindowSystem
virtual ~IWindowSystem ()=default
 Virtual destructor for safe polymorphic cleanup.

Static Public Member Functions

static void FramebufferResizeCallback (GLFWwindow *window, int width, int height)
 GLFW framebuffer resize callback.

Detailed Description

Desktop implementation of the IWindowSystem interface using GLFW.

Provides window creation, event polling, and framebuffer resize handling for standalone desktop environments. This class represents the concrete platform layer for rendering contexts that rely on desktop windowing systems (e.g., Windows, Linux, FreeBSD).

See also
IWindowSystem
IApplication

Definition at line 27 of file standalone_window_system.hpp.

Constructor & Destructor Documentation

◆ StandaloneDesktopWindow()

rendering_engine::StandaloneDesktopWindow::StandaloneDesktopWindow ( IApplication & app)

Constructs a desktop window system instance.

Parameters
appReference to the associated application.

Definition at line 7 of file standalone_window_system.cpp.

8 :
9 mApp(app),
10 mWindow{nullptr},
11 mFramebufferResized(false)
12{
13}

Member Function Documentation

◆ CreateAppWindow()

void rendering_engine::StandaloneDesktopWindow::CreateAppWindow ( unsigned int width,
unsigned int height,
const std::string & title )
overridevirtual

Creates the main application window.

Parameters
widthWidth of the window in pixels.
heightHeight of the window in pixels.
titleTitle displayed in the window caption.

Implements rendering_engine::IWindowSystem.

Definition at line 15 of file standalone_window_system.cpp.

16{
17 glfwInit();
18 glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
19 glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
20
21 if (mApp.GetScreenSettings().isFullScreen)
22 {
23 const GLFWvidmode* mode = glfwGetVideoMode(glfwGetPrimaryMonitor());
24 mFullScreenRes.width = mode->width;
25 mFullScreenRes.height = mode->height;
26 mWindow = glfwCreateWindow(mode->width,
27 mode->height,
28 mApp.GetScreenSettings().name.c_str(),
29 glfwGetPrimaryMonitor(), nullptr);
30 }
31 else
32 {
33 mWindow = glfwCreateWindow(mApp.GetScreenSettings().width,
34 mApp.GetScreenSettings().height,
35 mApp.GetScreenSettings().name.c_str(),
36 nullptr, nullptr);
37 }
38
39 glfwSetWindowUserPointer(mWindow, this);
40 glfwSetFramebufferSizeCallback(mWindow, FramebufferResizeCallback);
41}
static void FramebufferResizeCallback(GLFWwindow *window, int width, int height)
GLFW framebuffer resize callback.

◆ FramebufferResizeCallback()

void rendering_engine::StandaloneDesktopWindow::FramebufferResizeCallback ( GLFWwindow * window,
int width,
int height )
static

GLFW framebuffer resize callback.

This static function is registered with GLFW to detect when the framebuffer size changes. It sets the internal resize flag for synchronization with the rendering system.

Parameters
windowPointer to the GLFW window instance.
widthNew framebuffer width.
heightNew framebuffer height.

Definition at line 69 of file standalone_window_system.cpp.

70{
71 auto app = reinterpret_cast<StandaloneDesktopWindow*>(glfwGetWindowUserPointer(window));
72 app->mFramebufferResized = true;
73}
StandaloneDesktopWindow(IApplication &app)
Constructs a desktop window system instance.

◆ GetApplication()

const IApplication & rendering_engine::StandaloneDesktopWindow::GetApplication ( )
overridevirtual

Retrieves a reference to the owning application instance.

Returns
Reference to the associated IApplication object.

Implements rendering_engine::IWindowSystem.

Definition at line 64 of file standalone_window_system.cpp.

65{
66 return mApp;
67}

◆ GetFullScreenResolution()

WindowResolution rendering_engine::StandaloneDesktopWindow::GetFullScreenResolution ( ) const
overridevirtual

Queries the resolution of the full-screen display mode.

Returns
The native screen resolution when running in full-screen mode.

Implements rendering_engine::IWindowSystem.

Definition at line 75 of file standalone_window_system.cpp.

76{
77 return mFullScreenRes;
78}

◆ GetNativeHandle()

void * rendering_engine::StandaloneDesktopWindow::GetNativeHandle ( ) const
overridevirtual

Returns a pointer to the underlying native window handle.

Returns
Platform-specific native handle (e.g., HWND, GLFWwindow*, X11 Window).

Implements rendering_engine::IWindowSystem.

Definition at line 53 of file standalone_window_system.cpp.

54{
55 return static_cast<void*>(mWindow);
56}

◆ IsFramebufferResized()

bool rendering_engine::StandaloneDesktopWindow::IsFramebufferResized ( ) const
inlineoverridevirtual

Checks if the framebuffer has been resized since the last frame.

Implements rendering_engine::IWindowSystem.

Definition at line 48 of file standalone_window_system.hpp.

48{ return mFramebufferResized; }

◆ PollEvents()

void rendering_engine::StandaloneDesktopWindow::PollEvents ( )
overridevirtual

Polls and processes OS-level window events (input, resize, close, etc.).

Implements rendering_engine::IWindowSystem.

Definition at line 43 of file standalone_window_system.cpp.

44{
45 glfwPollEvents();
46}

◆ ResetFramebufferResizedFlag()

void rendering_engine::StandaloneDesktopWindow::ResetFramebufferResizedFlag ( )
inlineoverridevirtual

Resets the framebuffer resized flag after handling a resize event.

Implements rendering_engine::IWindowSystem.

Definition at line 50 of file standalone_window_system.hpp.

50{ mFramebufferResized = false; }

◆ ShouldClose()

bool rendering_engine::StandaloneDesktopWindow::ShouldClose ( ) const
overridevirtual

Checks whether the user has requested to close the window.

Implements rendering_engine::IWindowSystem.

Definition at line 48 of file standalone_window_system.cpp.

49{
50 return glfwWindowShouldClose(mWindow);
51}

◆ Shutdown()

void rendering_engine::StandaloneDesktopWindow::Shutdown ( )
overridevirtual

Performs cleanup and releases window-related resources.

Implements rendering_engine::IWindowSystem.

Definition at line 58 of file standalone_window_system.cpp.

59{
60 glfwDestroyWindow(mWindow);
61 glfwTerminate();
62}

The documentation for this class was generated from the following files: