Engine Architecture
ThreadEngine is split into three concentric layers — core, engine (the library you link against), and tools (editor + standalone runtime). Understanding which layer owns what is the fastest way to find your way around the codebase.
Layer cake
| Layer | Responsibility |
|---|---|
| Application / Window | GLFW window and the main loop. Application::Run() drives every frame. The engine has no UI library of its own: the editor and the Hub install an ImGui UiLayer (engine/imgui_host), a shipped game installs none. |
| Renderer | API-agnostic RendererAPI / RenderCommand; DirectX 11, DirectX 12 and Vulkan backends, plus a headless Null backend for tests. |
| Scene + ECS | The EnTT registry, components, systems, serializer. |
| Subsystems | OpenAL audio wrapper, Jolt physics wrapper. Each is a singleton facade with Init/Shutdown/Step. |
| Asset loading | Cached loaders for textures / meshes / clips. The VFS routes paths so a built game reads from assets.pak. |
| Editor | ImGui panels, gizmos, scene picking, BuildSystem. Links Engine, adds an OnImGuiRender loop. |
| Standalone runtime | Minimal main + Engine link, copied and compiled by BuildSystem for shipped games. |
The frame
Every tick of Application::Run() does, in order:
- Input poll (GLFW events → Input static state).
- Application::OnUpdate(deltaTime) — subclass hook. The editor uses this to update its scene + render both viewports.
- UI frame — only when a
UiLayeris installed: the editor draws its panels inOnImGuiRender. A game's HUD is the engine's own UI system, drawn with the scene. - Present — swap buffers.
During gameplay, the editor calls
Scene::OnUpdateRuntime(dt, w, h, playing=true). That method runs:
- NativeScripts →
OnUpdate(ts). - Scene systems registered via
SystemRegistry. - Camera lookup.
- Physics: lazy-init Jolt, create bodies for new RigidBody/Terrain/Character components, step, sync transforms back.
- Audio: set listener from camera, lazy-create AL sources, push live properties.
- Render:
RenderScene— lights, primitives, meshes, terrain, grid, post-process outline.
Build modes
| Mode | What's linked | Trigger |
|---|---|---|
| Editor build | Engine + Assimp + ImGui host + everything | Default CMake configure. |
| Standalone runtime | Engine without Assimp (THREAD_WITH_ASSIMP=OFF) | File ▸ Build Project… (Build Settings) generates a project with this option set, for Windows or Linux. |
The shipped game reads .tmesh precompiled by BuildSystem
during the editor's build step — so it never needs Assimp at runtime.
What to read next
The ECS Model page explains how entities and components actually fit together, and how the scene loop iterates them.
Architektura silnika
ThreadEngine dzieli się na trzy koncentryczne warstwy — rdzeń, silnik (biblioteka, którą linkujesz) i narzędzia (edytor + samodzielny runtime). Zrozumienie, która warstwa czym się zajmuje, to najszybszy sposób, żeby odnaleźć się w kodzie.
Warstwy
| Warstwa | Odpowiedzialność |
|---|---|
| Aplikacja / okno | Okno GLFW i pętla główna. Application::Run() napędza każdą klatkę. Silnik nie ma własnej biblioteki UI: edytor i Hub instalują UiLayer z ImGui (engine/imgui_host), wydana gra nie instaluje żadnego. |
| Renderer | Niezależne od API RendererAPI / RenderCommand; backendy DirectX 11, DirectX 12 i Vulkan oraz bezgłowy backend Null do testów. |
| Scena + ECS | Rejestr EnTT, komponenty, systemy, serializer. |
| Podsystemy | Nakładka na dźwięk OpenAL i fizykę Jolt. Każda to singleton z Init/Shutdown/Step. |
| Wczytywanie assetów | Buforowane loadery tekstur / siatek / klipów. VFS kieruje ścieżki tak, że zbudowana gra czyta z assets.pak. |
| Edytor | Panele ImGui, gizma, wybieranie w scenie, BuildSystem. Linkuje Engine i dokłada pętlę OnImGuiRender. |
| Samodzielny runtime | Minimalny main + link do Engine, kopiowany i kompilowany przez BuildSystem dla wydanych gier. |
Klatka
Każdy tick Application::Run() wykonuje po kolei:
- Odczyt wejścia (zdarzenia GLFW → stan statyczny Input).
- Application::OnUpdate(deltaTime) — zaczep podklasy. Edytor aktualizuje w nim scenę i renderuje oba viewporty.
- Klatka UI — tylko gdy zainstalowano
UiLayer: edytor rysuje panele wOnImGuiRender. HUD gry to własny system UI silnika, rysowany razem ze sceną. - Present — zamiana buforów.
Podczas gry edytor wywołuje Scene::OnUpdateRuntime(dt, w, h, playing=true). Ta metoda
wykonuje:
- NativeScripts →
OnUpdate(ts). - Systemy sceny zarejestrowane przez
SystemRegistry. - Wybór kamery.
- Fizykę: leniwy start Jolt, tworzenie ciał dla nowych komponentów RigidBody/Terrain/Character, krok, synchronizacja transformów z powrotem.
- Dźwięk: słuchacz z kamery, leniwe tworzenie źródeł AL, przekazanie bieżących właściwości.
- Renderowanie:
RenderScene— światła, prymitywy, siatki, teren, siatka pomocnicza, obrys w post-processie.
Tryby budowania
| Tryb | Co jest linkowane | Jak go wywołać |
|---|---|---|
| Build edytora | Engine + Assimp + host ImGui + wszystko | Domyślna konfiguracja CMake. |
| Samodzielny runtime | Engine bez Assimpa (THREAD_WITH_ASSIMP=OFF) | File ▸ Build Project… (Build Settings) generuje projekt z tą opcją, na Windows albo Linux. |
Wydana gra czyta .tmesh prekompilowane przez BuildSystem w kroku builda
edytora — więc nigdy nie potrzebuje Assimpa w czasie działania.
Co czytać dalej
Strona Model ECS wyjaśnia, jak naprawdę łączą się encje i komponenty oraz jak pętla sceny po nich iteruje.