Rendering Engine 0.2.0
Modular Graphics Rendering Engine | v0.2.0
Loading...
Searching...
No Matches
standalone_window_system.cpp
Go to the documentation of this file.
2#include <GLFW/glfw3.h>
3#include "i_application.hpp"
4
5namespace rendering_engine
6{
8 :
9 mApp(app),
10 mWindow{nullptr},
11 mFramebufferResized(false)
12{
13}
14
15void StandaloneDesktopWindow::CreateAppWindow(unsigned int width, unsigned int height, const std::string& title)
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}
42
44{
45 glfwPollEvents();
46}
47
49{
50 return glfwWindowShouldClose(mWindow);
51}
52
54{
55 return static_cast<void*>(mWindow);
56}
57
59{
60 glfwDestroyWindow(mWindow);
61 glfwTerminate();
62}
63
68
69void StandaloneDesktopWindow::FramebufferResizeCallback(GLFWwindow* window, int width, int height)
70{
71 auto app = reinterpret_cast<StandaloneDesktopWindow*>(glfwGetWindowUserPointer(window));
72 app->mFramebufferResized = true;
73}
74
79
80
81}
Defines a generic application interface for rendering-based programs.
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 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.
Represents the pixel resolution of a window or display.