Overview
Application is the composition root. It owns every Module*, exposes typed accessors, tracks engine state (EDITOR / PLAYING / PAUSED), pause/quit flags, optional per-module update profiling, frame phase timings, and the active editor camera perspective (CameraComponent*) used when rendering the scene editor viewport.
Module registration order in the constructor defines default update/render ordering. Initialization is strictly forward; cleanup strictly reverse—matching typical dependency teardown (render before D3D12 device destruction). Release builds bootstrap from build.cfg (scene UID/hash, optional bank, named scene library IDs) without the asset scanner.
How it works
- Win32 creates HWND;
Applicationis constructed with the ordered module list. init()initializes all modules forward;cleanUp()tears them down in reverse order.- Each
WM_PAINTcallsupdate()unless the window is minimized-paused. - When not paused, each frame runs update → preRender → render → postRender on every module, with optional per-module CPU timing.
- In
PLAYING,ModuleTime::deltaTime()uses scaled real delta; otherwise delta stays 0. - GPU work is bracketed by
ModuleD3D12::preRender/postRenderaround module render hooks.
Internal architecture
Application
├── Module registry (vector<Module*>)
├── ENGINE_STATE + pause/quit
├── FrameCpuTimings / ModuleUpdateTiming
├── Settings
├── ThreadPool
└── Lifecycle drivers
├── init() — forward init
├── update() — update → preRender → render → postRender
└── cleanUp() — reverse cleanUp
Relationships
- Central hub: all modules are owned here; the global
apppointer is used throughout the codebase. ModuleScenereceives profiling hooks fromApplication::update.ModuleRenderrequests simulation stop viarequestStopSimulation→ModuleGameView::stopGameSimulation.
Technical features
- Win32 host (
Engine.cpp→wWinMain); eachWM_PAINTtriggers one full engine frame viaApplication::update(). - Orthogonal state:
ENGINE_STATE(EDITOR/PLAYING/PAUSED) andApplication::m_pausedwhen minimized. - Four-phase frame with recorded CPU timings: update, preRender, render, postRender.
GAME_RELEASEbootstrap frombuild.cfgwithout editor asset scanning.
Implementation notes
- Verified: module order, four-phase frame, reverse cleanup,
GAME_RELEASEbootstrap. - Partial:
ModuleTime::waitForNextFrame()not used; 120 FPS target in constructor does not limit frames in practice. - Verified: default state
EDITOR; release forcesPLAYING.