Skip to main content

run_frame

Function run_frame 

Source
pub fn run_frame<F, E>(config: AppConfig, frame: F) -> Result<(), RunError>
where F: for<'frame> FnMut(&mut FrameContext<'frame>) -> Result<(), E> + 'static, E: Error + 'static,
Expand description

Runs an application with one fallible, exit-capable frame closure.

The closure value is retained by the runtime for the complete event-loop lifetime, so captured state persists between frames and across GPU generation recovery. FrameContext exposes the current UI, compiled add-ons, GPU generation, and FrameContext::request_exit. Returning an error preserves its Error::source chain and attributes it to ApplicationStage::Frame. Requesting exit is a normal control signal and returns Ok(()) after exactly-once shutdown.

Use run_ui when the callback only needs imgui::Ui. Use run when initialization, event, GPU recovery, or shutdown hooks are required.