Engine
Derives from MObject so the GC sees it as a discoverable root. The ctor roots it; MObject::~MObject auto-unroots via Unregister.
- Module
- MowoEngine
- Header
#include "Core/Engine.h"- Namespace
Mowo
Type aliases
| Alias | Description |
|---|---|
using InitProgressFn = std::function<void(const char* label, float fraction)> | Set before Initialize(). The engine reports coarse startup stages (label, 0..1 fraction) for a splash status bar. No-op if unset. |
using OverlayCallback = std::function<void()> | Registered by editor/runtime overlay systems (Arc). |
using FrameUpdateCallback = std::function<void(float dt)> | Called once per frame for app-level logic, before Tick. |
using IdlePredicate = std::function<bool()> |
Properties
| Type | Name | Description |
|---|---|---|
static constexpr int | kExitDeviceLost | What the host should exit with once the loop ends: kExitDeviceLost after a GPU device loss, else 0. A lost device used to end in exit 0 with plausible metrics, which a harness read as a fast successful run. Default 4. |
Constructors
Public functions
| Returns | Name | Description |
|---|---|---|
Engine* | GetGEngine | Process-wide Engine accessor. |
bool | Initialize | |
void | Shutdown | |
bool | WriteRunMetrics | Writes the run record --metrics=<file> asks for (Shutdown calls it): frame-time distribution plus everything that decides whether two records are comparable — build configuration, commit, RHI and seed. |
int | GetRunExitCode | |
void | LoadFeatureModules | Loads the engine systems that sit above this umbrella (AI, sequencer, destruction, ...) by name. |
void | Run | |
void | SetInitProgressCallback | |
void | ReportInitProgress | |
void | Tick | Per-frame app logic. |
void | Draw | App-level UI submission. |
void | RouteEvent | Pre-dispatch, before EventBus subscribers see the event. |
void | OnShadersReloaded | Fires after a shader hot-reload that changed at least one shader. |
void | OnCoreInitialized | Runs inside Initialize once logging, cvars and the object-system resolvers are up, before config, memory, physics, audio, the window or the device start. |
void | OnEnterBackground | Mobile app lifecycle (M2.4). |
void | OnEnterForeground | |
bool | IsInBackground | True while the OS holds the app in background: no frames render, the loop idles. |
bool | IsRenderPaused | The frame-captured render gate Engine::Run used THIS frame: minimized OR backgrounded. |
Window* | GetWindow | |
InputManager* | GetInput | |
World* | GetWorld | |
VFS* | GetVFS | |
SceneManager* | GetScenes | |
Scene* | GetActiveScene | |
bool | IsRunning | |
void | Stop | |
T* | GetSubsystem | Auto-instanced MEngineSubsystem singletons, each living as long as the engine. |
void | ForEachSubsystem | Visit every live subsystem in registration order. |
void | SetAutoSyncCursorLock | In standalone Runtime, Engine::Run mirrors game code's Input.CursorLocked into Window::SetMouseCapture every frame. |
bool | IsAutoSyncCursorLockEnabled | |
void | RequestShaderReload | The reload is APPLIED at the top of the next frame, before Renderer::BeginFrame — never while a command buffer records. |
void | SetShaderHotReloadEnabled | Watches the loose Shaders/ overlay (CWD-relative, the same folder the native VFS mount serves) and requests a reload when mbt shaders --watch drops fresh blobs there. |
bool | IsShaderHotReloadEnabled | |
void | PollShaderWatch | One scan of the overlay on the caller; it requests a reload once a change has held still for a whole scan. |
bool | ConsumeShaderReloadRequest | |
float | GetDeltaTime | |
float | GetTotalTime | |
void | TickTimer | |
bool | HasPendingResize | |
void | LoadScene | |
void | SetOverlayBeginFrame | |
void | SetOverlayEndFrame | |
void | SetOverlayRenderDrawData | |
void | SetOverlayRenderViewports | |
void | SetOverlayDrawFrame | |
void | OverlayBeginFrame | |
void | OverlayEndFrame | |
void | OverlayRenderDrawData | |
void | OverlayRenderViewports | |
void | OverlayDrawFrame | |
void | SetFrameUpdateCallback | |
void | SetIdlePredicate | |
EFrameThrottle | GetFrameThrottle | |
int | GetFrameThrottleHz | |
int | GetIdleFrameRateHz | The idle cap this host was configured with; 0 = never throttles idle. |
void | SetRenderAhead | Hosts whose frame path owns the publish-time render fence (the overlap pipeline) disable the loop-top render-thread drain with this. |
Function details
Engine
Engine()~Engine
~Engine() overrideGetGEngine
static Engine* GetGEngine()Process-wide Engine accessor. Set by Engine::Initialize, cleared by Engine::Shutdown; nullptr before init and after shutdown.
Initialize
bool Initialize(const EngineConfig& config = EngineConfig())Shutdown
void Shutdown()WriteRunMetrics
static bool WriteRunMetrics(const std::string& path)Writes the run record --metrics=<file> asks for (Shutdown calls it): frame-time distribution plus everything that decides whether two records are comparable — build configuration, commit, RHI and seed.
GetRunExitCode
static int GetRunExitCode()LoadFeatureModules
static void LoadFeatureModules()Loads the engine systems that sit above this umbrella (AI, sequencer, destruction, ...) by name. They depend on the engine, so the engine cannot link them; every host calls this before plugins load so their components and scene systems are registered before any scene deserializes. Missing binaries are skipped: a NoOnline player ships without the online ones.
Run
void Run()SetInitProgressCallback
void SetInitProgressCallback(InitProgressFn fn)ReportInitProgress
void ReportInitProgress(const char* label, float fraction)Tick
virtual void Tick(float dt)Per-frame app logic. Runs after the engine-core update (input, world, events, jobs) and before UI submission.
Draw
virtual void Draw()App-level UI submission. Runs between the overlay Begin/EndFrame callbacks.
RouteEvent
virtual void RouteEvent(Event& e)Pre-dispatch, before EventBus subscribers see the event.
OnShadersReloaded
virtual void OnShadersReloaded(uint32_t changedShaders)Fires after a shader hot-reload that changed at least one shader. Runs at the top of the frame, before Renderer::BeginFrame.
OnCoreInitialized
virtual void OnCoreInitialized()Runs inside Initialize once logging, cvars and the object-system resolvers are up, before config, memory, physics, audio, the window or the device start. Work that needs only static-init state (the MClass registry, FMObjectArray) goes here so it still reports when a later stage fails to come up.
OnEnterBackground
virtual void OnEnterBackground()Mobile app lifecycle (M2.4). EnterBackground runs AFTER the GPU is idled and before the frame loop pauses — flush saves here, the process may never run again on iOS. EnterForeground runs before the first resumed frame. Both also broadcast through FCoreDelegates so game code can subscribe without subclassing.
OnEnterForeground
virtual void OnEnterForeground()IsInBackground
bool IsInBackground() constTrue while the OS holds the app in background: no frames render, the loop idles. Never true on desktop.
IsRenderPaused
bool IsRenderPaused() constThe frame-captured render gate Engine::Run used THIS frame: minimized OR backgrounded. Hosts must gate their scene recording on this, not on Window::IsMinimized() alone — a background transition skips BeginFrame without minimizing the window, and recording into the never-begun main command buffer is a crash.
GetWindow
Window* GetWindow() constGetInput
InputManager* GetInput() constGetWorld
World* GetWorld() constGetVFS
VFS* GetVFS() constGetScenes
SceneManager* GetScenes() constGetActiveScene
Scene* GetActiveScene() constIsRunning
bool IsRunning() constStop
void Stop()GetSubsystem
template<typename T> T* GetSubsystem()Auto-instanced MEngineSubsystem singletons, each living as long as the engine. Initialize() fires lazily on the first GetSubsystem<T>() call — there is no manual registration.
ForEachSubsystem
template<typename Func> void ForEachSubsystem(Func&& fn)Visit every live subsystem in registration order.
SetAutoSyncCursorLock
void SetAutoSyncCursorLock(bool enabled)In standalone Runtime, Engine::Run mirrors game code's Input.CursorLocked into Window::SetMouseCapture every frame. In editor PIE, PreviewWindow owns cursor lock through SDL relative mode and tracks its own ESC sticky, so this sync would double-engage SDL relative mode and let Window::NotifyUserClicked — fired on any mouse-down — clear the escape and immediately re-lock. The editor disables it at startup; default true keeps standalone builds unchanged.
IsAutoSyncCursorLockEnabled
bool IsAutoSyncCursorLockEnabled() constRequestShaderReload
void RequestShaderReload()The reload is APPLIED at the top of the next frame, before Renderer::BeginFrame — never while a command buffer records.
SetShaderHotReloadEnabled
void SetShaderHotReloadEnabled(bool enabled)Watches the loose Shaders/ overlay (CWD-relative, the same folder the native VFS mount serves) and requests a reload when mbt shaders --watch drops fresh blobs there. Roughly 2 scans/s.
IsShaderHotReloadEnabled
bool IsShaderHotReloadEnabled() constPollShaderWatch
void PollShaderWatch()One scan of the overlay on the caller; it requests a reload once a change has held still for a whole scan. Public so a host that runs no frame loop (a test case) can drive the watch itself. The frame loop polls through PollShaderWatchAsync instead.
ConsumeShaderReloadRequest
bool ConsumeShaderReloadRequest()GetDeltaTime
float GetDeltaTime() constGetTotalTime
float GetTotalTime() constTickTimer
void TickTimer()HasPendingResize
bool HasPendingResize(uint32_t& w, uint32_t& h)LoadScene
void LoadScene(const std::string& path)SetOverlayBeginFrame
void SetOverlayBeginFrame(OverlayCallback cb)SetOverlayEndFrame
void SetOverlayEndFrame(OverlayCallback cb)SetOverlayRenderDrawData
void SetOverlayRenderDrawData(OverlayCallback cb)SetOverlayRenderViewports
void SetOverlayRenderViewports(OverlayCallback cb)SetOverlayDrawFrame
void SetOverlayDrawFrame(OverlayCallback cb)OverlayBeginFrame
void OverlayBeginFrame()OverlayEndFrame
void OverlayEndFrame()OverlayRenderDrawData
void OverlayRenderDrawData()OverlayRenderViewports
void OverlayRenderViewports()OverlayDrawFrame
void OverlayDrawFrame()SetFrameUpdateCallback
void SetFrameUpdateCallback(FrameUpdateCallback cb)SetIdlePredicate
void SetIdlePredicate(IdlePredicate cb)GetFrameThrottle
EFrameThrottle GetFrameThrottle() constGetFrameThrottleHz
int GetFrameThrottleHz() constGetIdleFrameRateHz
int GetIdleFrameRateHz() constThe idle cap this host was configured with; 0 = never throttles idle.
SetRenderAhead
void SetRenderAhead(bool enabled)Hosts whose frame path owns the publish-time render fence (the overlap pipeline) disable the loop-top render-thread drain with this.