libdonut  2.3.2
Application framework for cross-platform game development in C++20
Classes | Public Member Functions | List of all members
donut::graphics::Window Class Reference

Graphical window that can be rendered to. More...

#include <donut/graphics/Window.hpp>

Public Member Functions

 Window (const WindowOptions &options)
 Create a new window. More...
 
 ~Window ()=default
 Destructor. More...
 
 Window (const Window &)=delete
 Copying a window is not allowed, since it manages global state. More...
 
 Window (Window &&)=delete
 Moving a window is not allowed, since it manages global state. More...
 
Windowoperator= (const Window &)=delete
 Copying a window is not allowed, since it manages global state. More...
 
Windowoperator= (Window &&)=delete
 Moving a window is not allowed, since it manages global state. More...
 
void present ()
 Swap the window's front and back buffers, showing what has been rendered to the framebuffer since the last presentation. More...
 
void setTitle (const char *title)
 Set the displayed title of the window. More...
 
void setSize (ivec2 size)
 Set the size of the window. More...
 
void setResizable (bool resizable)
 Set whether to allow the window to be resized by the user or not. More...
 
void setFullscreen (bool fullscreen)
 Set the fullscreen state of the window. More...
 
void setVSync (bool vSync)
 Enable or disable vertical synchronization for the window. More...
 
bool isScreenKeyboardShown () const noexcept
 Check if the screen keyboard is currently open. More...
 
bool isFullscreen () const noexcept
 Check if the window is currently in fullscreen mode. More...
 
ivec2 getSize () const noexcept
 Get the size of the window. More...
 
ivec2 getDrawableSize () const noexcept
 Get the drawable size of the window. More...
 
std::uint32_t getId () const
 Get a unique identifier for this window. More...
 
FramebuffergetFramebuffer ()
 Get the Framebuffer for rendering to this window. More...
 

Detailed Description

Graphical window that can be rendered to.

Examples
example_game.cpp, and example_rectangle.cpp.

Constructor & Destructor Documentation

◆ Window() [1/3]

donut::graphics::Window::Window ( const WindowOptions options)
explicit

Create a new window.

Parameters
optionsinitial configuration of the window, see WindowOptions.
Exceptions
graphics::Errorif context or window setup failed.
std::bad_allocon allocation failure.

◆ ~Window()

donut::graphics::Window::~Window ( )
default

Destructor.

◆ Window() [2/3]

donut::graphics::Window::Window ( const Window )
delete

Copying a window is not allowed, since it manages global state.

◆ Window() [3/3]

donut::graphics::Window::Window ( Window &&  )
delete

Moving a window is not allowed, since it manages global state.

Member Function Documentation

◆ operator=() [1/2]

Window& donut::graphics::Window::operator= ( const Window )
delete

Copying a window is not allowed, since it manages global state.

◆ operator=() [2/2]

Window& donut::graphics::Window::operator= ( Window &&  )
delete

Moving a window is not allowed, since it manages global state.

◆ present()

void donut::graphics::Window::present ( )

Swap the window's front and back buffers, showing what has been rendered to the framebuffer since the last presentation.

◆ setTitle()

void donut::graphics::Window::setTitle ( const char *  title)

Set the displayed title of the window.

Parameters
titlenon-owning pointer to a null-terminated UTF-8 string containing the title. Must not be nullptr.
See also
WindowOptions::title

◆ setSize()

void donut::graphics::Window::setSize ( ivec2  size)

Set the size of the window.

Parameters
sizea 2D vector representing the desired size of the window, in screen coordinates (typically pixels), where:
  • the x component represents the width, and
  • the y component represents the height. Both the width and height must be positive.
See also
WindowOptions::size

◆ setResizable()

void donut::graphics::Window::setResizable ( bool  resizable)

Set whether to allow the window to be resized by the user or not.

Parameters
resizabletrue to allow resizing, false to disallow.
See also
WindowOptions::resizable

◆ setFullscreen()

void donut::graphics::Window::setFullscreen ( bool  fullscreen)

Set the fullscreen state of the window.

Parameters
fullscreentrue for fullscreen mode, false for windowed mode.
See also
WindowOptions::fullscreen

◆ setVSync()

void donut::graphics::Window::setVSync ( bool  vSync)

Enable or disable vertical synchronization for the window.

Parameters
vSynctrue to enable VSync, false to disable.
See also
WindowOptions::vSync

◆ isScreenKeyboardShown()

bool donut::graphics::Window::isScreenKeyboardShown ( ) const
noexcept

Check if the screen keyboard is currently open.

Returns
true if the screen keyboard is open, false otherwise.
See also
events::EventPump::hasScreenKeyboardSupport()

◆ isFullscreen()

bool donut::graphics::Window::isFullscreen ( ) const
noexcept

Check if the window is currently in fullscreen mode.

Returns
true if the window is in fullscreen mode, false otherwise.

◆ getSize()

ivec2 donut::graphics::Window::getSize ( ) const
noexcept

Get the size of the window.

Returns
a 2D vector representing the current size of the window, in screen coordinates (typically pixels), where:
  • the x component represents the width, and
  • the y component represents the height.

◆ getDrawableSize()

ivec2 donut::graphics::Window::getDrawableSize ( ) const
noexcept

Get the drawable size of the window.

Returns
a 2D vector representing the current drawable size of the window, in pixels, where:
  • the x component represents the width, and
  • the y component represents the height.

◆ getId()

std::uint32_t donut::graphics::Window::getId ( ) const

Get a unique identifier for this window.

Returns
the identifier corresponding to this window.

◆ getFramebuffer()

Framebuffer& donut::graphics::Window::getFramebuffer ( )

Get the Framebuffer for rendering to this window.

Returns
a reference to the default framebuffer, with the GL context associated with this window made current.

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