Skip to main content

run

Function run 

Source
pub fn run<H, B>(config: ShellConfig, build: B) -> Result<(), ShellError>
where H: ShellHost + 'static, B: FnOnce(&ShellInit<'_>) -> Result<(App, H), ShellError>,
Expand description

Open a window, bring up wgpu, build the app, and run the event loop until the window closes.

build is called once the window and the GPU exist — the device scale, input profile and surface size are already in place, which is what a widget tree wants to see while it is being built. It returns the App and the ShellHost that carries the app’s own per-frame plumbing; a host with nothing to add is crate::NoHost.

use agg_gui_shell::{run, NoHost, ShellConfig};

run(ShellConfig::new("My App"), move |_init| Ok((app, NoHost)))

§Ordering

  1. Restore and sanitise the saved window size, then refine it against the real monitor once the window exists (winit 0.30 only exposes monitors through a live Window).
  2. Create the window hidden, finish wgpu setup, build the app, and paint the first real frame before showing it — otherwise the user sees an unstyled OS-default background and a black border around the not-yet-configured surface.
  3. Install the agg-gui host waker only after the window and GPU came up, and clear it on every exit path (HostWakerGuard).