Struct CallbackFn

Source
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 the wgpu::RenderPass so that it can issue draw commands.

The final argument of both the prepare and paint callbacks is a the [paint_callback_resources][crate::renderer::RenderPass::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_glow demo source for a detailed usage example.

Implementations§

Source§

impl CallbackFn

Source

pub fn new() -> Self

Source

pub fn prepare<F>(self, prepare: F) -> Self
where F: Fn(&Device, &Queue, &mut TypeMap) + Sync + Send + 'static,

Set the prepare callback

Source

pub fn paint<F>(self, paint: F) -> Self
where F: for<'a, 'b> Fn(PaintCallbackInfo, &'a mut RenderPass<'b>, &'b TypeMap) + Sync + Send + 'static,

Set the paint callback

Trait Implementations§

Source§

impl Default for CallbackFn

Source§

fn default() -> Self

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

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>