runtime
garnet-runtime
Add the runtime shard from your workspace or exported Garnet SDK to the host application's shard.yml. For an SDK exported to vendor/garnet:
dependencies:
garnet-runtime:
path: vendor/garnet/runtime
Require garnet-runtime for Garnet::Runtime, HostEvent, Diagnostics, and ECS. The host forwards lifecycle events and supplies its clock on the simulation owner thread. Once resumed with a surface, each call to frame advances the world's schedule. Use one frame driver per world.
require "garnet-runtime"
world = Garnet::World.new
runtime = Garnet::Runtime.new(world)
registration = world.schedule.add(:fixed_update) { |_, seconds| puts seconds }
runtime.handle(:resume)
runtime.handle(:surface_available)
runtime.frame
registration.close
Run scripts/check-portable-runtime from the workspace to export the portable SDK, install its dependencies offline, and exercise a host frame.
Drivers, lifecycle and frame pacing
World#run hands control to a Garnet::Driver. Garnet::HostDriver drives any Garnet::Host (a window or screen adapter that implements poll, close_requested?, focused? and drawable?, plus optional wait, before_frame and after_frame). App plugins such as Garnet::App::Desktop install one for you.
Each iteration polls the host, maps focus to Resume/Suspend and visibility to SurfaceAvailable/SurfaceLost, and advances one frame while active. A close request or World#exit ends the loop with Close.
Garnet::Lifecycle(resource) tracks foreground, surface, audio interruption and close.lifecycle.subscribe(world) { |event| }runs synchronously when the host reports an event, even between frames, so services like audio can stop immediately. The same events are emitted into the world asHostEventfor systems.Garnet::FramePolicy(resource) holdsmax_frame(delta clamp, 100 ms),fixed_delta(exact per-frame delta for captures and replays),pause_when_unfocused,frame_limitandidle_wait. Drivers read it every frame.
Runtime#step(delta) advances an exact delta while active, alongside Runtime#frame, which measures the host clock. Runtime and the raw hosts stay usable directly for custom loops.
runtime
- 0
- 0
- 0
- 1
- 2
- 1 day ago
- November 30, 2026
MIT License
Wed, 02 Dec 2026 02:09:04 GMT