pub struct ActiveSurfaceWindow<'w> { /* private fields */ }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<'_>
impl ActiveSurfaceWindow<'_>
Sourcepub unsafe fn surface(&self) -> &Surface<'static>
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
Sourcepub fn config(&self) -> SurfaceConfiguration
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.
Sourcepub fn window(&self) -> &Window
pub fn window(&self) -> &Window
Get the winit::window::Window.
Sourcepub fn get_size(&self) -> PhysicalSize<u32>
pub fn get_size(&self) -> PhysicalSize<u32>
Convenience function to get the window’s inner size.
Sourcepub fn get_config_size(&self) -> PhysicalSize<u32>
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.
Sourcepub fn texture(&self) -> &SurfaceTexture
pub fn texture(&self) -> &SurfaceTexture
Get the surface’s
wgpu::SurfaceTexture.
Sourcepub fn view(&self) -> &TextureView
pub fn view(&self) -> &TextureView
Get the surface texture’s
wgpu::TextureView
with default settings.
Sourcepub fn resized(&self) -> bool
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.
Sourcepub fn as_colour_attachment<'a>(
&'a self,
clear: Option<Color>,
) -> RenderPassColorAttachment<'a>
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.
Sourcepub fn present_texture(self)
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§
impl<'w> Freeze for ActiveSurfaceWindow<'w>
impl<'w> !RefUnwindSafe for ActiveSurfaceWindow<'w>
impl<'w> !Send for ActiveSurfaceWindow<'w>
impl<'w> !Sync for ActiveSurfaceWindow<'w>
impl<'w> Unpin for ActiveSurfaceWindow<'w>
impl<'w> UnsafeUnpin for ActiveSurfaceWindow<'w>
impl<'w> !UnwindSafe for ActiveSurfaceWindow<'w>
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.