pub struct SurfaceState { /* private fields */ }Expand description
A configured wgpu surface, ready for frame acquisition.
Does NOT own the wgpu::Surface — the consumer creates the surface
from their windowing system and passes it in. This struct manages
configuration, resize, and frame acquisition.
§Examples
ⓘ
let mut state = SurfaceState::configure(
&surface, &adapter, &device, width, height,
PresentModePreference::Vsync,
)?;
// On window resize:
state.resize(&surface, &device, new_width, new_height);
// Each frame:
let frame = state.get_current_texture(&surface)?;Implementations§
Source§impl SurfaceState
impl SurfaceState
Sourcepub fn configure(
surface: &Surface<'_>,
adapter: &Adapter,
device: &Device,
width: u32,
height: u32,
present_mode: PresentModePreference,
) -> Result<Self>
pub fn configure( surface: &Surface<'_>, adapter: &Adapter, device: &Device, width: u32, height: u32, present_mode: PresentModePreference, ) -> Result<Self>
Configure a surface for rendering.
Selects the best available format (preferring sRGB) and alpha mode.
Sourcepub fn resize(
&mut self,
surface: &Surface<'_>,
device: &Device,
width: u32,
height: u32,
)
pub fn resize( &mut self, surface: &Surface<'_>, device: &Device, width: u32, height: u32, )
Reconfigure the surface after a resize.
Silently skips zero-size dimensions (common during window minimize).
Sourcepub fn acquire(&self, surface: &Surface<'_>) -> Result<SurfaceTexture>
pub fn acquire(&self, surface: &Surface<'_>) -> Result<SurfaceTexture>
Acquire the next frame texture.
Sourcepub fn format(&self) -> TextureFormat
pub fn format(&self) -> TextureFormat
The surface texture format.
Auto Trait Implementations§
impl Freeze for SurfaceState
impl RefUnwindSafe for SurfaceState
impl Send for SurfaceState
impl Sync for SurfaceState
impl Unpin for SurfaceState
impl UnsafeUnpin for SurfaceState
impl UnwindSafe 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