pub struct SurfaceState {
pub config: SurfaceConfiguration,
pub depth: DepthTexture,
/* private fields */
}Expand description
Swapchain surface and configuration for the active window.
Fields§
§config: SurfaceConfigurationCurrent surface configuration (dimensions, format, present mode).
depth: DepthTextureDepth buffer recreated on resize/reconfigure.
Implementations§
Source§impl SurfaceState
impl SurfaceState
Sourcepub fn new(
gpu: &GpuDevice,
window: &Arc<Window>,
width: u32,
height: u32,
) -> Result<Self, WgpuBackendError>
pub fn new( gpu: &GpuDevice, window: &Arc<Window>, width: u32, height: u32, ) -> Result<Self, WgpuBackendError>
Creates and configures the swapchain surface for the given window.
§Errors
Returns WgpuBackendError::CreateSurface if surface creation fails.
Sourcepub fn resize(&mut self, gpu: &GpuDevice, width: u32, height: u32)
pub fn resize(&mut self, gpu: &GpuDevice, width: u32, height: u32)
Resizes the swapchain and recreates the depth buffer.
No-op if either dimension is zero.
Sourcepub fn reconfigure(&mut self, gpu: &GpuDevice)
pub fn reconfigure(&mut self, gpu: &GpuDevice)
Reconfigures the swapchain with the current config and recreates the depth buffer.
Called internally when the surface is lost or outdated.
Sourcepub fn acquire_frame(
&mut self,
gpu: &GpuDevice,
) -> Result<SurfaceTexture, WgpuBackendError>
pub fn acquire_frame( &mut self, gpu: &GpuDevice, ) -> Result<SurfaceTexture, WgpuBackendError>
Acquires the next swapchain texture, reconfiguring once on loss or staleness.
§Errors
Returns WgpuBackendError::Surface if acquisition fails after one reconfigure attempt.
Sourcepub fn format(&self) -> TextureFormat
pub fn format(&self) -> TextureFormat
Returns the swapchain pixel format.
Auto Trait Implementations§
impl !Freeze for SurfaceState
impl !RefUnwindSafe for SurfaceState
impl !UnwindSafe for SurfaceState
impl Send for SurfaceState
impl Sync for SurfaceState
impl Unpin for SurfaceState
impl UnsafeUnpin for SurfaceState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn 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.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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.Source§fn as_any(&self) -> &(dyn Any + 'static)
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.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
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> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<H, TailTarget, Source, Idx> Embed<RenderTList<H, TailTarget>, There<Idx>> for Sourcewhere
TailTarget: IsRenderList,
Source: Embed<TailTarget, Idx>,
impl<H, TailTarget, Source, Idx> Embed<RenderTList<H, TailTarget>, There<Idx>> for Sourcewhere
TailTarget: IsRenderList,
Source: Embed<TailTarget, Idx>,
Source§fn embed(self) -> RenderTList<H, TailTarget>
fn embed(self) -> RenderTList<H, TailTarget>
Converts
self into Target.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more