Public Types | Public Member Functions | List of all members
ime::Window Class Reference

Window that can serve as a target for 2D drawing. More...

#include <Window.h>

Inheritance diagram for ime::Window:
ime::utility::NonCopyable

Public Types

enum  Style {
  Style::None = 0, Style::Titlebar = 1 << 0, Style::Resize = 1 << 1, Style::Close = 1 << 2,
  Style::Fullscreen = 1 << 3, Style::Default = Titlebar | Resize | Close
}
 Window styles. More...
 

Public Member Functions

 Window ()
 Constructor. More...
 
 Window (Window &&)=delete
 Move constructor. More...
 
Windowoperator= (Window &&)=delete
 Move assignment operator. More...
 
void create (const std::string &title, unsigned int width, unsigned int height, Style style=Style::Default)
 Create a render window. More...
 
void setIcon (const std::string &filename)
 Change the window's icon. More...
 
void setFramerateLimit (unsigned int framerateLimit)
 Set the frame rate limit of the window. More...
 
void setVsyncEnabled (bool isVsyncEnabled)
 Enable or disable vertical synchronization. More...
 
unsigned int getFramerateLimit () const
 Get the frame rate limit of the window. More...
 
Vector2u getSize ()
 Get the dimensions of the window. More...
 
bool isOpen () const
 Check if the window is open or not. More...
 
bool pollEvent (Event &event, WindowPassKey)
 
void close ()
 Close the window. More...
 
void draw (const Drawable &drawable)
 Draw drawable on the window. More...
 
void display ()
 Display drawn objects on the window. More...
 
void clear (Colour colour=Colour::Black)
 Clear the entire window with a single colour. More...
 
const std::unique_ptr< priv::WindowImpl > & getImpl () const
 
 ~Window ()
 Destructor. More...
 

Detailed Description

Window that can serve as a target for 2D drawing.

Definition at line 49 of file Window.h.

Member Enumeration Documentation

◆ Style

enum ime::Window::Style
strong

Window styles.

Enumerator
None 

No border / title bar (this flag and all others are mutually exclusive)

Titlebar 

Title bar + fixed border.

Resize 

Title bar + resizable border + maximize button.

Close 

Title bar + close button.

Fullscreen 

Fullscreen mode.

Default 

Default window style.

Definition at line 54 of file Window.h.

Constructor & Destructor Documentation

◆ Window() [1/2]

ime::Window::Window ( )

Constructor.

Warning
Only a single instance of the class can exist at a time. Attempting to instantiate the class while there is an active instance will terminate the program

◆ Window() [2/2]

ime::Window::Window ( Window &&  )
delete

Move constructor.

◆ ~Window()

ime::Window::~Window ( )

Destructor.

Ensures a new Window instance can be created when an existing Window instance is destroyed

Member Function Documentation

◆ clear()

void ime::Window::clear ( Colour  colour = Colour::Black)

Clear the entire window with a single colour.

Parameters
colourColour to clear window with

◆ close()

void ime::Window::close ( )

Close the window.

◆ create()

void ime::Window::create ( const std::string &  title,
unsigned int  width,
unsigned int  height,
Style  style = Style::Default 
)

Create a render window.

Parameters
titleTitle of the window
widthWidth of the window
heightHeight of the window
styleStyle of the window

The dimensions of the window must be positive, otherwise the program will be terminated prematurely

◆ display()

void ime::Window::display ( )

Display drawn objects on the window.

◆ draw()

void ime::Window::draw ( const Drawable drawable)

Draw drawable on the window.

Parameters
drawableObject to be drawn

◆ getFramerateLimit()

unsigned int ime::Window::getFramerateLimit ( ) const

Get the frame rate limit of the window.

Returns
The frame rate limit if it has been set, otherwise -1 if the frame rate is not limited

◆ getSize()

Vector2u ime::Window::getSize ( )

Get the dimensions of the window.

Returns
Dimensions of the window

◆ isOpen()

bool ime::Window::isOpen ( ) const

Check if the window is open or not.

Returns
true if open, false if not open

◆ operator=()

Window& ime::Window::operator= ( Window &&  )
delete

Move assignment operator.

◆ setFramerateLimit()

void ime::Window::setFramerateLimit ( unsigned int  framerateLimit)

Set the frame rate limit of the window.

Parameters
framerateLimitFrame rate limit

The frame rate is not limited by default. If set, it can be disabled by providing 0 as the argument

◆ setIcon()

void ime::Window::setIcon ( const std::string &  filename)

Change the window's icon.

Parameters
filenameFilename of the window icon to set

The OS default icon is used by default

◆ setVsyncEnabled()

void ime::Window::setVsyncEnabled ( bool  isVsyncEnabled)

Enable or disable vertical synchronization.

Parameters
isVsyncEnabledTrue to enable Vsync or false to disable it

Activating vertical synchronization will limit the number of frames displayed to the refresh rate of the monitor. This can avoid some visual artifacts, and limit the framerate to a good value (but not constant across different computers).

Vertical synchronization is disabled by default.


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