Function renderer_from_window

Source
pub fn renderer_from_window(
    window: Arc<Window>,
) -> Result<Renderer, RendererError>
Expand description

Builds the GPU renderer for the given window.

The window is wrapped in Arc so the wgpu Surface and the application co-own it. Without shared ownership, the surface could reference a moved/dropped window, causing flaky Wayland segfaults at startup. The current physical inner size, including a possible zero minimized size, seeds renderer configuration; renderer defaults choose the remaining policy.

§Errors

Propagates adapter, device, surface, and renderer initialization failures.

§Examples

use std::sync::Arc;
use ailloli_ui_winit::wgpu_bootstrap::renderer_from_window;
fn initialize(window: Arc<winit::window::Window>) {
    let renderer: ailloli_ui_render_wgpu::Renderer = renderer_from_window(window).unwrap();
    let _ = renderer;
}