pub struct Surface { /* private fields */ }
Expand description
Handle to a presentable surface.
A Surface
represents a platform-specific surface (e.g. a window) onto which rendered images may
be presented. A Surface
may be created with the unsafe function Instance::create_surface
.
This type is unique to the Rust API of wgpu
. In the WebGPU specification,
GPUCanvasContext
serves a similar role.
Implementations§
source§impl Surface
impl Surface
sourcepub fn get_capabilities(&self, adapter: &Adapter) -> SurfaceCapabilities
pub fn get_capabilities(&self, adapter: &Adapter) -> SurfaceCapabilities
Returns the capabilities of the surface when used with the given adapter.
Returns specified values (see SurfaceCapabilities
) if surface is incompatible with the adapter.
sourcepub fn get_default_config(
&self,
adapter: &Adapter,
width: u32,
height: u32
) -> Option<SurfaceConfiguration<Vec<TextureFormat>>>
pub fn get_default_config( &self, adapter: &Adapter, width: u32, height: u32 ) -> Option<SurfaceConfiguration<Vec<TextureFormat>>>
Return a default SurfaceConfiguration
from width and height to use for the Surface
with this adapter.
Returns None if the surface isn’t supported by this adapter
sourcepub fn configure(
&self,
device: &Device,
config: &SurfaceConfiguration<Vec<TextureFormat>>
)
pub fn configure( &self, device: &Device, config: &SurfaceConfiguration<Vec<TextureFormat>> )
Initializes Surface
for presentation.
Panics
- A old
SurfaceTexture
is still alive referencing an old surface. - Texture format requested is unsupported on the surface.
sourcepub fn get_current_texture(&self) -> Result<SurfaceTexture, SurfaceError>
pub fn get_current_texture(&self) -> Result<SurfaceTexture, SurfaceError>
Returns the next texture to be presented by the swapchain for drawing.
In order to present the SurfaceTexture
returned by this method,
first a Queue::submit
needs to be done with some work rendering to this texture.
Then SurfaceTexture::present
needs to be called.
If a SurfaceTexture referencing this surface is alive when the swapchain is recreated, recreating the swapchain will panic.
sourcepub unsafe fn as_hal_mut<A, F, R>(&mut self, hal_surface_callback: F) -> R
pub unsafe fn as_hal_mut<A, F, R>(&mut self, hal_surface_callback: F) -> R
Returns the inner hal Surface using a callback. The hal surface will be None
if the
backend type argument does not match with this wgpu Surface
Safety
- The raw handle obtained from the hal Surface must not be manually destroyed
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Surface
impl Send for Surface
impl Sync for Surface
impl Unpin for Surface
impl !UnwindSafe for Surface
Blanket Implementations§
source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
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
source§impl<T, U> ConvertInto<U> for Twhere
U: ConvertFrom<T>,
impl<T, U> ConvertInto<U> for Twhere
U: ConvertFrom<T>,
source§fn convert_into(self) -> U
fn convert_into(self) -> U
source§fn convert_unclamped_into(self) -> U
fn convert_unclamped_into(self) -> U
source§fn try_convert_into(self) -> Result<U, OutOfBounds<U>>
fn try_convert_into(self) -> Result<U, OutOfBounds<U>>
OutOfBounds
error is returned which contains the unclamped color. Read more