Raftel Engine
 
Loading...
Searching...
No Matches
Raftel::Window Class Reference

Represents a single window in the system, supporting OpenGL context and input handling. More...

#include <window.hpp>

Public Member Functions

 ~Window ()
 Destructor that destroys the GLFW window and releases associated resources.
 
void MakeContextCurrent ()
 Makes the window context current for OpenGL operations.
 
bool ShouldClose (bool allowEscapeKey=true)
 Checks if the window should close, optionally checking for the Escape key.
 
void clear ()
 Clears the window's buffer (color and depth).
 
void swapBuffers ()
 Swaps the front and back buffers, displaying the rendered content.
 
glm::ivec2 getScreenSize ()
 Gets the current size of the window in screen coordinates.
 
void toggleFullscreen (GLFWwindow *window)
 Toggles between fullscreen and windowed modes.
 
void onResize (int newWidth, int newHeight)
 Handles window resize events, adjusting the OpenGL viewport accordingly.
 
 Window (GLFWwindow *w)
 Private constructor used by the make method to initialize the window.
 

Static Public Member Functions

static std::unique_ptr< Windowmake (const char *title, WindowSystem &ws, int width=0, int height=0, bool fullscreen=false)
 Creates a new window with the specified properties.
 

Public Attributes

std::unique_ptr< Inputinput
 Input handler associated with the window.
 
GLFWwindow * window_
 The GLFW window instance.
 
bool isFullscreen = false
 Whether the window is in fullscreen mode.
 

Detailed Description

Represents a single window in the system, supporting OpenGL context and input handling.

The Window class manages an individual window's properties and provides methods to interact with the OpenGL context. It supports features such as fullscreen toggling, resizing, and swapping buffers. Input handling is also integrated within this class.

Definition at line 83 of file window.hpp.

Constructor & Destructor Documentation

◆ Window()

Raftel::Window::Window ( GLFWwindow * w)

Private constructor used by the make method to initialize the window.

Parameters
wThe GLFW window instance to associate with this Window object.

Member Function Documentation

◆ getScreenSize()

glm::ivec2 Raftel::Window::getScreenSize ( )

Gets the current size of the window in screen coordinates.

Returns
A glm::ivec2 representing the width and height of the window.

◆ make()

static std::unique_ptr< Window > Raftel::Window::make ( const char * title,
WindowSystem & ws,
int width = 0,
int height = 0,
bool fullscreen = false )
static

Creates a new window with the specified properties.

Parameters
titleThe title of the window.
wsThe window system to associate the window with.
widthThe width of the window (default 0 for fullscreen resolution).
heightThe height of the window (default 0 for fullscreen resolution).
fullscreenWhether the window should be fullscreen or not.
Returns
A unique pointer to the created Window object, or nullptr if creation fails.

◆ onResize()

void Raftel::Window::onResize ( int newWidth,
int newHeight )

Handles window resize events, adjusting the OpenGL viewport accordingly.

Parameters
newWidthThe new width of the window.
newHeightThe new height of the window.

◆ ShouldClose()

bool Raftel::Window::ShouldClose ( bool allowEscapeKey = true)

Checks if the window should close, optionally checking for the Escape key.

Parameters
allowEscapeKeyWhether the Escape key should be allowed to close the window.
Returns
true if the window should close, false otherwise.

◆ toggleFullscreen()

void Raftel::Window::toggleFullscreen ( GLFWwindow * window)

Toggles between fullscreen and windowed modes.

Parameters
windowThe GLFW window object to toggle.

Member Data Documentation

◆ input

std::unique_ptr<Input> Raftel::Window::input

Input handler associated with the window.

Definition at line 140 of file window.hpp.

◆ isFullscreen

bool Raftel::Window::isFullscreen = false

Whether the window is in fullscreen mode.

Definition at line 149 of file window.hpp.

◆ window_

GLFWwindow* Raftel::Window::window_

The GLFW window instance.

Definition at line 141 of file window.hpp.


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