pub struct Painter<'a> { /* private fields */ }
Expand description

Everything you need to paint egui with wgpu on winit.

Alternatively you can use crate::renderer directly.

Implementations

Manages wgpu state, including surface state, required to render egui.

Only the wgpu::Instance is initialized here. Device selection and the initialization of render + surface state is deferred until the painter is given its first window target via set_window(). (Ensuring that a device that’s compatible with the native window is chosen)

Before calling paint_and_update_textures() a wgpu::Surface must be initialized (and corresponding render state) by calling set_window() once you have a winit::window::Window with a valid .raw_window_handle() associated.

Get the RenderState.

Will return None if the render state has not been initialized yet.

Updates (or clears) the winit::window::Window associated with the Painter

This creates a wgpu::Surface for the given Window (as well as initializing render state if needed) that is used for egui rendering.

This must be called before trying to render via paint_and_update_textures

Portability

In particular it’s important to note that on Android a it’s only possible to create a window surface between Resumed and Paused lifecycle events, and Winit will panic on attempts to query the raw window handle while paused.

On Android set_window should be called with Some(window) for each Resumed event and None for each Paused event. Currently, on all other platforms set_window may be called with Some(window) as soon as you have a valid winit::window::Window.

Safety

The raw Window handle associated with the given window must be a valid object to create a surface upon and must remain valid for the lifetime of the created surface. (The surface may be cleared by passing None).

Returns the maximum texture dimension supported if known

This API will only return a known dimension after set_window() has been called at least once, since the underlying device and render state are initialized lazily once we have a window (that may determine the choice of adapter/device).

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more