pub struct CallbackFn { /* private fields */ }
Expand description

A callback function that can be used to compose an [egui::PaintCallback] for custom WGPU rendering.

The callback is composed of two functions: prepare and paint:

  • prepare is called every frame before paint, and can use the passed-in wgpu::Device and wgpu::Buffer to allocate or modify GPU resources such as buffers.
  • paint is called after prepare and is given access to the wgpu::RenderPass so that it can issue draw commands into the same wgpu::RenderPass that is used for all other egui elements.

The final argument of both the prepare and paint callbacks is a the paint_callback_resources. paint_callback_resources has the same lifetime as the Egui render pass, so it can be used to store buffers, pipelines, and other information that needs to be accessed during the render pass.

Example

See the custom3d_wgpu demo source for a detailed usage example.

Implementations§

Set the prepare callback.

The passed-in CommandEncoder is egui’s and can be used directly to register wgpu commands for simple use cases. This allows reusing the same wgpu::CommandEncoder for all callbacks and egui rendering itself.

For more complicated use cases, one can also return a list of arbitrary CommandBuffers and have complete control over how they get created and fed. In particular, this gives an opportunity to parallelize command registration and prevents a faulty callback from poisoning the main wgpu pipeline.

When using eframe, the main egui command buffer, as well as all user-defined command buffers returned by this function, are guaranteed to all be submitted at once in a single call.

Set the paint callback

Trait Implementations§

Returns the “default value” for a type. Read more

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