NAP
RenderWindow Class Reference

#include <renderwindow.h>

Public Member Functions

 RenderWindow ()=default
 
virtual ~RenderWindow () override
 
 RenderWindow (RenderService &renderService)
 
virtual bool init (utility::ErrorState &errorState) override
 
GLWindowgetWindow () const
 
void swap () const
 
void makeActive ()
 
int getWidth () const
 
int getWidthPixels () const
 
int getHeight () const
 
int getHeightPixels () const
 
void show ()
 
void hide ()
 
const std::string & getTitle () const
 
bool isResizable () const
 
void setFullscreen (bool value)
 
void toggleFullscreen ()
 
void setWidth (int width)
 
void setHeight (int height)
 
void setPosition (const glm::ivec2 &position)
 
const glm::ivec2 getPosition () const
 
virtual uint getNumber () const override
 
math::Rect getRect () const
 
math::Rect getRectPixels () const
 
const opengl::BackbufferRenderTargetgetBackbuffer () const
 
opengl::BackbufferRenderTargetgetBackbuffer ()
 
- Public Member Functions inherited from Window
void addEvent (WindowEventPtr inEvent)
 
void processEvents ()
 
EventPtrConstIterator GetEvents () const
 
- Public Member Functions inherited from Resource
 Resource ()
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual void onDestroy ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 

Public Attributes

int mWidth = 512
 Property: 'Width' of the window in pixels. More...
 
int mHeight = 512
 Property: 'Height' of the window in pixels. More...
 
bool mBorderless = false
 Property: 'Borderless' if the window has any borders. More...
 
bool mResizable = true
 Property: 'Resizable' if the window is resizable. More...
 
bool mSync = true
 Property: 'Sync' If v-sync is enabled. More...
 
std::string mTitle = ""
 Property: 'Title' window title. More...
 
glm::vec4 mClearColor = { 0.0f, 0.0f, 0.0f, 1.0f }
 Property: 'ClearColor' background clear color. More...
 
- Public Attributes inherited from Window
Signal< const WindowEvent & > mWindowEvent
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 

Additional Inherited Members

- Public Types inherited from Window
using EventPtrList = std::vector< EventPtr >
 
using EventPtrConstIterator = utility::UniquePtrConstVectorWrapper< WindowEventPtrList, Event * >
 
- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 

Detailed Description

3D render window resource that can be declared in json. This resource offers an interface to change window settings and manages an OpenGL window including associated render context. It is important to activate the window before issuing any draw commands!

Inheritance diagram for RenderWindow:
[legend]
Collaboration diagram for RenderWindow:
[legend]

Constructor & Destructor Documentation

◆ RenderWindow() [1/2]

RenderWindow ( )
default

◆ ~RenderWindow()

virtual ~RenderWindow ( )
overridevirtual

◆ RenderWindow() [2/2]

RenderWindow ( RenderService renderService)

This constructor is called when creating the render window using the resource manager Every render window needs to be aware of it's render service

Member Function Documentation

◆ getBackbuffer() [1/2]

const opengl::BackbufferRenderTarget& getBackbuffer ( ) const

The back buffer for an OpenGL window isn't an actual frame buffer but allows for handling windows and render targets inside the framework in a similar way. Associating a back buffer with a window also ensures, in this case, that the opengl viewport always matches the window dimensions

Returns
the back buffer associated with this window

◆ getBackbuffer() [2/2]

opengl::BackbufferRenderTarget& getBackbuffer ( )

The back buffer for an OpenGL window isn't an actual frame buffer but allows for handling windows and render targets inside the framework in a similar way. Associating a back buffer with a window also ensures, in this case, that the opengl viewport always matches the window dimensions

Returns
the back buffer associated with this window

◆ getHeight()

int getHeight ( ) const

Returns the height of the window. Note that on high DPI monitors this is not the same as the pixel count. To get the height in pixels use the size of the backbuffer using getHeightPixels().

Returns
the height of the window in pixels

◆ getHeightPixels()

int getHeightPixels ( ) const

Returns the height of this window in pixels.

Returns
the width of the window in pixels.

◆ getNumber()

virtual uint getNumber ( ) const
overridevirtual
Returns
the hardware window number

Implements Window.

◆ getPosition()

const glm::ivec2 getPosition ( ) const
Returns
the window position in pixel coordinates

◆ getRect()

math::Rect getRect ( ) const

Creates a rectangle based on the current width and height of the render window. Note that the returned dimensions of the rectangle can differ from the actual size in pixels on a high dpi monitor. To obtain a rectangle that contains the actual size of the window in pixels use: getRectPixels

Returns
the window as a rectangle

◆ getRectPixels()

math::Rect getRectPixels ( ) const

Creates a rectangle based on the current width and height of the render window in pixels.

Returns
the window as rectangle

◆ getTitle()

const std::string& getTitle ( ) const
Returns
the window title

◆ getWidth()

int getWidth ( ) const

Returns the width of the window. Note that on high DPI monitors this is not the same as the pixel count. To get the width in pixels use the size of the backbuffer using getWidthPixels().

Returns
the width of the window

◆ getWidthPixels()

int getWidthPixels ( ) const

Returns the width of this window in pixels.

Returns
the width of the window in pixels.

◆ getWindow()

GLWindow* getWindow ( ) const
Returns
the window managed by this component

◆ hide()

void hide ( )

Hides the window

◆ init()

virtual bool init ( utility::ErrorState errorState)
overridevirtual

Creates window, connects to resize event.

Reimplemented from Object.

◆ isResizable()

bool isResizable ( ) const
Returns
if the window is resizable

◆ makeActive()

void makeActive ( )

Makes this window active, calls activate afterwards

◆ setFullscreen()

void setFullscreen ( bool  value)

Turns full screen on / off This is the windowed full screen mode, game is not supported

Parameters
valueif the window is set to fill the screen or not

◆ setHeight()

void setHeight ( int  height)

Sets the height of the window. When the window is drawn on a high DPI monitor the pixel count of the window buffer will be higher.

Parameters
heightthe new window height in pixels

◆ setPosition()

void setPosition ( const glm::ivec2 &  position)

Sets the position of the window on screen

Parameters
positionthe new screen position in pixel coordinates

◆ setWidth()

void setWidth ( int  width)

Sets the width of the window. When the window is drawn on a high DPI monitor the resulting pixel count of the window buffer will be higher.

Parameters
widththe new width of the window in pixels

◆ show()

void show ( )

Shows the window and gives it input focus. This call also makes sure the window is on top of other windows.

◆ swap()

void swap ( ) const

Swaps window buffers

◆ toggleFullscreen()

void toggleFullscreen ( )

Toggles full screen on / off

Member Data Documentation

◆ mBorderless

bool mBorderless = false

Property: 'Borderless' if the window has any borders.

◆ mClearColor

glm::vec4 mClearColor = { 0.0f, 0.0f, 0.0f, 1.0f }

Property: 'ClearColor' background clear color.

◆ mHeight

int mHeight = 512

Property: 'Height' of the window in pixels.

◆ mResizable

bool mResizable = true

Property: 'Resizable' if the window is resizable.

◆ mSync

bool mSync = true

Property: 'Sync' If v-sync is enabled.

◆ mTitle

std::string mTitle = ""

Property: 'Title' window title.

◆ mWidth

int mWidth = 512

Property: 'Width' of the window in pixels.