Skip to main content

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

MemberReturnsDescription
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

MemberReturnsDescription
loadScene(sceneUri)LoadedSceneLoad a scene JSON, populate the scene graph, and apply ambient colour. Throws on failure.
startupSceneUri()std::stringReturns game.json["scenes"]["main"], or empty string if absent. Call after construction to locate the entry-point scene.

Post-processing

MemberReturnsDescription
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

MemberReturnsDescription
registerPath(scheme, directory, readonly)voidMap a URI scheme to an absolute filesystem directory. readonly defaults to true.
loadAndApplyConfiguration(uri)voidLoad a config file by URI string and merge it with the current engine config.
loadKeybinds()voidLoad res://keybinds.json and apply the active keybind scheme to the input mapper.

Main loop

MemberReturnsDescription
run()intEnter 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

FieldTypeDefaultDescription
versionstd::string""Config schema version
gameDirstd::string""Directory containing game.json (resource paths)
logging_levelspdlog::level::level_enumwarnGlobal log level for all loggers
subsystem_levelsmap<string, level_enum>{}Per-subsystem log level overrides
subsystem_sink_configsmap<string, json>{}Per-subsystem sink configuration JSON
log_file_pathstd::string"logs/glitter.log"Log file path relative to the executable

renderer_config

FieldTypeDefaultDescription
usestd::string"vulkan"Renderer name; looked up in RendererRegistry. Falls back to the default if unknown.
antialiasbooltrueEnable anti-aliasing (FXAA in post-process)

window_config

FieldTypeDefaultDescription
widthint800Initial window width in pixels
heightint600Initial window height in pixels
resizablebooltrueAllow the window to be resized
fullscreenboolfalseStart in fullscreen mode

shadow_config

FieldTypeDefaultDescription
enabledbooltrueEnable directional cascade shadow maps
pointShadowsEnabledbooltrueEnable omnidirectional point-light shadow cubemaps
mapSizeint2048Shadow map resolution (square, in pixels)
cascadeCountint4Number of CSM cascades

ssao_config

FieldTypeDefaultDescription
enabledboolfalseEnable screen-space ambient occlusion
kernelSizeint64SSAO hemisphere sample count
radiusfloat0.5Sampling hemisphere radius in view space
biasfloat0.025Self-occlusion bias

ibl_config

FieldTypeDefaultDescription
enabledbooltrueEnable image-based lighting (irradiance map + pre-filtered specular + BRDF LUT)

postprocess_config

FieldTypeDefaultDescription
exposurefloat1.0Tonemap exposure multiplier
forwardPassEnabledbooltrueRender transparent / alpha-masked objects in a forward pass after deferred shading

textures_config

FieldTypeDefaultDescription
maxAnisotropyfloat16.0Maximum anisotropic filtering level (1/2/4/8/16)
mipLodBiasfloat0.0MIP LOD bias — negative = sharper, positive = blurrier

probes_config

FieldTypeDefaultDescription
skyBakeSizeint512Sky environment probe cubemap resolution (128/256/512/1024)
localBakeSizeint128Local reflection probe cubemap resolution (64/128/256/512)

Free functions

FunctionReturnsDescription
default_engine_configuration()engine_configurationConstruct a config with all fields at their defaults
load_engine_configuration(res, uri)engine_configurationLoad 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_configurationMerge two configs; fields present in overrides win
apply_logging_configuration(cfg)voidPush log levels from a config into log_manager