![]() |
Jopnal Engine
alpha 0.4
Simple Component Based 2D/3D Game Engine
|
#include <Engine.hpp>
Public Types | |
enum | State { State::Running, State::RenderOnly, State::Frozen } |
Engine state. More... | |
Public Member Functions | |
Engine (const std::string &projectName, int argc, char *argv[]) | |
Constructor. More... | |
~Engine () | |
Destructor. More... | |
void | loadDefaultConfiguration () |
Load the default subsystem configuration. More... | |
Static Public Member Functions | |
static int | runMainLoop () |
Run the main loop. More... | |
static void | advanceFrame () |
Advance a single frame. More... | |
template<typename T , bool Threaded = false, bool WaitSignal = false, typename... Args> | |
static void | createScene (Args &&...args) |
Create a new scene. More... | |
static bool | hasCurrentScene () |
Check if there's a current scene. More... | |
static Scene & | getCurrentScene () |
Get the current scene. More... | |
static bool | signalNewScene () |
Signal a new scene (loaded in a threaded manner) to set itself current. More... | |
static bool | newSceneReady () |
Check if a scene has been loaded and is ready to be set current. More... | |
template<typename T , typename... Args> | |
static T & | createSubsystem (Args &&...args) |
Create a subsystem. More... | |
template<typename T > | |
static T * | getSubsystem () |
Get a subsystem using type info. More... | |
template<typename T > | |
static T * | getSubsystem (const uint32 ID) |
Get a subsystem using subsystem ID and type info. More... | |
template<typename T > | |
static bool | removeSubsystem (const uint32 ID) |
Remove a subsystem. More... | |
static bool | exiting () |
Check if the engine is signaled to exit. More... | |
static void | exit () |
Exit the main loop. More... | |
static void | setState (const State state) |
Set the engine state. More... | |
static State | getState () |
Get the engine state. More... | |
static RenderTarget & | getMainRenderTarget () |
Get the main render target. More... | |
static Window & | getMainWindow () |
Get the main window. More... | |
static bool | hasMainWindow () |
Check if there's a main window. More... | |
static Message::Result | sendMessage (const Message &message) |
Send a message to the whole engine. More... | |
static Scene & | getSharedScene () |
Get the shared scene. More... | |
static bool | hasSharedScene () |
Check if a shared scene exists. More... | |
template<typename T , typename... Args> | |
static T & | setSharedScene (Args &&...args) |
Set the shared scene. More... | |
static double | getTotalTime () |
Get the total time since Engine construction. More... | |
static float | getDeltaTimeUnscaled () |
Get the current actual/unscaled delta time. More... | |
Definition at line 52 of file Engine.hpp.
|
strong |
Engine state.
No matter the state, sub systems will always be running normally.
Enumerator | |
---|---|
Running |
Run normally. |
RenderOnly |
Only render, don't update. |
Frozen |
No rendering or updating. |
Definition at line 65 of file Engine.hpp.
jop::Engine::Engine | ( | const std::string & | projectName, |
int | argc, | ||
char * | argv[] | ||
) |
Constructor.
This will initialize the engine and all associated systems. Project name must not be empty, as it will be used to create the necessary config directories.
The engine object must stay alive until exit is called and the main loop is returned from.
projectName | The project name |
argc | Number of arguments passed from main() |
argv | The argument array passed from main() |
jop::Engine::~Engine | ( | ) |
Destructor.
This will deinitialize the engine, so that the program can exit.
|
static |
Advance a single frame.
When state is Running, this function has no effect.
|
static |
Create a new scene.
This function will construct the scene and then set it as active. The previously active scene will be discarded and deleted.
If Threaded is true, the scene will be loaded in a separate thread, while the old one is left running. If WaitSignal is false, the new scene will be set current as soon as it's loaded. If WaitSignal is true, you'll need to call signalNewScene to set it active.
args | The arguments to be used in the scene's construction |
|
static |
Create a subsystem.
args | The arguments to be used in the subsystem's construction |
|
static |
Exit the main loop.
This function will have no effect if no jop::Engine exists at the time of the call. The main loop returns only after the current frame has been processed.
|
static |
Check if the engine is signaled to exit.
This will also be true when the engine hasn't been loaded yet.
|
static |
Get the current scene.
This function asserts that the scene has been loaded first with createScene().
|
static |
Get the current actual/unscaled delta time.
Use this if you need the real delta time value, which is unaffected by the scene's delta scale.
|
static |
Get the main render target.
This can be either MainRenderTarget or Window.
|
static |
Get the main window.
This function asserts that the window has been created first. This will be done automatically by loadDefaultConfiguration().
|
static |
Get the shared scene.
The shared scene exists for the purpose of being able to have objects that are shared between scenes. This makes it possible to have general-purpose functionality without having to take care of it in every scene separately.
|
static |
Get a subsystem using type info.
|
static |
Get a subsystem using subsystem ID and type info.
ID | The identifier to search with |
|
static |
Get the total time since Engine construction.
|
static |
Check if there's a current scene.
|
static |
Check if there's a main window.
|
static |
Check if a shared scene exists.
void jop::Engine::loadDefaultConfiguration | ( | ) |
Load the default subsystem configuration.
|
static |
Check if a scene has been loaded and is ready to be set current.
If a scene wasn't previously loaded with a thread, this function will always return false.
|
static |
Remove a subsystem.
ID | Identifier of the subsystem to be removed |
|
static |
Run the main loop.
The main loop will run until exit() is called.
|
static |
Send a message to the whole engine.
The message will be forwarded everywhere. This function is identical to jop::broadcast().
message | The message |
|
static |
Set the shared scene.
This will immediately replace the previous shared scene with a new one of the given type. Threaded loading is not supported at this time.
args | Arguments to use in the scene's construction |
|
static |
Set the engine state.
state | The new state to set |
|
static |
Signal a new scene (loaded in a threaded manner) to set itself current.
If a scene wasn't previously loaded with a thread, this function has no effect.