Jopnal Engine  alpha 0.4
Simple Component Based 2D/3D Game Engine
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
jop::Window Class Reference

#include <Window.hpp>

Inheritance diagram for jop::Window:
jop::RenderTarget jop::Subsystem

Classes

struct  Settings
 

Public Types

enum  DisplayMode { DisplayMode::Windowed, DisplayMode::Borderless, DisplayMode::Fullscreen }
 
- Public Types inherited from jop::RenderTarget
enum  { ColorBit = 1, DepthBit = 1 << 1, StencilBit = 1 << 2, AllBit = ColorBit | DepthBit | StencilBit }
 

Public Member Functions

 Window ()
 Default constructor. More...
 
 Window (const Settings &settings)
 Overloaded constructor. More...
 
 ~Window () override
 Destructor. More...
 
void preUpdate (const float deltaTime) override
 Pre-update. More...
 
void postUpdate (const float deltaTime) override
 Post-update. More...
 
void draw () override
 Draw. More...
 
bool bind () const override
 Bind this render target for drawing. More...
 
void open (const Settings &settings)
 Open this window. More...
 
void close ()
 Close and destroy this window. More...
 
bool isOpen () const
 Check if this window is open. More...
 
template<typename T , typename... Args>
T & setEventHandler (Args &&...args)
 Set the event handler. More...
 
void setDefaultEventHandler ()
 Set the default handler. More...
 
WindowEventHandlergetEventHandler ()
 Get the event handler. More...
 
void removeEventHandler ()
 Remove and delete the event handler. More...
 
WindowLibHandle getLibraryHandle ()
 Get the window library handle handle. More...
 
WindowHandle getNativeHandle ()
 Get the native window handle. More...
 
void setMouseMode (const Mouse::Mode mode)
 Set the mouse mode. More...
 
void setPosition (const int x, const int y)
 Set the window position. More...
 
glm::ivec2 getPosition () const
 Get the window position. More...
 
void setSize (const int width, const int height)
 Set the window size. More...
 
glm::uvec2 getSize () const override
 Get the size of the window. More...
 
- Public Member Functions inherited from jop::RenderTarget
 RenderTarget ()
 Constructor. More...
 
virtual ~RenderTarget ()=0
 Virtual destructor. More...
 
void clear (const unsigned int bits)
 Clear the selected buffers. More...
 
RenderTargetsetClearColor (const Color &color)
 Set the clear color. More...
 
Color getClearColor () const
 Get the clear color. More...
 
RenderTargetsetClearDepth (const float depth)
 Set the clear depth. More...
 
float getClearDepth () const
 Get the clear depth value. More...
 
RenderTargetsetClearStencil (const int stencil)
 Set the clear stencil. More...
 
int getClearStencil () const
 Get the clear stencil value. More...
 
- Public Member Functions inherited from jop::Subsystem
 Subsystem (const uint32 ID)
 Constructor. More...
 
virtual ~Subsystem ()=0
 Virtual destructor. More...
 
Message::Result sendMessage (const Message &message)
 Function to handle messages. More...
 
SubsystemsetActive (const bool active)
 Set this sub system active. More...
 
bool isActive () const
 Check if this sub system is active. More...
 
uint32 getID () const
 Get the ID. More...
 

Static Public Member Functions

static void pollEvents ()
 Poll the events of all open windows. More...
 

Additional Inherited Members

- Protected Attributes inherited from jop::RenderTarget
std::recursive_mutex m_mutex
 Mutex. More...
 

Detailed Description

Definition at line 68 of file Window/Window.hpp.

Member Enumeration Documentation

Display modes

Enumerator
Windowed 

Windowed with decorations.

Borderless 

Windowed without decorations.

Fullscreen 

Full screen.

Definition at line 80 of file Window/Window.hpp.

Constructor & Destructor Documentation

jop::Window::Window ( )

Default constructor.

Does not open a window.

jop::Window::Window ( const Settings settings)

Overloaded constructor.

Calls open() using the given settings.

Parameters
settingsThe window settings
jop::Window::~Window ( )
override

Destructor.

Member Function Documentation

bool jop::Window::bind ( ) const
overridevirtual

Bind this render target for drawing.

Returns
True if successful

Implements jop::RenderTarget.

void jop::Window::close ( )

Close and destroy this window.

If no window is open, this does nothing.

void jop::Window::draw ( )
overridevirtual

Draw.

This simply swaps the OpenGL buffers and displays the current back buffer.

Reimplemented from jop::Subsystem.

WindowEventHandler* jop::Window::getEventHandler ( )

Get the event handler.

Returns
Reference to the event handler. nullptr if the window hasn't been opened
WindowLibHandle jop::Window::getLibraryHandle ( )

Get the window library handle handle.

On desktop operating systems this is GLFWwindow*.

Returns
A pointer to the handle. nullptr if the window hasn't been opened
WindowHandle jop::Window::getNativeHandle ( )

Get the native window handle.

Returns
The native window handle. nullptr if the window hasn't been opened
glm::ivec2 jop::Window::getPosition ( ) const

Get the window position.

Returns
The window position
glm::uvec2 jop::Window::getSize ( ) const
overridevirtual

Get the size of the window.

This is the size of the window's frame buffer.

Returns
Size of the window

Implements jop::RenderTarget.

bool jop::Window::isOpen ( ) const

Check if this window is open.

Returns
True if the window is open
void jop::Window::open ( const Settings settings)

Open this window.

This will create a new window. If one already exists, it will be replaced.

Parameters
settingsThe window settings
static void jop::Window::pollEvents ( )
static

Poll the events of all open windows.

This will poll all events and invoke the appropriate callbacks.

void jop::Window::postUpdate ( const float  deltaTime)
overridevirtual

Post-update.

This clears the OpenGL front buffer

Reimplemented from jop::Subsystem.

void jop::Window::preUpdate ( const float  deltaTime)
overridevirtual

Pre-update.

This will simply set an internal boolean flag so we know when a new frame has begun.

Reimplemented from jop::Subsystem.

void jop::Window::removeEventHandler ( )

Remove and delete the event handler.

After this call, there won't be a valid event handler.

See also
setDefaultEventHandler()
void jop::Window::setDefaultEventHandler ( )

Set the default handler.

The default event handler has no functionality other than exiting the engine when the close button is clicked.

On android the default handler exits the engine when the "back" button is pressed.

template<typename T , typename... Args>
T& jop::Window::setEventHandler ( Args &&...  args)

Set the event handler.

This function will automatically pass a reference of this window into the handler's constructor.

Parameters
argsThe arguments to use with construction
Returns
Reference to the newly created event handler
void jop::Window::setMouseMode ( const Mouse::Mode  mode)

Set the mouse mode.

Parameters
modeThe mouse mode
See also
Mouse::Mode
void jop::Window::setPosition ( const int  x,
const int  y 
)

Set the window position.

Parameters
xThe X coordinate
yThe Y coordinate
void jop::Window::setSize ( const int  width,
const int  height 
)

Set the window size.

This will set the size of the client area.

Parameters
widthNew width
heightNew height

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