fn resize(&mut self, new_size: winit::dpi::PhysicalSize<u32>) {
        self.size = new_size;
        self.surface_configs.width = new_size.width;
        self.surface_configs.height = new_size.height;

        self.camera.aspect = self.size.width as f32 / self.size.height as f32;
        self.surface.configure(&self.device, &self.surface_configs);
        self.front_face_pass
            .resize(&self.device, self.size.width, self.size.height);
        self.back_face_pass
            .resize(&self.device, self.size.width, self.size.height);
        self.front_face_pass.update_model_view_proj_uniform(
            self.cube_scaling.clone(),
            &self.camera,
            &self.queue,
        );
        self.back_face_pass.update_model_view_proj_uniform(
            self.cube_scaling.clone(),
            &self.camera,
            &self.queue,
        );
        self.canvas_pass
            .resize(&self.device, self.size.width, self.size.height);

        self.front_face_render_buffer = Tex::create_render_buffer(
            (self.size.width, self.size.height),
            &self.device,
            Some("Front Face Render Buffer"),
            NonZeroU32::new(State::FACE_RENDER_BUFFER_SAMPLE_COUNT).unwrap(),
            &self.front_face_render_buffer.format,
        );
        self.back_face_render_buffer = Tex::create_render_buffer(
            (self.size.width, self.size.height),
            &self.device,
            Some("Back Face Render Buffer"),
            NonZeroU32::new(State::FACE_RENDER_BUFFER_SAMPLE_COUNT).unwrap(),
            &self.back_face_render_buffer.format,
        );
        self.canvas_pass.change_bound_face_textures(
            &self.device,
            &self.front_face_render_buffer,
            &self.back_face_render_buffer,
        );
    }
// If we want to support resizing in our application, we're going to need to recreate the swap_chain everytime the window's size changes.
// That's the reason we stored the physical size and the sc_desc used to create the swap chain.
If we want to support resizing in our application, we're going to need to recreate the swap_chain everytime the window's size changes.
That's the reason we stored the physical size and the sc_desc used to create the swap chain.
If we want to support resizing in our application we ' re going to need to recreate the swap_chain everytime the window ' s size changes . That ' s the reason we stored the physical size and the sc_desc used to create the swap chain .
fn resize(&mut self, new_size: winit::dpi::PhysicalSize<u32>) {
        self.size = new_size;
        self.surface_configs.width = new_size.width;
        self.surface_configs.height = new_size.height;
        self.camera.aspect = self.size.width as f32 / self.size.height as f32;
        self.surface.configure(&self.device, &self.surface_configs);
        self.front_face_pass
            .resize(&self.device, self.size.width, self.size.height);
        self.back_face_pass
            .resize(&self.device, self.size.width, self.size.height);
        self.front_face_pass.update_model_view_proj_uniform(
            self.cube_scaling.clone(),
            &self.camera,
            &self.queue,
        );
        self.back_face_pass.update_model_view_proj_uniform(
            self.cube_scaling.clone(),
            &self.camera,
            &self.queue,
        );
        self.canvas_pass
            .resize(&self.device, self.size.width, self.size.height);
        self.front_face_render_buffer = Tex::create_render_buffer(
            (self.size.width, self.size.height),
            &self.device,
            Some("Front Face Render Buffer"),
            NonZeroU32::new(State::FACE_RENDER_BUFFER_SAMPLE_COUNT).unwrap(),
            &self.front_face_render_buffer.format,
        );
        self.back_face_render_buffer = Tex::create_render_buffer(
            (self.size.width, self.size.height),
            &self.device,
            Some("Back Face Render Buffer"),
            NonZeroU32::new(State::FACE_RENDER_BUFFER_SAMPLE_COUNT).unwrap(),
            &self.back_face_render_buffer.format,
        );
        self.canvas_pass.change_bound_face_textures(
            &self.device,
            &self.front_face_render_buffer,
            &self.back_face_render_buffer,
        );
    }
fn resize ( & mut self , new_size : winit :: dpi :: PhysicalSize < u32 > ) { self . size = new_size ; self . surface_configs . width = new_size . width ; self . surface_configs . height = new_size . height ; self . camera . aspect = self . size . width as f32 / self . size . height as f32 ; self . surface . configure ( & self . device , & self . surface_configs ) ; self . front_face_pass . resize ( & self . device , self . size . width , self . size . height ) ; self . back_face_pass . resize ( & self . device , self . size . width , self . size . height ) ; self . front_face_pass . update_model_view_proj_uniform ( self . cube_scaling . clone ( ) , & self . camera , & self . queue , ) ; self . back_face_pass . update_model_view_proj_uniform ( self . cube_scaling . clone ( ) , & self . camera , & self . queue , ) ; self . canvas_pass . resize ( & self . device , self . size . width , self . size . height ) ; self . front_face_render_buffer = Tex :: create_render_buffer ( ( self . size . width , self . size . height ) , & self . device , Some ( " " ) , NonZeroU32 :: new ( State :: FACE_RENDER_BUFFER_SAMPLE_COUNT ) . unwrap ( ) , & self . front_face_render_buffer . format , ) ; self . back_face_render_buffer = Tex :: create_render_buffer ( ( self . size . width , self . size . height ) , & self . device , Some ( " " ) , NonZeroU32 :: new ( State :: FACE_RENDER_BUFFER_SAMPLE_COUNT ) . unwrap ( ) , & self . back_face_render_buffer . format , ) ; self . canvas_pass . change_bound_face_textures ( & self . device , & self . front_face_render_buffer , & self . back_face_render_buffer , ) ; }
If we want to support resizing in our application, we're going to need to recreate the swap_chain everytime the window's size changes.
If we want to support resizing in our application we ' re going to need to recreate the swap_chain everytime the window ' s size changes .
&mut self
new_size
winit::dpi::PhysicalSize<u32>
&mut self
new_size
winit::dpi::PhysicalSize<u32>