OpenEnroth 73e68f7
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
Platform Class Referenceabstract

#include <Platform.h>

Inheritance diagram for Platform:
ProxyBase< Platform > NullPlatform SdlPlatform ProxyPlatform ApplicationProxy EngineDeterministicComponent

Public Member Functions

virtual ~Platform ()=default
 
virtual std::unique_ptr< PlatformWindowcreateWindow ()=0
 
virtual std::unique_ptr< PlatformEventLoopcreateEventLoop ()=0
 
virtual std::vector< PlatformGamepad * > gamepads ()=0
 
virtual void setCursorShown (bool cursorShown)=0
 
virtual bool isCursorShown () const =0
 
virtual std::vector< RectidisplayGeometries () const =0
 
virtual void showMessageBox (const std::string &title, const std::string &message) const =0
 
virtual int64_t tickCount () const =0
 

Static Public Member Functions

static std::unique_ptr< PlatformcreateStandardPlatform ()
 

Detailed Description

Platform abstraction layer.

Platform classes can be broadly divided into three categories:

API handles exposed by the platform are:

Then there are the following extension points:

That's it, there is only one extension point. If you want fancy event handler chains, you can use FilteringEventHandler.

And then there are value types:

All platform classes don't throw but write errors to log instead. See per-method docs for details on how errors are reported by each method.

Also platform declares its own main function, so you cannot declare main in your code. Platform expects you to define platformMain instead.

Some guidelines on adding new functionality to platform classes:

See also
platformMain

Constructor & Destructor Documentation

◆ ~Platform()

virtual Platform::~Platform ( )
virtualdefault

Member Function Documentation

◆ createEventLoop()

virtual std::unique_ptr< PlatformEventLoop > Platform::createEventLoop ( )
pure virtual

Creates a new event loop.

Returns
Newly created event loop, or nullptr on error.

Implemented in ApplicationProxy, NullPlatform, ProxyPlatform, and SdlPlatform.

◆ createStandardPlatform()

std::unique_ptr< Platform > Platform::createStandardPlatform ( )
static

Creates a standard platform.

Returns
A newly created Platform. This method is guaranteed to succeed.

◆ createWindow()

virtual std::unique_ptr< PlatformWindow > Platform::createWindow ( )
pure virtual

Creates a new platform window.

Returns
Newly created window, or nullptr on error.

Implemented in ApplicationProxy, NullPlatform, ProxyPlatform, and SdlPlatform.

◆ displayGeometries()

virtual std::vector< Recti > Platform::displayGeometries ( ) const
pure virtual
Returns
Geometries of all monitors on current system, or an empty vector in case of an error.

Implemented in NullPlatform, ProxyPlatform, and SdlPlatform.

◆ gamepads()

virtual std::vector< PlatformGamepad * > Platform::gamepads ( )
pure virtual

This function lists the gamepads currently connected to the system. The gamepad objects themselves are owned by the platform and are destroyed automatically when disconnected. If you're caching them in your code, then make sure to subscribe to EVENT_GAMEPAD_DISCONNECTED, it is guaranteed to fire before the gamepad object is destroyed.

Returns
All gamepads connected to the system.

Implemented in NullPlatform, ProxyPlatform, and SdlPlatform.

◆ isCursorShown()

virtual bool Platform::isCursorShown ( ) const
pure virtual

Getter for setCursorShown.

Returns
Whether the system cursor is currently shown on top of windows created by this platform.

Implemented in NullPlatform, ProxyPlatform, and SdlPlatform.

◆ setCursorShown()

virtual void Platform::setCursorShown ( bool  cursorShown)
pure virtual

Shows / hides system cursor (on top of all windows created by this platform).

Parameters
cursorShownWhether to show the system cursor.

Implemented in NullPlatform, ProxyPlatform, and SdlPlatform.

◆ showMessageBox()

virtual void Platform::showMessageBox ( const std::string &  title,
const std::string &  message 
) const
pure virtual

Shows a modal message box.

Parameters
titleTitle of the message box window.
messageMessage to display.

Implemented in NullPlatform, ProxyPlatform, and SdlPlatform.

◆ tickCount()

virtual int64_t Platform::tickCount ( ) const
pure virtual
Returns
Current value of a monotonic clock in milliseconds.

Implemented in EngineDeterministicComponent, NullPlatform, ProxyPlatform, and SdlPlatform.


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