The cer::Window
class represents the game’s central window. It’s available immediately upon the game’s construction and can be obtained by calling the Game::window()
method:
auto game = Game("My Game");
auto window = game.window();
A Window
is reference-counted and can therefore be freely copied and moved around. Calling Game::window()
will increment the window’s reference count.
Window controls
The Window
class provides methods to obtain its properties such as size and position, and methods to also alter it.
The size of a window is always expressed in logical units, which is a device-independent unit. To obtain sizes in pixels, use methods that end in Px()
specifically.
For example, to obtain a window’s logical size, use the Window::size()
method, and Window::sizePx()
for its size in pixels.
This is necessary in order to support high-DPI displays, where a logical value of 1
might not be equal to a pixel value of 1
.
This relation is obtained using the Window::pixelRatio()
method, which represents the DPI scaling factor of the display that currently contains the window. To map from logical units to pixel units, logical values must be multiplied by this factor.
The title of a window can be obtained and modified by using the Window::title()
and Window::setTitle()
methods, respectively.