get_current_texture

Function get_current_texture 

Source
pub fn get_current_texture(
    surface: &Surface<'_>,
    surface_config: &SurfaceConfiguration,
) -> RenderEvent
Expand description

Acquire the next surface texture or signal that the surface needs reconfiguration.

Returns a RenderEvent::Redraw with a ready-to-use texture view when successful, or RenderEvent::Resize when the surface was lost/outdated. Forward errors like OutOfMemory as RenderEvent::None while logging.

ยงExample

use wde_wgpu::instance::{get_current_texture, RenderEvent};

match get_current_texture(surface, config) {
    RenderEvent::Redraw(frame) => {
        // frame.texture -> call present after encoding work
        // frame.view -> attach to render passes
        drop(frame);
    }
    RenderEvent::Resize => println!("surface needs resize"),
    RenderEvent::None => println!("skipping frame"),
}