Function reattach_renderer_to_window

Source
pub fn reattach_renderer_to_window(
    renderer: &mut Renderer,
    window: Arc<Window>,
) -> Result<SurfaceReattachOutcome, RendererError>
Expand description

Reattaches a retained renderer to a newly-created winit window.

Compatible surfaces reuse the existing instance, adapter, device, queue, pipelines, and caches. The renderer performs a full GPU bootstrap fallback when the retained adapter cannot present to the new surface. The new window’s current physical client size becomes the surface extent, and winit’s pre-present callback is installed for subsequent frames.

§Errors

Propagates surface creation, compatibility, or fallback bootstrap failures.

§Examples

use std::sync::Arc;
use ailloli_ui_render_wgpu::{Renderer, SurfaceReattachOutcome};
fn resume(renderer: &mut Renderer, window: Arc<winit::window::Window>) {
    let outcome: SurfaceReattachOutcome =
        ailloli_ui_winit::wgpu_bootstrap::reattach_renderer_to_window(renderer, window)
            .unwrap();
    let _ = outcome;
}