Skip to main content

ActiveSurfaceWindow

Struct ActiveSurfaceWindow 

Source
pub struct ActiveSurfaceWindow<'w> { /* private fields */ }
Available on crate features winit only.
Expand description

A borrowed form of SurfaceWindow which guarantees that its surface exists & is configured, ready to be rendered to.

Only one instance is allowed at any time (per SurfaceWindow). wgpu panics if multiple wgpu::SurfaceTextures exist in specific conditions, so the safest thing to do is make sure only one can exist.

Implementations§

Source§

impl ActiveSurfaceWindow<'_>

Source

pub unsafe fn surface(&self) -> &Surface<'static>

Get the window’s wgpu::Surface.

This is unsafe because reconfiguring this surface while it has an active view will cause wgpu to panic. wgpu doesn’t enforce this so I gotta. In other words:
ABSOLUTELY DO NOT CALL wgpu::Surface::configure ON THIS SURFACE

Source

pub fn config(&self) -> SurfaceConfiguration

Get the surface’s wgpu::SurfaceConfiguration.

Under the hood, self.surface().get_configuration().unwrap() - the surface is guaranteed to be configured if it made it into this struct.

Source

pub fn window(&self) -> &Window

Source

pub fn get_size(&self) -> PhysicalSize<u32>

Convenience function to get the window’s inner size.

Source

pub fn get_config_size(&self) -> PhysicalSize<u32>

Convenience function to get the configured size of the surface.

Resize events may not be sent in time before a frame runs, leading to desyncs. This may cause a panic on wgpu’s side if you have a depth, which needs to always be kept the same size as the configured surface.
See also Self::resized.

Source

pub fn texture(&self) -> &SurfaceTexture

Get the surface’s wgpu::SurfaceTexture.

Source

pub fn view(&self) -> &TextureView

Get the surface texture’s wgpu::TextureView with default settings.

Source

pub fn resized(&self) -> bool

Returns true if the surface has just been resized (reconfigured or rebuilt with a new size since last frame).

Useful to keep a depth stencil buffer in-sync.

Source

pub fn as_colour_attachment<'a>( &'a self, clear: Option<Color>, ) -> RenderPassColorAttachment<'a>

Get a wgpu::RenderPassColorAttachment to attach this surface’s texture to a render pass, to draw to it using a specified clear colour.

Source

pub fn present_texture(self)

Present the graphics operations to the surface. Consumes this struct, init a new one for next frame.

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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
§

impl<T> Upcast<T> for T

§

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

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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