pub struct SurfaceWindow { /* private fields */ }winit only.Expand description
A combined
winit::window::Window
&
wgpu::Surface.
Implementations§
Source§impl SurfaceWindow
impl SurfaceWindow
Sourcepub fn new(
event_loop: &ActiveEventLoop,
attributes: WindowAttributes,
config_opts: SurfaceConfigOptions,
) -> Result<Self, OsError>
pub fn new( event_loop: &ActiveEventLoop, attributes: WindowAttributes, config_opts: SurfaceConfigOptions, ) -> Result<Self, OsError>
Create a new window under an
winit::ActiveEventLoop.
Also requires a
winit::window::WindowAttributes
(though Default should work fine for most cases) and a SurfaceConfigOptions
(Default should be fine here too).
Sourcepub fn try_get_config(&self) -> Option<SurfaceConfiguration>
pub fn try_get_config(&self) -> Option<SurfaceConfiguration>
Try to get the wgpu::SurfaceConfiguration,
if the surface has been created.
Sourcepub fn init_surface(
&self,
instance: &Instance,
adapter: &Adapter,
device: &Device,
) -> Result<ActiveSurfaceWindow<'_>, ConfigSurfaceError>
pub fn init_surface( &self, instance: &Instance, adapter: &Adapter, device: &Device, ) -> Result<ActiveSurfaceWindow<'_>, ConfigSurfaceError>
Opaquely create, configure, and get the
wgpu::SurfaceTexture
&
wgpu::TextureView
of the underlying
winit::window::Window.
If the window’s
wgpu::Surface
hasn’t been created yet, it will do so now. If needed it’ll make a new
wgpu::SurfaceConfiguration
using either the window’s inner size or a manually provided one from
the last Self::resize.
Next, it’ll try getting its
wgpu::SurfaceTexture
with
wgpu::Surface::get_current_texture.
This may fail if the surface was old and needed to be refreshed, in which
case it’ll need to fully recreate the surface. If getting the surface
texture fails a 2nd time, the error will be raised to the caller.
Only one ActiveSurfaceWindow is allowed at any one time, this is
enforced during runtime.
Sourcepub fn init_with_context(
&self,
context: &RenderContext,
) -> Result<ActiveSurfaceWindow<'_>, ConfigSurfaceError>
pub fn init_with_context( &self, context: &RenderContext, ) -> Result<ActiveSurfaceWindow<'_>, ConfigSurfaceError>
Get a usable ActiveSurfaceWindow, which guarantees that the window
surface exists & is configured.
See Self::init_surface for more details.
Sourcepub fn try_drop_surface(&self) -> Result<(), BorrowMutError>
pub fn try_drop_surface(&self) -> Result<(), BorrowMutError>
Try to drop the surface.
Sourcepub fn drop_surface(&mut self)
pub fn drop_surface(&mut self)
Drop the surface now.
Sourcepub fn resize(&self, size: Option<PhysicalSize<u32>>)
pub fn resize(&self, size: Option<PhysicalSize<u32>>)
Set the target window size and trigger a reconfiguration.
If you pass None, the size will be queried from the window, or you can
specify it from a winit resize event. The surface will be reconfigured
when it’s next initialized.
Sourcepub fn reconfigure(&self)
pub fn reconfigure(&self)
Mark the surface to be reconfigured when it’s next initialized.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SurfaceWindow
impl !RefUnwindSafe for SurfaceWindow
impl Send for SurfaceWindow
impl !Sync for SurfaceWindow
impl Unpin for SurfaceWindow
impl UnsafeUnpin for SurfaceWindow
impl !UnwindSafe for SurfaceWindow
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.