|
Deki 1.3.0
Modular C++ 2D engine for embedded displays and desktop
|
Engine singleton: owns the scene system, lifecycle and frame loop. More...
#include <DekiEngine.h>
Public Member Functions | |
| const DekiEngineHost & | GetHost () const |
| void | Shutdown () |
| Shutdown the game engine and free resources. | |
| void | Update (uint32_t deltaTime) |
| Update game logic and animations (called every frame). | |
| void | ProcessLifecycle () |
| Process lifecycle methods on the active scene Handles Awake, Start, Update and detects scene changes during lifecycle. | |
| void | Render () |
| Render the current scene to internal buffer. | |
| void | PresentFrame () |
| Present the render system's framebuffer through the display. | |
| void | RequestFullRefresh () |
| Make the next present cover the whole screen (the display's own RequestFullRefresh included). | |
| size_t | RegisterUpdate (const UpdateCallback &callback) |
| Register an update callback to be called each frame. | |
| void | UnregisterUpdate (size_t id) |
| Remove a callback registered with RegisterUpdate. | |
| void | RunUpdateCallbacks (uint32_t deltaTime) |
| Run the registered update callbacks once. | |
| void | SetRootScene (Scene *scene, bool takeOwnership=true) |
| Set the current root scene. | |
| Scene * | GetRootScene () const |
| Get the current root scene. | |
| Scene * | CreateScene () |
| Create a new empty scene. | |
| IDekiRenderSystem & | GetRenderer () const |
| Get the renderer instance. | |
| SceneSystem & | GetSceneSystem () const |
| Get the scene system instance. | |
| LifecycleManager * | GetLifecycleManager () const |
| Get the lifecycle manager instance. | |
| IDekiRenderSystem * | GetRenderSystem () const |
| Get the render system instance. | |
| void | SetRenderSystem (IDekiRenderSystem *rs) |
| Set the render system (called by rendering package during registration). | |
| IDekiInputSystem * | GetInputSystem () const |
| Get the input system instance. | |
| void | SetInputSystem (IDekiInputSystem *is) |
| Set the input system (called by input package during registration). | |
| IDekiDisplay * | GetDisplay () const |
| Get the active display. | |
| void | SetDisplay (IDekiDisplay *display, const std::string &name="") |
| Register the active display (called by SDL3Display, LovyanGFXDisplay, EditorDisplay, etc. | |
| const std::string & | GetDisplayName () const |
| Display name set by the registering package (e.g. | |
| bool | IsDisplayInitialized () const |
| True iff a display has been registered AND its IsInitialized() is true. | |
| bool | IsInitialized () const |
| Check if the game engine is initialized. | |
| void | SetGameUpdateCallback (const GameUpdateCallback &callback) |
| Set the game update callback for game logic updates. | |
| void | SetTargetFPS (uint32_t fps) |
| Set the target FPS for the main loop. | |
| void | RunMainLoop () |
| Run the main game loop This handles timing, platform updates, rendering, and callbacks. | |
| void | StopMainLoop () |
| Stop the main game loop. | |
| bool | IsRunning () const |
| Check if the main loop is running. | |
| void | MarkDirty () |
| Mark the engine as dirty (needs redraw). | |
| bool | IsDirty () const |
| Check if engine needs redraw. | |
| const uint8_t * | GetFrameBuffer () const |
| int32_t | GetScreenWidth () const |
| int32_t | GetScreenHeight () const |
| DekiColorFormat | GetFrameBufferFormat () const |
| DekiEngineSettings & | GetSettings () |
| Get engine settings. | |
| const DekiEngineSettings & | GetSettings () const |
Static Public Member Functions | |
| static DekiEngine & | GetInstance () |
| Get the singleton instance of DekiEngine. | |
| static bool | Initialize () |
| Initialize the engine from the active project settings. | |
| static bool | Initialize (const DekiEngineHost &host) |
| Initialize the engine for an explicit host configuration. | |
| static bool | IsRuntimeMode () |
| Check if the engine is in runtime mode (play mode or device). | |
| static void | SetRuntimeMode (bool runtime) |
| Set runtime mode (called by editor play mode init/shutdown). | |
Engine singleton: owns the scene system, lifecycle and frame loop.
Holds the active scene graph via SceneSystem, drives the DekiBehaviour lifecycle (PreRender, Start, Update) through LifecycleManager, and dispatches to whichever render, input and display providers a package has installed — all four are optional, so a headless or editor-hosted engine is the same class with null providers.
|
static |
Get the singleton instance of DekiEngine.
|
static |
Initialize the engine from the active project settings.
Picks the host configuration for this build: DekiEngineHost::Editor() in editor builds, DekiEngineHost::Device() otherwise.
|
static |
Initialize the engine for an explicit host configuration.
|
inline |
| void DekiEngine::Shutdown | ( | ) |
Shutdown the game engine and free resources.
| void DekiEngine::Update | ( | uint32_t | deltaTime | ) |
Update game logic and animations (called every frame).
| deltaTime | Time since last update in milliseconds |
| void DekiEngine::ProcessLifecycle | ( | ) |
Process lifecycle methods on the active scene Handles Awake, Start, Update and detects scene changes during lifecycle.
| void DekiEngine::Render | ( | ) |
Render the current scene to internal buffer.
| void DekiEngine::PresentFrame | ( | ) |
Present the render system's framebuffer through the display.
Only the rectangles the render system reports as changed are pushed when the display can present partial frames (IDekiRenderSystem:: GetPresentRects + IDekiDisplay::PresentRegions); otherwise the whole frame. Every present in the engine goes through here.
| void DekiEngine::RequestFullRefresh | ( | ) |
Make the next present cover the whole screen (the display's own RequestFullRefresh included).
| size_t DekiEngine::RegisterUpdate | ( | const UpdateCallback & | callback | ) |
Register an update callback to be called each frame.
| callback | Function to call during update |
| void DekiEngine::UnregisterUpdate | ( | size_t | id | ) |
Remove a callback registered with RegisterUpdate.
| id | The value RegisterUpdate returned |
A package DLL that registers a callback MUST unregister it before it unloads, or the engine calls into unmapped code on the next frame.
| void DekiEngine::RunUpdateCallbacks | ( | uint32_t | deltaTime | ) |
Run the registered update callbacks once.
| deltaTime | Milliseconds since the previous call |
Update() does this itself. Hosts that drive the lifecycle by hand (the editor's play mode) call it so package systems (tweens, ...) tick there exactly as they do on a device.
| void DekiEngine::SetRootScene | ( | Scene * | scene, |
| bool | takeOwnership = true ) |
Set the current root scene.
| scene | Pointer to the scene to set as root |
| takeOwnership | If true, engine will delete the scene when replaced or on shutdown |
| Scene * DekiEngine::GetRootScene | ( | ) | const |
Get the current root scene.
| Scene * DekiEngine::CreateScene | ( | ) |
Create a new empty scene.
|
inline |
Get the renderer instance.
|
inline |
Get the scene system instance.
|
inline |
Get the lifecycle manager instance.
|
inline |
Get the render system instance.
|
inline |
Set the render system (called by rendering package during registration).
| rs | Pointer to the render system (package owns lifetime) |
|
inline |
Get the input system instance.
|
inline |
Set the input system (called by input package during registration).
| is | Pointer to the input system (package owns lifetime) |
|
inline |
Get the active display.
Set at runtime by a display integration package via SetDisplay(). nullptr if no display package is loaded.
| void DekiEngine::SetDisplay | ( | IDekiDisplay * | display, |
| const std::string & | name = "" ) |
Register the active display (called by SDL3Display, LovyanGFXDisplay, EditorDisplay, etc.
at package load).
The package owns the display instance's lifetime. Engine-core only stores the pointer + a name (for diagnostics) and re-runs the render system's Setup() so it can pick up a display-owned DMA buffer if available.
|
inline |
Display name set by the registering package (e.g.
"SDL3").
|
inline |
True iff a display has been registered AND its IsInitialized() is true.
|
inline |
Check if the game engine is initialized.
|
static |
Check if the engine is in runtime mode (play mode or device).
In runtime mode, components follow the device code path: no editor GUID sync, no font preview, no on-demand baking. On device (!DEKI_EDITOR), always returns true. In editor, returns true only during play mode.
|
static |
Set runtime mode (called by editor play mode init/shutdown).
| void DekiEngine::SetGameUpdateCallback | ( | const GameUpdateCallback & | callback | ) |
Set the game update callback for game logic updates.
| callback | Function to call for game logic updates |
| void DekiEngine::SetTargetFPS | ( | uint32_t | fps | ) |
Set the target FPS for the main loop.
| fps | Target frames per second (default: 30) |
| void DekiEngine::RunMainLoop | ( | ) |
Run the main game loop This handles timing, platform updates, rendering, and callbacks.
| void DekiEngine::StopMainLoop | ( | ) |
Stop the main game loop.
|
inline |
Check if the main loop is running.
|
inline |
Mark the engine as dirty (needs redraw).
|
inline |
Check if engine needs redraw.
| const uint8_t * DekiEngine::GetFrameBuffer | ( | ) | const |
| int32_t DekiEngine::GetScreenWidth | ( | ) | const |
| int32_t DekiEngine::GetScreenHeight | ( | ) | const |
| DekiColorFormat DekiEngine::GetFrameBufferFormat | ( | ) | const |
|
inline |
Get engine settings.
|
inline |