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

LayerResponsibility
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:

  1. Input poll (GLFW events → Input static state).
  2. Application::OnUpdate(deltaTime) — subclass hook. The editor uses this to update its scene + render both viewports.
  3. UI frame — only when a UiLayer is installed: the editor draws its panels in OnImGuiRender. A game's HUD is the engine's own UI system, drawn with the scene.
  4. Present — swap buffers.

During gameplay, the editor calls Scene::OnUpdateRuntime(dt, w, h, playing=true). That method runs:

  1. NativeScripts → OnUpdate(ts).
  2. Scene systems registered via SystemRegistry.
  3. Camera lookup.
  4. Physics: lazy-init Jolt, create bodies for new RigidBody/Terrain/Character components, step, sync transforms back.
  5. Audio: set listener from camera, lazy-create AL sources, push live properties.
  6. Render: RenderScene — lights, primitives, meshes, terrain, grid, post-process outline.

Build modes

ModeWhat's linkedTrigger
Editor buildEngine + Assimp + ImGui host + everythingDefault CMake configure.
Standalone runtimeEngine 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

WarstwaOdpowiedzialność
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:

  1. Odczyt wejścia (zdarzenia GLFW → stan statyczny Input).
  2. Application::OnUpdate(deltaTime) — zaczep podklasy. Edytor aktualizuje w nim scenę i renderuje oba viewporty.
  3. Klatka UI — tylko gdy zainstalowano UiLayer: edytor rysuje panele w OnImGuiRender. HUD gry to własny system UI silnika, rysowany razem ze sceną.
  4. Present — zamiana buforów.

Podczas gry edytor wywołuje Scene::OnUpdateRuntime(dt, w, h, playing=true). Ta metoda wykonuje:

  1. NativeScripts → OnUpdate(ts).
  2. Systemy sceny zarejestrowane przez SystemRegistry.
  3. Wybór kamery.
  4. Fizykę: leniwy start Jolt, tworzenie ciał dla nowych komponentów RigidBody/Terrain/Character, krok, synchronizacja transformów z powrotem.
  5. Dźwięk: słuchacz z kamery, leniwe tworzenie źródeł AL, przekazanie bieżących właściwości.
  6. Renderowanie: RenderScene — światła, prymitywy, siatki, teren, siatka pomocnicza, obrys w post-processie.

Tryby budowania

TrybCo jest linkowaneJak go wywołać
Build edytoraEngine + Assimp + host ImGui + wszystkoDomyślna konfiguracja CMake.
Samodzielny runtimeEngine 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.