QuasarEngine
Cross-platform 3D engine and editor
Loading...
Searching...
No Matches
Quasar::Window Class Reference

Application window. More...

#include <quasar/core/Window.h>

Public Types

using EventCallback = std::function<void(Event&)>
 Function that receives the events of the window.

Public Member Functions

 Window (const Window &)=delete
Window & operator= (const Window &)=delete
 Window (Window &&)=delete
Window & operator= (Window &&)=delete
void Update ()
 Shows the rendered image and processes the messages of the operating system.
void SetEventCallback (EventCallback callback)
 Sets the function that receives every event of the window.
bool ShouldClose () const
 Returns true when the window was asked to close, by the user or by Close().
void Close ()
 Asks the window to close. ShouldClose() then returns true.
void SetVSync (bool enabled)
 Enables or disables vertical synchronization.
bool IsVSync () const
 Returns true if vertical synchronization is enabled.
std::uint32_t GetWidth () const
 Returns the width of the drawing area, in pixels.
std::uint32_t GetHeight () const
 Returns the height of the drawing area, in pixels.
const std::string & GetTitle () const
 Returns the title of the window.
GLFWwindow * GetNativeWindow () const
 Returns the GLFW window, for the code that needs to call GLFW directly.
std::string GetKeyName (Key key) const
 Returns the name of a key in the current keyboard layout, for example "z" for Key::W on AZERTY.

Static Public Member Functions

static Scope< Window > Create (const WindowSpecification &specification)
 Creates a window and shows it.

Detailed Description

Application window.

A window is created with Create() and destroyed with its Scope. GLFW is initialized with the first window and shut down with the last one.

Member Function Documentation

◆ Create()

Scope< Window > Quasar::Window::Create ( const WindowSpecification & specification)
staticnodiscard

Creates a window and shows it.

Parameters
specificationTitle, size and settings of the window.
Returns
The new window, or nullptr if it cannot be created. The reason is logged as an engine error.

◆ Update()

void Quasar::Window::Update ( )

Shows the rendered image and processes the messages of the operating system.

Call it once per frame, after rendering.

◆ SetVSync()

void Quasar::Window::SetVSync ( bool enabled)

Enables or disables vertical synchronization.

With VSync, the frame rate follows the refresh rate of the monitor, which prevents tearing.

◆ GetKeyName()

std::string Quasar::Window::GetKeyName ( Key key) const

Returns the name of a key in the current keyboard layout, for example "z" for Key::W on AZERTY.

Returns
The name of the key, or an empty string for keys that do not print a character, like Escape.

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