Struct nannou::frame::raw::RawFrame

source ·
pub struct RawFrame<'swap_chain> { /* private fields */ }
Expand description

Allows the user to draw a single RawFrame to the surface of a window.

The application’s view function is called each time the application is ready to retrieve a new image that will be displayed to a window. The RawFrame type can be thought of as the canvas to which you draw this image.

Under the hood - WGPU

RawFrame provides access to the wgpu::TextureViewHandle associated with the swap chain’s current target texture for a single window.

In the case that your view function is shared between multiple windows, can determine which window the RawFrame is associated with via the RawFrame::window_id method.

The user can draw to the swap chain texture by building a list of commands via a wgpu::CommandEncoder and submitting them to the wgpu::Queue associated with the wgpu::Device that was used to create the swap chain. It is important that the queue matches the device. In an effort to reduce the chance for errors to occur, RawFrame provides access to a wgpu::CommandEncoder whose commands are guaranteed to be submitted to the correct wgpu::Queue at the end of the view function.

Implementations§

source§

impl<'swap_chain> RawFrame<'swap_chain>

source

pub fn command_encoder(&self) -> RefMut<'_, CommandEncoder>

Access the command encoder in order to encode commands that will be submitted to the swap chain queue at the end of the call to view.

source

pub fn window_id(&self) -> Id

The Id of the window whose wgpu surface is associated with this frame.

source

pub fn rect(&self) -> Rect

A Rect representing the full surface of the frame.

The returned Rect is equivalent to the result of calling Window::rect on the window associated with this Frame.

source

pub fn nth(&self) -> u64

The nth frame for the associated window since the application started.

E.g. the first frame yielded will return 0, the second will return 1, and so on.

source

pub fn swap_chain_texture(&self) -> &TextureViewHandle

The swap chain texture that will be the target for drawing this frame.

source

pub fn texture_format(&self) -> TextureFormat

The texture format of the frame’s swap chain texture.

source

pub fn device_queue_pair(&self) -> &Arc<DeviceQueuePair>

The device and queue on which the swap chain was created and which will be used to submit the RawFrame’s encoded commands.

This refers to the same DeviceQueuePair as held by the window associated with this frame.

source

pub fn submit(self)

Submit the frame to the GPU!

Specifically, this submits the encoded commands to the queue of the device that was used to create the swap chain texture.

Note: You do not need to call this manually as submission will occur automatically when the Frame is dropped.

Note: Be careful that you do not currently possess a lock to either the frame’s command encoder or the queue of the window associated with this frame or this method will lock and block forever.

source

pub fn clear(&self, texture_view: &TextureView, color: Color)

Clear the texture with the given color.

Trait Implementations§

source§

impl<'swap_chain> Drop for RawFrame<'swap_chain>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'swap_chain> !RefUnwindSafe for RawFrame<'swap_chain>

§

impl<'swap_chain> Send for RawFrame<'swap_chain>

§

impl<'swap_chain> !Sync for RawFrame<'swap_chain>

§

impl<'swap_chain> Unpin for RawFrame<'swap_chain>

§

impl<'swap_chain> !UnwindSafe for RawFrame<'swap_chain>

Blanket Implementations§

source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: Component + Float, Swp: WhitePoint, Dwp: WhitePoint, D: AdaptFrom<S, Swp, Dwp, T>,

source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<Swp, Dwp, T>,

Convert the source color to the destination color using the specified method
source§

fn adapt_into(self) -> D

Convert the source color to the destination color using the bradford method by default
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, U> ConvertInto<U> for T
where U: ConvertFrom<T>,

source§

fn convert_into(self) -> U

Convert into T with values clamped to the color defined bounds Read more
source§

fn convert_unclamped_into(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
source§

fn try_convert_into(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
§

impl<T> Downcast<T> for T

§

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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

§

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>,

§

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.
§

impl<T> Upcast<T> for T

§

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

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WasmNotSend for T
where T: Send,