![]() |
vkmEngine 1.0.15
A C++ game engine · vkmengine.com
|
How to configure, build, run and test the engine and its examples, what each CMake target is, and what an SDK install and a shipping build contain.
No compiler is needed: a configure that names none builds with the pinned GCC, or with -DVKM_COMPILER=clang the pinned Clang, which tools/toolchain.json pins and cmake/pinned_toolchain.cmake fetches through vkm toolchain (the toolchain pin). Naming one - -DCMAKE_CXX_COMPILER=..., CC/CXX, a toolchain file, or -DVKM_PINNED_TOOLCHAIN=OFF for whatever CMake finds - builds with that instead, and vkm builds a game's module with the same.
The engine's own assets/ is ignored except for logo/, fonts/ and docs/, so a clone carries no models and no environment maps; it builds and runs without them. examples/the_lab/assets/ and examples/the_lab/library/ are named exceptions in .gitignore.
An in-source build is refused, and a configure that names no build type gets RelWithDebInfo. Asserts stay on whatever the build type (VKM_ASSERTS); turn them off in a tree you profile.
Those run what was built last. tools/vkm builds the project's module and cooks its assets first:
getting-started.md lists every command. Each host takes a project directory, defaulting to the one beside its executable (io.md).
A boot check is an exit code. A host that cannot open its project exits non-zero, and Engine::run shuts down cleanly on SIGINT/SIGTERM:
Which conditions are fatal to which host is in io.md.
The executables land in build/bin/. Each project's gameplay module builds into that project's own bin/, and is named game in every configuration (the host finds it by name). So two build trees write the same <project>/bin/libgame.so and the later build wins: run a host from the tree that built the module it will load. Mixing them runs a module compiled against another tree's public flags - the profiler, the asserts - beside an engine built with others: it may refuse to load, or load and disagree with the engine about the code they share.
examples/potion_runner, examples/the_lab, examples/stress_arena and examples/city_block are projects, and one CMakeLists.txt each serves two ways of building them. Configured on its own (./tools/vkm build examples/potion_runner) it calls find_package(vkmEngine) against the engine's build tree or an installed SDK, as a project made by vkm new does. Added by the engine's own CMakeLists.txt, it skips project() and find_package.
Both call vkm_add_gameplay_module() (cmake/gameplay_module.cmake, shipped in the SDK). It compiles every .cpp under the project's src/, which is also its include root, and refuses at configure an engine of another minor release than engineVersion in project.json (vkm_check_engine_version).
The suites are split by what each one needs to run:
| CTest name | Runs | Needs |
|---|---|---|
| vkm_gl | vkm_gl_tests | nothing |
| vkm_engine | vkm_engine_tests | nothing |
| render | vkm_render_tests | an EGL device |
| vkm_tool | tests/tools/vkm_tool.cmake | Python 3.8, and the build tree at build/ |
| vkm_download | tests/tools/vkm_download_tests.py | Python 3.8 |
vkm_gl is vkmGL's context-free suite (modules/CMakeLists.txt forces VKM_GL_BUILD_TESTS on).
vkm_engine is the engine's own, and needs no GPU or display. A suite is tests/<area>/<suite>_tests.cpp, the area being the source folder it tests (tests/physics/solver_tests.cpp); only the harness - main.cpp, suites.h, support.h - sits at the root. A new suite is two edits: the file, and a row in VKM_TEST_SUITES (tests/suites.h); the docs suite checks that rows, files and the list below agree. The suites are core, ecs, hierarchy, query, collision, solver, joint, ragdoll, character, resource, async, cook, import, authoring, prefab, scene, play, undo, culling, sky, ocean, terrain, animation, particle, wire, transport, replication, prediction, session, ui, audio, script, hostile, docs.
render is the GPU suite. It compiles the shipped shaders, renders small scenes built in code through RenderView and GLBackend off-screen, and compares each with its image in tests/render/golden/ (tolerances in tests/render/golden_tests.cpp; a failing frame is written to /tmp/vkm_golden_<name>.png). It is built only where CMake finds EGL and skips at runtime with no device. Each golden is compared only on the GPU that made it. After a change meant to alter the picture, regenerate them, look at them, and commit them with the change:
vkm_tool runs tools/vkm as a user does - vkm new, then doctor, package --development and clean - and is registered only for a build tree at build/.
Asserts are on in these builds, so a check of what a shipping build does with a broken invariant is skipped; a tree configured -DVKM_ASSERTS=OFF runs it.
Nothing covers what needs a window - the editor, input, and how the pieces meet; walk the tool for those. New engine tests join the existing suites rather than starting another binary.
| Target | Type | Description |
|---|---|---|
| vkm_core | Shared lib | Core engine: ECS, resources, IO, the non-render systems, platform, debug |
| vkm_render | Shared lib | Render system, backend abstraction, render view |
| vkm_backend_gl | Static lib | OpenGL backend |
| vkm_tools | Static lib | What every host needs from src/tools/: image and HDR decode, the SDF font baker (loader/), the host prologue (project_boot). No model import, no texture bake |
| vkm_cook | Static lib | The model, image and audio importers and the asset cooker. Linked by vkm_editor_app and vkm_cook_app only |
| vkm_editor | Static lib | Editor UI, panels, overlays, gizmo, scene I/O |
| vkm_build_info | Interface lib | Compile-time build metadata (version, branch, commit hash) |
| vkm_warnings | Interface lib | Shared GCC/Clang warning flags; first-party targets opt in, submodules don't |
| <project>_module | Shared lib | One per project (potion_runner_module, ...), built by vkm_add_gameplay_module() as game.dll/libgame.so into the project's bin/ |
| vkm_runtime_app | Executable | Bare engine; links no importer and no editor. Runs as vkm_runtime |
| vkm_editor_app | Executable | Engine libs + vkm_editor + vkm_cook; hot-reloads the open project's module. Runs as vkm_editor |
| vkm_cook_app | Executable | Headless asset cook: no window, no graphics context, no Engine. Runs as vkm_cook |
| vkm_server_app | Executable | The refereeing host: a client's system stack with no window and no render backend. Runs as vkm_server; still links glfw through vkm_core |
| vkm_gl_tests | Executable | CTest vkm_gl. Not installed |
| vkm_engine_tests | Executable | CTest vkm_engine. Not installed |
| vkm_render_tests | Executable | CTest render. Built only where CMake finds EGL. Not installed |
Host targets carry an _app suffix because two of the names are library names; OUTPUT_NAME drops it.
vkm_core and vkm_render are shared because a gameplay module must reach engine symbols without a second copy (two typeId registries, two sets of singletons). A static engine could only manage that by resolving from the host executable, which on Windows binds a module to one exe.
The three hosts that build an Engine include app/engine_app.h for setupEngineApp. That vkm_runtime_app carries no cooker and no editor is enforced by its link list, not a build flag.
cmake --install produces an SDK - what games are built with - not a game:
vkm package takes shaders/ and assets/ into a game (ENGINE_DATA in tools/vkmcli/package.py) from an SDK or from the build tree alike. CPack makes the downloadable archive:
Building a game with the SDK is getting-started.md.
A packaged game runs on VKM_SHIPPING: Release with asserts and the profiler off and -g kept, so a player's crash reads against the symbols vkm package splits out. It configures only the runtime, the server and what they load - no editor, cooker, tests or examples.
vkm package runs exactly that, so this is only for doing it by hand. A shipped module is built against it into the project's build/shipping/ (VKM_MODULE_DIR), never over the development one. An SDK carries one, in <prefix>/shipping, when the development tree is told where it is:
Without it, a game packaged from the SDK ships on the development engine, and vkm package says so.
Nothing runs on a push. A branch is built by hand - Actions > CI > Run workflow, or gh workflow run ci.yml --ref <branch> - through .github/workflows/ci.yml, which runs .github/workflows/build.yml: GCC and Clang on Linux and Windows build the shipping engine and the SDK, run the tests, package the archive, then install it on a clean machine and use it (vkm new, vkm doctor, vkm package, every example). A version tag (vX.Y.Z) runs .github/workflows/release.yml: the same build, then the archives, the examples as games, the installers (tools/install/install.sh, install.ps1) and SHA256SUMS on the tag's GitHub release, with notes from CHANGELOG.md.
Every external dependency is a git submodule under modules/, pinned to a commit; updating one is moving its pin. testTheModuleListsAreTheModules holds this table and the README's list to that directory:
| Module | Path | Provides |
|---|---|---|
| vkmGL | modules/vkmGL | OpenGL object wrappers (Vkm::GL::), shader loading/preprocessing. Vendors GLEW privately |
| vkmLog | modules/vkmLog | Logging (Vkm::Log::): LOG_TRACE..LOG_FATAL, VKM_ASSERT |
| glm | modules/glm | Vector/matrix math |
| glfw | modules/glfw | Window + input platform layer |
| stb | modules/stb | stb_image (texture decode), stb_truetype (SDF font bake), stb_image_resize2 (the cooker's mip chains) |
| miniaudio | modules/miniaudio | Playback device + wav/mp3/flac decode; only system/audio and the audio importer include it |
| imgui | modules/imgui | Dear ImGui, docking branch, for editor UI |
| freetype | modules/freetype | Font rasterizer, trimmed to the core |
| json | modules/json | nlohmann/json (nlohmann_json) |
| basis_universal | modules/basis_universal | The cooker's BC7 encoder: only encoder/basisu_bc7e_scalar.cpp is compiled (the bc7e target). BC4/BC5 are the engine's own, src/tools/cook/bc4_encoder.h |
| cgltf | modules/cgltf | glTF and GLB import |
| ufbx | modules/ufbx | FBX and OBJ import, converted to the engine's axes and metres on load |
| mikktspace | modules/mikktspace | MikkTSpace tangents for imported meshes that carry none |
| meshoptimizer | modules/meshoptimizer | LOD simplification (decimateMesh), the vertex-cache / vertex-fetch order of cooked meshes (optimizeMeshForGpu), and the import weld |
| tracy | modules/tracy | Tracy profiler client (TracyClient), linked by vkm_core only when VKM_PROFILER is on |
cgltf, ufbx, mikktspace, meshoptimizer and bc7e are linked privately by vkm_cook and by the test suite only.
GLSL shaders live in shaders/, one folder per program, grouped by pipeline stage:
The loader (vkmGL) hard-codes each stage's file name:
| Stage | Filename | Required? |
|---|---|---|
| Vertex | vertex.shader | Required for graphics programs |
| Fragment | fragment.shader | Required for graphics programs |
| Geometry | geometry.shader | Optional; loaded if present |
| Compute | compute.shader | A compute-only program (Vkm::GL::ComputeShader) |
A program is loaded by path prefix:
The preprocessor resolves #include between .shader/.glsl files and prepends a prelude - the #version and the engine's cross-language constants - which GLBackend builds from the C++ constants; see lighting.md.
src/engine/platform/windows_api.h is the one way to include a Windows system header, and src/engine/platform/window/glfw_include.h the one way to include GLFW. Nothing enforces it: a file that includes <windows.h> or <GLFW/glfw3.h> directly compiles on Linux and fails on Windows.
First-party targets link the vkm_warnings interface lib (GCC/Clang): -Wall -Wextra and a few more, each explained in the top-level CMakeLists.txt. Submodules keep their own warnings, and the third-party ones' include paths are SYSTEM (vkmGL and vkmLog are first-party, and are not). Clang adds -Werror=documentation, which fails on a @param that names no parameter, so a Clang build checks the doc blocks. First-party code is strict C++17 (CMAKE_CXX_EXTENSIONS OFF).
A separate tree with AddressSanitizer and UndefinedBehaviorSanitizer on every target, submodules included; the first report is fatal:
Run it after touching anything that reads bytes the process did not write - the cooked readers, the scene and prefab loaders, the wire.
| Define | Scope | Purpose |
|---|---|---|
| -UNDEBUG | vkm_core (public) | With VKM_ASSERTS (on by default, off in a shipping engine): VKM_ASSERT and assert() run in every first-party file and every gameplay module, whatever the build type |
| VKM_PROFILER=1 | vkm_core (public) | Enables Tracy CPU+GPU zones via debug/profiler.h. Default ON unless CMAKE_BUILD_TYPE is exactly Release; always off in a shipping engine |
| GLM_ENABLE_EXPERIMENTAL | vkm_core (public) | GLM experimental features |
| GLM_FORCE_INTRINSICS | vkm_core (public) | GLM SIMD intrinsics |
| VKM_ENGINE_VERSION | vkm_core (public) | The engine version a gameplay module reports through vkmModuleEngineVersion(); a host refuses a module whose string differs |
| APP_VERSION | vkm_build_info | Engine version string |
| APP_ROOT_DIR | vkm_build_info | Absolute path to the engine root - the fallback ProjectPaths::engineRoot() uses when the exe is run from a build tree. Not the project root |
| APP_BRANCH, APP_COMMIT_HASH, APP_BUILD_DATE | vkm_build_info | Git metadata |
With VKM_PROFILER=1 the engine emits a FrameMark per frame, a CPU zone per stage, and CPU+GPU zones per pass. Attach the Tracy GUI (built from modules/tracy/profiler). The CPU macros are in src/engine/debug/profiler.h and the GPU ones in src/backend/opengl/gl_profiler.h; engine code never includes Tracy headers directly. The client listens on localhost only (TRACY_ONLY_LOCALHOST, modules/CMakeLists.txt); turn that off to profile from another machine.
A headless capture:
(tracy-capture and tracy-csvexport build from modules/tracy/capture and modules/tracy/csvexport.) Skip the start-up - the scene build and probe bakes, until the SwapBuffers zones come steadily - then divide each zone's summed time by the number of SwapBuffers zones, one per frame, for time per frame - not by a stage's own count, as a stage opens a zone on every fixed tick too. Compare GPU.Frame with the main thread's stages to see which side binds; on the CPU side a pass costs mostly what it binds and draws, not what its shaders compute.