Game Without the Editor engine only
The editor is an application built on the engine, not a layer the engine needs. A
shipped game links Engine and nothing else — no ImGui panels, no Assimp, no editor
code. This page is the two ways to do that.
Two paths
| Path | You write | Use when |
|---|---|---|
| RuntimePlayer | A main() that fills a config struct. |
The game is an editor-authored scene. This is the no-code path, and it is what File ▸ Build Project… generates for you. |
| Subclass Application | Your own OnInit / OnUpdate. |
You need menus, scene swapping, your own systems, or a scene built in C++ rather than loaded. |
Path 1 — RuntimePlayer
Mounts assets, loads the start scene, runs the loop. It lives in the engine
(core/RuntimePlayer.h) rather than in a template folder, so an engine change that
breaks it breaks the build immediately instead of the next time somebody ships.
#include "core/RuntimePlayer.h"
int main() {
Thread::RuntimePlayerConfig cfg;
cfg.GameName = "Souls of Arcania";
cfg.StartScene = "assets/scenes/main.thread"; // a VFS path
cfg.PreferredAPI = Thread::RendererAPI::API::DirectX12;
cfg.Fullscreen = true;
return Thread::RunRuntimePlayer(cfg);
}
| GameName | std::string | Window title. |
| StartScene | std::string | Virtual path, resolved through the VFS — so a packed and a loose build behave identically. |
| PreferredAPI | RendererAPI::API | DirectX12 (default), DirectX11 or Vulkan. Off Windows, DirectX falls back to Vulkan. |
| Fullscreen / Width / Height | bool / uint32 | Initial window. |
| RedirectOutputToLog | bool | stdout/stderr to game.log beside the exe. On by default — a shipped game has no console to print to. |
| HideConsole | bool | Hide the console window. Off for a launcher that wants one. |
RunRuntimePlayer returns a process exit code: 0 on a
clean exit, non-zero when the start scene could not be loaded — so a packaging script can tell a
broken build from a working one without reading the log.Path 2 — subclass Application
Everything beyond "run this scene" means owning the loop yourself. ExampleGame/
and TPPExample/ in the repo are complete, working versions of this — a first-person
game with a menu, HUD, pickups, audio and save/load, built entirely on stock engine APIs.
class MyGame : public Thread::Application {
public:
explicit MyGame(const Thread::ApplicationSpecification& spec) : Application(spec) {}
void OnInit() override {
m_Scene = new Thread::Scene();
// Build entities, or load one: Thread::SceneSerializer(m_Scene).Deserialize(path);
}
void OnUpdate(float dt) override {
int w = 0, h = 0; GetFramebufferSize(w, h);
if (w > 0 && h > 0) m_Scene->OnUpdateRuntime(dt, (float)w, (float)h);
}
void OnImGuiRender() override {} // no editor UI
private:
Thread::Scene* m_Scene = nullptr;
};
int main() {
Thread::ApplicationSpecification spec;
spec.Name = "My Game";
spec.PreferredAPI = Thread::RendererAPI::API::DirectX12;
MyGame game(spec);
game.Run();
}
Gameplay scripts work here exactly as they do in the editor, and can be bound by TYPE instead of by name, since the class is right there:
player.AddComponent<Thread::NativeScriptComponent>().Bind<FPSController>();
Building
The game's CMake pulls the engine in and turns off what a shipped build does not need:
set(THREAD_BUILD_STANDALONE ON CACHE BOOL "" FORCE)
set(THREAD_WITH_ASSIMP OFF CACHE BOOL "" FORCE) # meshes are precompiled to .tmesh
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/.." "${CMAKE_CURRENT_BINARY_DIR}/thread_engine")
add_executable(MyGame ${GAME_SOURCES})
target_link_libraries(MyGame PRIVATE Engine)
Assimp is off because the editor precompiles meshes to .tmesh at build time —
the runtime never parses an .fbx or .gltf. See the
Asset Pipeline.
WIN32_EXECUTABLE TRUE plus /ENTRY:mainCRTStartup, which keeps an
ordinary int main() while dropping the console window.Finding assets at runtime
A shipped game mounts one of three things, in this order of preference — packed, loose, then the repo's own assets when running straight from a build tree:
if (exists(exeDir / "assets.pak")) VFS::MountPackFile("assets", ...); // shipped
else if (exists(exeDir / "assets")) VFS::Mount("assets", "assets"); // loose
else VFS::Mount("assets", THREAD_ASSETS_DIR); // dev
Then load the asset manifest, or every GUID reference in your scenes resolves to nothing:
Thread::AssetRegistry::LoadManifest("assets/" + Thread::AssetRegistry::kManifestName);
.pak looking for .meta sidecars, so it reads
the manifest the editor wrote. A project that only ever used paths has nothing to resolve and a
missing manifest is not an error — but a project that used GUIDs and skipped this ships with
every material unresolved.Packaging
The engine provides the packaging step; the game only declares its target and asset folders:
thread_package_game(MyGame ASSET_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/Assets")
cmake --install build --config Release --prefix dist --component game
The engine links its dependencies (GLFW, yaml-cpp, OpenAL, Jolt…) statically, so the result is
just the executable, assets.pak and the MSVC runtime DLLs — a folder you can zip and
send. build_example.bat does the whole thing for ExampleGame.
What you give up
Nothing at runtime — the engine is the same code either way. What the editor adds is authoring: the scene you load has to come from somewhere, and building one in C++ is a lot of typing compared with dragging it together. The usual split is to author in the editor and ship with RuntimePlayer, and to reach for path 2 when the game needs a loop the player does not provide.
See also
Engine Architecture · Asset Pipeline · Native Scripting · Project Structure
Gra bez edytora tylko silnik
Edytor to aplikacja zbudowana na silniku, a nie warstwa, której silnik potrzebuje. Wydana gra
linkuje Engine i nic więcej — bez paneli ImGui, bez Assimpa, bez kodu edytora. Ta strona
opisuje dwa sposoby, żeby to zrobić.
Dwie drogi
| Droga | Piszesz | Kiedy |
|---|---|---|
| RuntimePlayer | main(), który wypełnia strukturę konfiguracji. |
Gra to scena zrobiona w edytorze. To droga bez kodu i to ją generuje File ▸ Build Project…. |
| Podklasa Application | Własne OnInit / OnUpdate. |
Potrzebujesz menu, podmiany scen, własnych systemów albo sceny budowanej w C++ zamiast wczytywanej. |
Droga 1 — RuntimePlayer
Montuje assety, wczytuje scenę startową, kręci pętlę. Żyje w silniku (core/RuntimePlayer.h),
a nie w folderze szablonu, więc zmiana w silniku, która go psuje, psuje build od razu, a nie przy
następnym wydaniu.
#include "core/RuntimePlayer.h"
int main() {
Thread::RuntimePlayerConfig cfg;
cfg.GameName = "Souls of Arcania";
cfg.StartScene = "assets/scenes/main.thread"; // ścieżka VFS
cfg.PreferredAPI = Thread::RendererAPI::API::DirectX12;
cfg.Fullscreen = true;
return Thread::RunRuntimePlayer(cfg);
}
| GameName | std::string | Tytuł okna. |
| StartScene | std::string | Ścieżka wirtualna, rozwiązywana przez VFS — build spakowany i luźny zachowują się identycznie. |
| PreferredAPI | RendererAPI::API | DirectX12 (domyślnie), DirectX11 albo Vulkan. Poza Windows DirectX przechodzi na Vulkana. |
| Fullscreen / Width / Height | bool / uint32 | Okno początkowe. |
| RedirectOutputToLog | bool | stdout/stderr do game.log obok pliku wykonywalnego. Domyślnie włączone — wydana gra nie ma konsoli. |
| HideConsole | bool | Ukrywa okno konsoli. Wyłącz dla launchera, który jej chce. |
RunRuntimePlayer zwraca kod wyjścia procesu: 0 przy czystym
zakończeniu, niezerowy, gdy nie udało się wczytać sceny startowej — skrypt pakujący odróżni zepsuty build
od działającego bez czytania logu.Droga 2 — podklasa Application
Wszystko poza „uruchom tę scenę” oznacza posiadanie pętli. ExampleGame/ i
TPPExample/ w repozytorium to kompletne, działające wersje tego — gra FPP z menu, HUD-em,
podnoszeniem przedmiotów, dźwiękiem i zapisem/odczytem, zbudowana wyłącznie na standardowych API
silnika.
class MyGame : public Thread::Application {
public:
explicit MyGame(const Thread::ApplicationSpecification& spec) : Application(spec) {}
void OnInit() override {
m_Scene = new Thread::Scene();
// Zbuduj encje albo wczytaj: Thread::SceneSerializer(m_Scene).Deserialize(path);
}
void OnUpdate(float dt) override {
int w = 0, h = 0; GetFramebufferSize(w, h);
if (w > 0 && h > 0) m_Scene->OnUpdateRuntime(dt, (float)w, (float)h);
}
void OnImGuiRender() override {} // bez UI edytora
private:
Thread::Scene* m_Scene = nullptr;
};
int main() {
Thread::ApplicationSpecification spec;
spec.Name = "My Game";
spec.PreferredAPI = Thread::RendererAPI::API::DirectX12;
MyGame game(spec);
game.Run();
}
Skrypty gry działają tu dokładnie tak jak w edytorze i można je podpinać po TYPIE zamiast po nazwie, bo klasa jest pod ręką:
player.AddComponent<Thread::NativeScriptComponent>().Bind<FPSController>();
Budowanie
CMake gry wciąga silnik i wyłącza to, czego wydany build nie potrzebuje:
set(THREAD_BUILD_STANDALONE ON CACHE BOOL "" FORCE)
set(THREAD_WITH_ASSIMP OFF CACHE BOOL "" FORCE) # siatki są prekompilowane do .tmesh
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/.." "${CMAKE_CURRENT_BINARY_DIR}/thread_engine")
add_executable(MyGame ${GAME_SOURCES})
target_link_libraries(MyGame PRIVATE Engine)
Assimp jest wyłączony, bo edytor prekompiluje siatki do .tmesh przy buildzie — runtime
nigdy nie parsuje .fbx ani .gltf. Zob. Potok zasobów.
WIN32_EXECUTABLE TRUE plus
/ENTRY:mainCRTStartup, co zostawia zwykłe int main(), a usuwa okno konsoli.Znajdowanie assetów w czasie działania
Wydana gra montuje jedno z trzech, w tej kolejności — spakowane, luźne, a przy uruchomieniu prosto z drzewa builda assety repozytorium:
if (exists(exeDir / "assets.pak")) VFS::MountPackFile("assets", ...); // wydane
else if (exists(exeDir / "assets")) VFS::Mount("assets", "assets"); // luźne
else VFS::Mount("assets", THREAD_ASSETS_DIR); // dev
Potem wczytaj manifest assetów, inaczej każde odwołanie GUID w scenach rozwiąże się do niczego:
Thread::AssetRegistry::LoadManifest("assets/" + Thread::AssetRegistry::kManifestName);
.pak w poszukiwaniu plików .meta, więc czyta manifest
zapisany przez edytor. Projekt, który używał tylko ścieżek, nie ma czego rozwiązywać i brak manifestu to
nie błąd — ale projekt, który używał GUID-ów i to pominął, wychodzi z każdym materiałem
nierozwiązanym.Pakowanie
Krok pakowania daje silnik; gra deklaruje tylko swój target i foldery assetów:
thread_package_game(MyGame ASSET_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/Assets")
cmake --install build --config Release --prefix dist --component game
Silnik linkuje swoje zależności (GLFW, yaml-cpp, OpenAL, Jolt…) statycznie, więc wynik to sam plik
wykonywalny, assets.pak i biblioteki uruchomieniowe MSVC — folder, który można spakować i
wysłać. build_example.bat robi to wszystko dla ExampleGame.
Z czego rezygnujesz
W czasie działania z niczego — silnik to ten sam kod w obu przypadkach. Edytor dodaje tworzenie: scena, którą wczytujesz, musi skądś pochodzić, a budowanie jej w C++ to dużo pisania w porównaniu z przeciąganiem. Zwykły podział: twórz w edytorze, wydawaj przez RuntimePlayer, a po drogę 2 sięgaj, gdy gra potrzebuje pętli, której RuntimePlayer nie daje.
Zobacz też
Architektura silnika · Potok zasobów · Skrypty natywne · Struktura projektu