Pacman Torben Petré
Loading...
Searching...
No Matches
Window Class Reference

#include <Window.h>

Public Member Functions

 Window (Window &other)=delete
void operator= (const Window &)=delete
bool isOpen () const
 Tell whether the window is open.
bool pollEvent (sf::Event &event)
 Pop the event on top of the event queue, if any, and return it.
void draw (const sf::Drawable &drawable)
 Draw a drawable object to the window.
void clear ()
 Clear the window.
void display ()
 Display on screen what has been drawn to the window since the last clear.
void close ()
 Close the window and destroy all the attached resources.
void setFramerateLimit (unsigned int frameRate)
 Limit the framerate to a maximum fixed frequency.
void setView (const sf::View &view)
 Change the current active view.
unsigned int getWidth () const
 Get the width of the rendering region of the window. This does not include the borders of the window.
unsigned int getHeight () const
 Get the height of the rendering region of the window. This does not include the titlebar or borders of the window.

Static Public Member Functions

static WindowgetInstance ()
 Returns an instance of the Window class.

Constructor & Destructor Documentation

◆ Window()

Window::Window ( Window & other)
delete

Singletons should not be cloneable or assignable.

Member Function Documentation

◆ clear()

void Window::clear ( )

Clear the window.

◆ close()

void Window::close ( )

Close the window and destroy all the attached resources.

◆ display()

void Window::display ( )

Display on screen what has been drawn to the window since the last clear.

◆ draw()

void Window::draw ( const sf::Drawable & drawable)

Draw a drawable object to the window.

Parameters
drawableObject to draw

◆ getHeight()

unsigned int Window::getHeight ( ) const
nodiscard

Get the height of the rendering region of the window. This does not include the titlebar or borders of the window.

Returns
Height in pixels

◆ getInstance()

Window & Window::getInstance ( )
staticnodiscard

Returns an instance of the Window class.

Returns
Window instance

◆ getWidth()

unsigned int Window::getWidth ( ) const
nodiscard

Get the width of the rendering region of the window. This does not include the borders of the window.

Returns
Width in pixels

◆ isOpen()

bool Window::isOpen ( ) const
nodiscard

Tell whether the window is open.

Returns
True if the window is open, false if has been closed.

◆ operator=()

void Window::operator= ( const Window & )
delete

◆ pollEvent()

bool Window::pollEvent ( sf::Event & event)
nodiscard

Pop the event on top of the event queue, if any, and return it.

This function is not blocking: if there's no pending event then it will return false and leave event unmodified. Note that more than one event may be present in the event queue, thus you should always call this function in a loop to make sure that you process every pending event

Parameters
eventEvent to be returned.
Returns
True if an event was returned, or false if the event queue was empty.

◆ setFramerateLimit()

void Window::setFramerateLimit ( unsigned int frameRate)

Limit the framerate to a maximum fixed frequency.

If a limit is set, the window will use a small delay after each call to display() to ensure that the current frame lasted long enough to match the framerate limit. SFML will try to match the given limit as much as it can, but since it internally uses sf::sleep, whose precision depends on the underlying OS, the results may be a little unprecise as well (for example, you can get 65 FPS when requesting 60).

Parameters
frameRateFramerate limit, in frames per seconds (use 0 to disable limit).

◆ setView()

void Window::setView ( const sf::View & view)

Change the current active view.

The view is like a 2D camera, it controls which part of the 2D scene is visible, and how it is viewed in the render target. The new view will affect everything that is drawn, until another view is set. The render target keeps its own copy of the view object, so it is not necessary to keep the original one alive after calling this function. To restore the original view of the target, you can pass the result of getDefaultView() to this function.

Parameters
viewNew view to use

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