class

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

AliasDescription
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

TypeNameDescription
static constexpr intkExitDeviceLostWhat 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

SignatureNameDescription
Engine()Engine
~Engine() override~Engine

Public functions

ReturnsNameDescription
Engine*GetGEngineProcess-wide Engine accessor.
boolInitialize
voidShutdown
boolWriteRunMetricsWrites 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.
intGetRunExitCode
voidLoadFeatureModulesLoads the engine systems that sit above this umbrella (AI, sequencer, destruction, ...) by name.
voidRun
voidSetInitProgressCallback
voidReportInitProgress
voidTickPer-frame app logic.
voidDrawApp-level UI submission.
voidRouteEventPre-dispatch, before EventBus subscribers see the event.
voidOnShadersReloadedFires after a shader hot-reload that changed at least one shader.
voidOnCoreInitializedRuns inside Initialize once logging, cvars and the object-system resolvers are up, before config, memory, physics, audio, the window or the device start.
voidOnEnterBackgroundMobile app lifecycle (M2.4).
voidOnEnterForeground
boolIsInBackgroundTrue while the OS holds the app in background: no frames render, the loop idles.
boolIsRenderPausedThe frame-captured render gate Engine::Run used THIS frame: minimized OR backgrounded.
Window*GetWindow
InputManager*GetInput
World*GetWorld
VFS*GetVFS
SceneManager*GetScenes
Scene*GetActiveScene
boolIsRunning
voidStop
T*GetSubsystemAuto-instanced MEngineSubsystem singletons, each living as long as the engine.
voidForEachSubsystemVisit every live subsystem in registration order.
voidSetAutoSyncCursorLockIn standalone Runtime, Engine::Run mirrors game code's Input.CursorLocked into Window::SetMouseCapture every frame.
boolIsAutoSyncCursorLockEnabled
voidRequestShaderReloadThe reload is APPLIED at the top of the next frame, before Renderer::BeginFrame — never while a command buffer records.
voidSetShaderHotReloadEnabledWatches 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.
boolIsShaderHotReloadEnabled
voidPollShaderWatchOne scan of the overlay on the caller; it requests a reload once a change has held still for a whole scan.
boolConsumeShaderReloadRequest
floatGetDeltaTime
floatGetTotalTime
voidTickTimer
boolHasPendingResize
voidLoadScene
voidSetOverlayBeginFrame
voidSetOverlayEndFrame
voidSetOverlayRenderDrawData
voidSetOverlayRenderViewports
voidSetOverlayDrawFrame
voidOverlayBeginFrame
voidOverlayEndFrame
voidOverlayRenderDrawData
voidOverlayRenderViewports
voidOverlayDrawFrame
voidSetFrameUpdateCallback
voidSetIdlePredicate
EFrameThrottleGetFrameThrottle
intGetFrameThrottleHz
intGetIdleFrameRateHzThe idle cap this host was configured with; 0 = never throttles idle.
voidSetRenderAheadHosts whose frame path owns the publish-time render fence (the overlap pipeline) disable the loop-top render-thread drain with this.

Function details

Engine

C++
Engine()

~Engine

C++
~Engine() override

GetGEngine

C++
static Engine* GetGEngine()

Process-wide Engine accessor. Set by Engine::Initialize, cleared by Engine::Shutdown; nullptr before init and after shutdown.

Initialize

C++
bool Initialize(const EngineConfig& config = EngineConfig())

Shutdown

C++
void Shutdown()

WriteRunMetrics

C++
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

C++
static int GetRunExitCode()

LoadFeatureModules

C++
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

C++
void Run()

SetInitProgressCallback

C++
void SetInitProgressCallback(InitProgressFn fn)

ReportInitProgress

C++
void ReportInitProgress(const char* label, float fraction)

Tick

C++
virtual void Tick(float dt)

Per-frame app logic. Runs after the engine-core update (input, world, events, jobs) and before UI submission.

Draw

C++
virtual void Draw()

App-level UI submission. Runs between the overlay Begin/EndFrame callbacks.

RouteEvent

C++
virtual void RouteEvent(Event& e)

Pre-dispatch, before EventBus subscribers see the event.

OnShadersReloaded

C++
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

C++
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

C++
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

C++
virtual void OnEnterForeground()

IsInBackground

C++
bool IsInBackground() const

True while the OS holds the app in background: no frames render, the loop idles. Never true on desktop.

IsRenderPaused

C++
bool IsRenderPaused() const

The 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

C++
Window* GetWindow() const

GetInput

C++
InputManager* GetInput() const

GetWorld

C++
World* GetWorld() const

GetVFS

C++
VFS* GetVFS() const

GetScenes

C++
SceneManager* GetScenes() const

GetActiveScene

C++
Scene* GetActiveScene() const

IsRunning

C++
bool IsRunning() const

Stop

C++
void Stop()

GetSubsystem

C++
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

C++
template<typename Func> void ForEachSubsystem(Func&& fn)

Visit every live subsystem in registration order.

SetAutoSyncCursorLock

C++
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

C++
bool IsAutoSyncCursorLockEnabled() const

RequestShaderReload

C++
void RequestShaderReload()

The reload is APPLIED at the top of the next frame, before Renderer::BeginFrame — never while a command buffer records.

SetShaderHotReloadEnabled

C++
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

C++
bool IsShaderHotReloadEnabled() const

PollShaderWatch

C++
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

C++
bool ConsumeShaderReloadRequest()

GetDeltaTime

C++
float GetDeltaTime() const

GetTotalTime

C++
float GetTotalTime() const

TickTimer

C++
void TickTimer()

HasPendingResize

C++
bool HasPendingResize(uint32_t& w, uint32_t& h)

LoadScene

C++
void LoadScene(const std::string& path)

SetOverlayBeginFrame

C++
void SetOverlayBeginFrame(OverlayCallback cb)

SetOverlayEndFrame

C++
void SetOverlayEndFrame(OverlayCallback cb)

SetOverlayRenderDrawData

C++
void SetOverlayRenderDrawData(OverlayCallback cb)

SetOverlayRenderViewports

C++
void SetOverlayRenderViewports(OverlayCallback cb)

SetOverlayDrawFrame

C++
void SetOverlayDrawFrame(OverlayCallback cb)

OverlayBeginFrame

C++
void OverlayBeginFrame()

OverlayEndFrame

C++
void OverlayEndFrame()

OverlayRenderDrawData

C++
void OverlayRenderDrawData()

OverlayRenderViewports

C++
void OverlayRenderViewports()

OverlayDrawFrame

C++
void OverlayDrawFrame()

SetFrameUpdateCallback

C++
void SetFrameUpdateCallback(FrameUpdateCallback cb)

SetIdlePredicate

C++
void SetIdlePredicate(IdlePredicate cb)

GetFrameThrottle

C++
EFrameThrottle GetFrameThrottle() const

GetFrameThrottleHz

C++
int GetFrameThrottleHz() const

GetIdleFrameRateHz

C++
int GetIdleFrameRateHz() const

The idle cap this host was configured with; 0 = never throttles idle.

SetRenderAhead

C++
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.

Generated from Core/Engine.h via mowoengine.json · Oct 27, 2026Version 1.0.0