Architecture
Mortar is a C++ game engine designed for running custom maps created in the ctx.gg map editor.
Core Libraries
Section titled “Core Libraries”| Library | Purpose |
|---|---|
| Vulkan | GPU rendering |
| flecs | Entity Component System |
| Jolt Physics | Physics simulation |
| miniaudio | Audio playback |
System Overview
Section titled “System Overview”The engine follows an ECS (Entity Component System) architecture using flecs:
Components
Section titled “Components”Components are plain data structs attached to entities:
Transform— Position, rotation, scaleMeshRenderer— Mesh and material referencesRigidBody— Physics body propertiesCollider— Collision shape definitionAudioSource— Sound emitter
Systems
Section titled “Systems”Systems run each frame to process entities with matching components:
- Input System — Polls input devices, updates input state
- Physics System — Steps the Jolt physics simulation
- Transform System — Syncs physics transforms to entity transforms
- Render System — Submits draw calls to Vulkan
- Audio System — Updates spatial audio sources
Render Pipeline
Section titled “Render Pipeline”The Vulkan render pipeline uses a forward rendering approach:
- Update uniform buffers (camera, lights)
- Record command buffers for each visible entity
- Submit to GPU, present swapchain image
Map Loading
Section titled “Map Loading”When the engine starts, it reads a map JSON file and:
- Parses the JSON into entity descriptions
- Creates flecs entities with the specified components
- Initializes physics bodies in Jolt
- Loads referenced meshes and textures
- Enters the main loop
See Map Format for the JSON structure.
Building
Section titled “Building”See Building from Source for build instructions.