Core API
Headers: src/core/engine.h, src/core/configuration.h
Namespace: glitter
glitter::engine
The root object of the engine. Handles its own complete initialisation — hardware layer, config loading, logging, renderer creation — in its constructor. main.cpp only creates it and calls run().
Subsystem accessors
| Member | Returns | Description |
|---|---|---|
hwlayer() | HWLayer& | Platform / windowing layer |
renderer() | Renderer& | Active renderer (Vulkan) |
mainWindow() | Window& | The primary SDL window |
resources() | glitter::resources& | URI-based resource system |
renderContext() | RenderContext& | Low-level GPU context (throws if not supported by the active renderer) |
shaders() | ShaderSystem& | Shader loading and binding facade |
scene() | Scene& | Scene object factory and cache |
sceneGraph() | SceneGraph& | Live spatial scene graph |
loop() | LoopScheduler& | Per-frame callback scheduler |
input() | InputMapper& | Semantic input mapping (shortcut for loop().inputMapper()) |
postProcess() | IPostProcess& | Active post-process pipeline (valid after setupPostProcess()) |
Scene management
| Member | Returns | Description |
|---|---|---|
loadScene(sceneUri) | LoadedScene | Load a scene JSON, populate the scene graph, and apply ambient colour. Throws on failure. |
startupSceneUri() | std::string | Returns game.json["scenes"]["main"], or empty string if absent. Call after construction to locate the entry-point scene. |
Post-processing
| Member | Returns | Description |
|---|---|---|
setupPostProcess(shader) | IPostProcess& | Create the offscreen framebuffer + screen-quad pipeline for the given tonemap shader. Must be called once before the first frame. |
Configuration & paths
| Member | Returns | Description |
|---|---|---|
registerPath(scheme, directory, readonly) | void | Map a URI scheme to an absolute filesystem directory. readonly defaults to true. |
loadAndApplyConfiguration(uri) | void | Load a config file by URI string and merge it with the current engine config. |
loadKeybinds() | void | Load res://keybinds.json and apply the active keybind scheme to the input mapper. |
Main loop
| Member | Returns | Description |
|---|---|---|
run() | int | Enter the main game loop. Returns EXIT_SUCCESS on clean shutdown. Dispatches events, then calls onPreRender → onRender → onPostRender each vsync frame. |
Convenience helper
Defined in engine.h, usable without a full engine instance:
src/core/engine.h
std::shared_ptr<spdlog::logger> getLogger(const std::string& name)
Shortcut for glitter::logging::log_manager::get(name).
glitter::engine_configuration
Loaded from engine.config.json during engine construction. All fields have explicit defaults — no null checks are required by callers.
Top-level fields
| Field | Type | Default | Description |
|---|---|---|---|
version | std::string | "" | Config schema version |
gameDir | std::string | "" | Directory containing game.json (resource paths) |
logging_level | spdlog::level::level_enum | warn | Global log level for all loggers |
subsystem_levels | map<string, level_enum> | {} | Per-subsystem log level overrides |
subsystem_sink_configs | map<string, json> | {} | Per-subsystem sink configuration JSON |
log_file_path | std::string | "logs/glitter.log" | Log file path relative to the executable |
renderer_config
| Field | Type | Default | Description |
|---|---|---|---|
use | std::string | "vulkan" | Renderer name; looked up in RendererRegistry. Falls back to the default if unknown. |
antialias | bool | true | Enable anti-aliasing (FXAA in post-process) |
window_config
| Field | Type | Default | Description |
|---|---|---|---|
width | int | 800 | Initial window width in pixels |
height | int | 600 | Initial window height in pixels |
resizable | bool | true | Allow the window to be resized |
fullscreen | bool | false | Start in fullscreen mode |
shadow_config
| Field | Type | Default | Description |
|---|---|---|---|
enabled | bool | true | Enable directional cascade shadow maps |
pointShadowsEnabled | bool | true | Enable omnidirectional point-light shadow cubemaps |
mapSize | int | 2048 | Shadow map resolution (square, in pixels) |
cascadeCount | int | 4 | Number of CSM cascades |
ssao_config
| Field | Type | Default | Description |
|---|---|---|---|
enabled | bool | false | Enable screen-space ambient occlusion |
kernelSize | int | 64 | SSAO hemisphere sample count |
radius | float | 0.5 | Sampling hemisphere radius in view space |
bias | float | 0.025 | Self-occlusion bias |
ibl_config
| Field | Type | Default | Description |
|---|---|---|---|
enabled | bool | true | Enable image-based lighting (irradiance map + pre-filtered specular + BRDF LUT) |
postprocess_config
| Field | Type | Default | Description |
|---|---|---|---|
exposure | float | 1.0 | Tonemap exposure multiplier |
forwardPassEnabled | bool | true | Render transparent / alpha-masked objects in a forward pass after deferred shading |
textures_config
| Field | Type | Default | Description |
|---|---|---|---|
maxAnisotropy | float | 16.0 | Maximum anisotropic filtering level (1/2/4/8/16) |
mipLodBias | float | 0.0 | MIP LOD bias — negative = sharper, positive = blurrier |
probes_config
| Field | Type | Default | Description |
|---|---|---|---|
skyBakeSize | int | 512 | Sky environment probe cubemap resolution (128/256/512/1024) |
localBakeSize | int | 128 | Local reflection probe cubemap resolution (64/128/256/512) |
Free functions
| Function | Returns | Description |
|---|---|---|
default_engine_configuration() | engine_configuration | Construct a config with all fields at their defaults |
load_engine_configuration(res, uri) | engine_configuration | Load from a JSON URI; throws on failure |
try_load_engine_configuration(res, uri) | expected<engine_configuration, string> | Load from a JSON URI; returns an error string on failure |
merge_engine_configuration(defaults, overrides) | engine_configuration | Merge two configs; fields present in overrides win |
apply_logging_configuration(cfg) | void | Push log levels from a config into log_manager |