Skip to content

Architecture

Mortar is a C++ game engine designed for running custom maps created in the ctx.gg map editor.

LibraryPurpose
VulkanGPU rendering
flecsEntity Component System
Jolt PhysicsPhysics simulation
miniaudioAudio playback

The engine follows an ECS (Entity Component System) architecture using flecs:

Components are plain data structs attached to entities:

  • Transform — Position, rotation, scale
  • MeshRenderer — Mesh and material references
  • RigidBody — Physics body properties
  • Collider — Collision shape definition
  • AudioSource — Sound emitter

Systems run each frame to process entities with matching components:

  1. Input System — Polls input devices, updates input state
  2. Physics System — Steps the Jolt physics simulation
  3. Transform System — Syncs physics transforms to entity transforms
  4. Render System — Submits draw calls to Vulkan
  5. Audio System — Updates spatial audio sources

The Vulkan render pipeline uses a forward rendering approach:

  1. Update uniform buffers (camera, lights)
  2. Record command buffers for each visible entity
  3. Submit to GPU, present swapchain image

When the engine starts, it reads a map JSON file and:

  1. Parses the JSON into entity descriptions
  2. Creates flecs entities with the specified components
  3. Initializes physics bodies in Jolt
  4. Loads referenced meshes and textures
  5. Enters the main loop

See Map Format for the JSON structure.

See Building from Source for build instructions.