pub struct Runtime { /* private fields */ }Expand description
Coordinates simulation-latched input, a fixed-rate simulation clock, and presentation pacing.
Implementations§
Source§impl Runtime
impl Runtime
Sourcepub fn new(config: RuntimeConfig, started_at: Instant) -> Self
pub fn new(config: RuntimeConfig, started_at: Instant) -> Self
Starts a runtime clock at started_at with no accumulated simulation debt.
Sourcepub fn record_presented(&mut self, presented_at: Instant)
pub fn record_presented(&mut self, presented_at: Instant)
Records one presented frame with the display time the backend reported for it.
Drain the graphics surface’s presentation feedback into this method (or
Self::record_untimed_presented) every frame. Once the recorded timestamps yield a
cadence estimate, Self::begin_frame advances simulation time by whole display
intervals instead of wall-clock gaps.
Sourcepub fn record_untimed_presented(&mut self)
pub fn record_untimed_presented(&mut self)
Records one frame whose presentation completed without a reported display time, such as while the window is off screen.
Sourcepub fn pacing_report(&self) -> PacingReport
pub fn pacing_report(&self) -> PacingReport
Summarizes the presentation pacing recorded so far.
Sourcepub fn handle_input(&mut self, event: InputEvent)
pub fn handle_input(&mut self, event: InputEvent)
Adds one ordered native input transition to the current snapshot.
Sourcepub fn handle_window_event(&mut self, event: WindowEvent)
pub fn handle_window_event(&mut self, event: WindowEvent)
Applies the input and rendering-lifecycle parts of one platform window event.
Redraw, metrics, and close policy remain with the application. Lower-level input, suspend, and resume methods remain available when an application uses a different coordination shape.
Sourcepub const fn input(&self) -> &InputSnapshot
pub const fn input(&self) -> &InputSnapshot
Returns held state and transitions accumulated since the last simulation-bearing frame.
Sourcepub fn begin_frame(&mut self, now: Instant) -> RuntimeFrame<'_>
pub fn begin_frame(&mut self, now: Instant) -> RuntimeFrame<'_>
Begins a scoped frame with fixed simulation work, input, and render interpolation.
While recorded presentation feedback yields a fresh cadence estimate, the frame delta is a
whole number of display intervals; call this once per frame that will be presented, since
every paced call advances at least one interval. Without feedback, or when it goes stale,
the delta observably falls back to the wall-clock gap since the previous frame — see
RuntimeFrame::schedule.
Dropping a frame with fixed updates consumes transient input, including on early return. A frame with no fixed update retains it for the next simulation-bearing frame.
Sourcepub fn suspend(&mut self)
pub fn suspend(&mut self)
Pauses frame timing and releases every held input control.
The fractional fixed-step accumulator is preserved so rendering can resume without a small
interpolation jump. Calls to Self::begin_frame while suspended schedule no updates.