Class Engine
Defined in File Engine.hpp
Nested Relationships
Nested Types
Class Documentation
-
class Engine
Core engine systems singleton.
Public Types
Public Functions
-
inline const InitConfig &GetInitConfig() const
Get an immutable reference to the initialization config values.
- Returns:
The initialization config values
-
const std::filesystem::path GetDataDirectory()
Get a path to the data directory where logs and game data should be stored.
This path will be created if it does not exist when this function is called
- Returns:
Data directory path
-
std::shared_ptr<exathread::Pool> GetThreadPool()
Get access to the engine thread pool.
See also
https://robotleopard86.github.io/Exathread/stable for the documentation on how to use the pool
- Throws:
BadStateException – If the thread pool is not running
- Returns:
A handle to the pool
Run a task on the main thread.
- Parameters:
func – The task to execute
args – The arguments to the task function
- Throws:
BadStateException – If the engine is not in the Running state
- Returns:
A future that will be fulfilled when the task completes
-
void CoreInit(const InitConfig &initCfg)
Initialize all engine systems that don’t require graphics or windowing.
The engine must be in the Dead state when this method is called
-
void GfxInit()
Initialize the graphics backend and windowing system.
The engine must be in the Alive state when this method is called
-
void Run()
Perform any final pre-run tasks and start the game loop.
The engine must be in the Ready state when this method is called
-
void GfxShutdown()
Shutdown windowing and graphics systems.
Any GPU resources still existing at this time will be destroyed via appropriate functions before shutdown
The engine must be in the Ready state when this method is called
-
void CoreShutdown()
Shutdown all engine systems that don’t require graphics or windowing.
After this function is called, the process may be safely exited or the engine may be re-initialized
The engine must be in the Alive state when this method is called
-
inline State GetState()
Get the current state of the engine.
- Returns:
The engine state
Public Static Functions
-
static Engine &Get()
Get the instance and create one if there isn’t one.
- Returns:
The instance
-
struct InitConfig
Configuration values that are set for startup and cannot be modified afterwards.
Public Members
-
std::string initialRequestedBackend
The requested backend to try to initialize first, overriding the default setting.
-
std::string preferredWindowProvider
The preferred windowing provider to use.
The available options are:
win32Windows API (Windows only)cocoaCocoa (MacOS only)x11X11 via XCB (Linux only)waylandWayland (Linux only)
Note
If the provider requested is not available or this string is empty, default behavior will be used
-
ClientIdentity clientID
ID of the client application. This should be in reverse-domain format with a PascalCase final segment (e.g. com.example.MyGame), but this is not enforced.
-
bool startFrameProcessorWithGfxSystem
Whether to start the frame processor with the graphics system or to start it when the engine starts running.
This is set to
falseby default, which is best for games. However, other users may want to continue rendering without an active gameloop, thus this option exists.
-
std::string initialRequestedBackend
-
inline const InitConfig &GetInitConfig() const