Expand description
The public-facing Software Development Kit (SDK) for the Khora Engine.
This is the only crate that should be used by game developers. All internal crates (khora-agents, khora-control, etc.) are implementation details.
§Examples
A minimal game is an EngineApp handed to run_winit. The SDK owns the
engine loop; your type owns the game logic. Everything you need for game code
is in prelude.
use khora_sdk::prelude::*;
use khora_sdk::prelude::math::Vec3;
use khora_sdk::{
run_winit, AgentProvider, DccService, EngineApp, GameWorld, PhaseProvider,
Runtime, Vessel, WindowConfig,
};
use khora_sdk::winit_adapters::WinitWindowProvider;
struct MyGame;
impl EngineApp for MyGame {
fn window_config() -> WindowConfig {
WindowConfig { title: "My Game".into(), ..WindowConfig::default() }
}
fn new() -> Self {
MyGame
}
fn setup(&mut self, world: &mut GameWorld, _runtime: &Runtime) {
// Spawn a camera looking down the -Z axis.
let camera = ecs::Camera::new_perspective(
std::f32::consts::FRAC_PI_4,
16.0 / 9.0,
0.1,
1000.0,
);
Vessel::at(world, Vec3::new(0.0, 2.0, 10.0))
.with_component(camera)
.build();
}
fn update(&mut self, _world: &mut GameWorld, _inputs: &[InputEvent]) {}
}
// `AgentProvider` / `PhaseProvider` are required super-traits; the default
// (no custom agents, no custom phases) is enough for most games.
impl AgentProvider for MyGame {
fn register_agents(&self, _dcc: &DccService, _runtime: &mut Runtime) {}
}
impl PhaseProvider for MyGame {}
fn main() -> anyhow::Result<()> {
run_winit::<WinitWindowProvider, MyGame>(|_window, _runtime, _event_loop| {
// Wire backends (renderer, physics, audio, …) into `_runtime` here.
})
}Re-exports§
pub extern crate inventory;
Re-exports§
pub use winit_adapters::run_winit;pub use winit_adapters::WinitAppRunner;pub use winit_adapters::WinitWindowProvider;pub use khora_io;pub use khora_data;pub use khora_core;pub use khora_agents;pub use khora_lanes;pub use winit;
Modules§
- editor_
ui - Editor UI types re-exported from khora_core.
- prelude
- Common imports for game development.
- renderer
- Renderer sub-modules (used by editor gizmo)
- tool_ui
- UI surface for standalone Khora tools (the hub, future asset cookers, …).
- winit_
adapters - Winit-specific integration for the Khora Engine.
Structs§
- Agent
Hints - The accumulated hint state for one agent, folded from the
EngineHints the DCC has received. ANonefield means “no developer hint — use the engine default”. Persists across ticks until overwritten by a newer hint. - Agent
Registry - Registry that manages all registered agents with automatic priority ordering.
- Agent
Status - A snapshot of an Agent’s current health and performance.
- Asset
Change Event - One filesystem change against an asset under the watched root.
- Asset
Entry - A lightweight description of an asset for the asset browser panel.
- Asset
IdRegistry - Maps forward-slash relative asset paths to their frozen
AssetUUID. - Asset
Service - The asset management service.
- Asset
Watcher - Drains filesystem-change events under a project’s
assets/directory. - Backends
- Container of engine backends — concrete impls of abstract traits.
- Command
History - Fixed-capacity undo/redo stack.
- Component
Json - Snapshot of one component on an inspected entity, captured generically
as JSON via the macro-generated
to_jsononComponentRegistration. - Component
Registration - Registration entry for a serializable component type.
- Cpal
Audio Device - CPAL-backed
AudioDevicefactory. - DccConfig
- Configuration for the DCC Service.
- DccContext
- The complete context model used for strategic decision making.
- DccService
- The Dynamic Context Core service.
- Default
MixBus - Mutex-backed ringbuffer impl of
AudioMixBus. - EcsWorld
- The central container for the entire ECS, holding all entities, components, and metadata.
- Editor
Camera - An orbit camera controller for the editor viewport.
- Editor
Command - A reversible editor operation.
- Editor
LogCapture - A
log::Logimplementation that stores entries in a shared buffer and also writes to stderr. - Editor
State - Shared editor state populated by
Application::update()each frame. - Engine
Context - The complete context model used for strategic decision making.
- Engine
Core - The core engine state, independent of any windowing backend.
- Environment
Map - Selects the scene’s environment source for the IBL bake.
- Execution
Phase - A phase in the frame execution pipeline.
- Execution
Timing - Declares when and how an agent should execute within the frame pipeline.
- File
Loader - File-based asset loader for editor/development mode.
- File
System Resolver - Resolves resources from the local filesystem relative to a base path.
- Font
Pack - A collection of fonts grouped by family.
- Game
World - A high-level facade over the internal ECS
WorldandAssetsregistry. - Gizmo
Line Instance - A single line segment for GPU rendering.
- GpuMonitor
- GPU performance monitor that works with any RenderSystem implementation.
- Handle
Component - A generic ECS component that associates an entity with a shared asset resource. It holds both a handle to the loaded data and the asset’s unique identifier.
- Index
Builder - Recursive scanner that turns a project’s
assets/directory into anAssetMetadatalist ready for the VFS. - Inspected
Entity - Snapshot of an inspected entity.
- Interaction
- Result of an
UiBuilder::interact_rectcall. - LogEntry
- A captured log entry for the console panel.
- Mat4
- A 4x4 column-major matrix, used for 3D affine transformations.
- Memory
Monitor - System memory resource monitor.
- Mesh
- Represents a complete mesh with vertex data and indices.
- Mesh
Dispatcher - Default mesh dispatcher: delegates to gltf or obj based on byte sniffing.
- Metrics
Registry - Central registry for metrics in the KhoraEngine
- Monitor
Registry - A thread-safe registry for resource monitors.
- Named
Font - A named font face inside a pack. The name is used by the backend to register the font in its registry and (where applicable) to make it addressable by user code.
- Pack
Builder - Builds a release pack from a project’s
assets/directory. - Pack
Header - Decoded form of the 24-byte header at the start of
data.pack. - Pack
Loader - Pack-based asset loader for release mode.
- Pack
Output - Output of a successful
PackBuilder::build. - Rapier
Physics World - Implementation of the
PhysicsProvidertrait using the Rapier3D physics engine. - Resources
- Container of engine resources — long-lived shared state that is principally data (with at most trivial accessors), not a service.
- Runtime
- Bundle of the three runtime containers.
- Scene
File - A logical representation of a full scene file in memory.
- Scene
Node - A lightweight description of an entity in the scene tree.
- Serialization
Service - The serialization service.
- Services
- Container of engine services — concrete stateful objects with rich APIs (asset loading, serialization, telemetry, DCC orchestration).
- Sound
Data - Represents a sound asset, decoded and ready for playback.
- Standard
Text Renderer - A “maison” (home-made) text renderer that is backend-agnostic.
- Status
BarData - Status bar data displayed at the bottom of the editor.
- Stream
Info - A struct providing information about the audio stream.
- Symphonia
Decoder - Decodes multiple audio formats via
symphonia. - Taffy
Layout System - Layout system implementation using the Taffy layout engine.
- Telemetry
Service - Central service for collecting and managing engine-wide telemetry.
- UiTheme
- Color palette and sizing tokens for any Khora UI surface.
- Vessel
- A high-level wrapper around an ECS entity.
- Viewport
Texture Handle - An opaque handle referencing a texture that the UI backend knows how to display.
- Wgpu
Pipeline System - The wgpu/naga_oil
PipelineSystembackend. Injected viaruntime.backendsasArc<dyn PipelineSystem>. - Wgpu
Render System - The concrete, WGPU-based implementation of the
RenderSystemtrait. - Window
Config - Window configuration for applications.
- Window
Icon - Raw window icon data for native window creation.
Enums§
- AgentId
- Unique identifier for engine agents with implicit priority ordering.
- Agent
Importance - How critical an agent is for frame correctness — and therefore whether GORNA budget arbitration may skip it under pressure.
- Asset
Change Kind - What kind of change happened to an asset on disk.
- Asset
Source - Represents the physical source of an asset’s data.
- Editor
Mode - The active editing workspace, switched via the left “spine” mode bar.
- Engine
Hint - A developer/editor hint that biases GORNA arbitration without changing game
semantics — the “adapt the HOW, not the WHAT” control surface, on the same
axis as [
AdaptationMode]. Hints are advisory: a death-spiral safety stop and aManualpin both still win over them. Sent to the DCC over the hint channel; the DCC folds them per agent (seeAgentHints) and feeds the accumulated state into each arbitration round. - Engine
Mode - The current mode of the engine.
- Entity
Icon - Icon hint for the scene tree.
- Font
Family Hint - Font family hint passed to
UiBuilder::paint_text_styled. Backends map each variant to whichever face was registered for that family. - Font
Handle - A bundled font, either as a static slice or owned bytes loaded at runtime.
- Gizmo
Kind - The kind of gizmo to draw for an entity.
- Gizmo
Mode - The active gizmo tool in the viewport toolbar.
- Icon
- A semantic icon identifier mapped to a Lucide codepoint.
- Input
Event - An engine-internal representation of a user input event.
- KeyCode
- Type-safe physical key codes — a 1-to-1 mirror of
winit::keyboard::KeyCodebut living inkhora-coreso app code never has to depend on winit. - LogLevel
- Log severity matching
log::Level. - Monitored
Resource Type - An enumeration of the types of resources that can be monitored.
- Mouse
Button - An engine-internal representation of a mouse button.
- Pack
Progress - One step of a pack build, suitable for driving a UI progress bar.
- Panel
Location - Where a panel is placed in the editor dock layout.
- Play
Mode - The play-mode state of the editor.
- Property
Edit - A property edit to apply back to the ECS world.
- Serialization
Goal - Defines the developer’s high-level intention for a serialization operation.
- Strategy
Id - Generic strategy identifier for budget allocation.
- Telemetry
Event - A high-level telemetry event produced by the Hot Path or hardware sensors.
- Text
Align - Horizontal alignment for
UiBuilder::paint_text_styled.
Constants§
- PACK_
FORMAT_ VERSION - Current pack format version. Bumped when the on-disk layout changes in a non-additive way; older runtimes refuse newer packs by reading the version from the header.
- PACK_
HEADER_ SIZE - Total size in bytes of the leading
PackHeaderindata.pack. Asset offsets recorded inindex.binare relative to the start of the asset region, not to byte 0 —PackLoaderadds this constant when seeking. - PACK_
MAGIC - 8-byte magic prefix that identifies a Khora pack archive on disk.
- PRIMARY_
VIEWPORT - Well-known viewport handle for the primary 3D viewport.
- TEXT_
WGSL - Shader for text rendering. Consumed by
khora_infra::StandardTextRenderer::newas a rawString.
Traits§
- Agent
Provider - Allows the application to register custom agents with the DCC.
- AssetIo
- Trait for asset I/O backends (file system or pack archive).
- Asset
Writer - Sibling trait to
AssetIofor editor-time writing of assets back to storage. Implemented only bycrate::asset::FileLoader— release builds (PackLoader) are intentionally read-only, which is whyAssetWriterlives separately rather than extendingAssetIo. - Audio
Device - Factory for an audio output stream.
- Audio
MixBus - The contract between audio-producing lanes and the audio backend.
- Audio
Stream - Live audio stream handle. Drop = stop.
- Editor
Panel - A single editor panel that can render itself into a
UiBuilder. - Editor
Shell - The top-level editor shell — a generic host for docked panels.
- Engine
App - The single generic bound for the engine’s application type.
- Layout
System - A trait defining a system capable of computing UI layouts.
- Phase
Provider - Allows the application to add custom execution phases to the scheduler.
- Physics
Provider - Interface contract for any physics engine implementation (e.g., Rapier).
- Pipeline
System - Backend that compiles shaders and builds/caches bind-group layouts and render pipelines on demand. See the module docs.
- Render
System - A high-level trait representing the entire rendering subsystem.
- Text
Renderer - A service responsible for laying out and rendering text.
- UiBuilder
- A backend-agnostic, immediate-mode widget builder.
- Window
Provider - Provides a platform window for the engine to render into.
Functions§
- generate_
selection_ gizmos - Generates all gizmo lines for a set of selected entities.
- instantiate_
subtree - Inverse of
serialize_subtree. Decodes the recipe bytes and spawns the subtree intoworld, returning the new root’sEntityIdso the caller can position it / reparent it / treat it as the drop target’s child. - run_
default - Boots a Khora game with the default runtime app: auto-detects pack vs
loose assets, registers every default decoder, and loads the scene
named in
runtime.json. This is what the pre-builtkhora-runtimebinary calls and what a user project’ssrc/main.rsshould call when it doesn’t need to register custom components/agents/lanes. - serialize_
subtree - Encodes the subtree rooted at
root(root + all descendants reached via theChildrencomponent) as a stand-alone bincode-encodedSceneRecipe. Exists to back the editor’s “Save as Prefab” flow: the resulting bytes round-trip throughinstantiate_subtree. - spawn_
cube_ at - Creates a Vessel with a cube mesh at a specific position.
- spawn_
plane - Creates a Vessel with a plane mesh at the origin.
- spawn_
sphere - Creates a Vessel with a sphere mesh at the origin.