pub fn transfer<T>(
        texture: &Texture,
        t_pixels: &[T],
        rect: Rect<u32, ScreenSpace>,
        device: &Device,
    ) where
    T: bytemuck::Pod + Clone + Copy + 'static,
    {
        let destination = rect.to_box2d();
        
        // Make sure we have a positive rectangle
        let destination: Box2D<u32, ScreenSpace> = Box2D::new (
            Point2D::new(
                destination.min.x.min(destination.max.x),
                destination.min.y.min(destination.max.y)
            ),
            Point2D::new(
                destination.max.x.max(destination.min.x),
                destination.max.y.max(destination.max.y),
            )
        );
        
        // Flip y axis as wgpu has its texture y axis pointing down
        let destination: Box2D<u32, ScreenSpace> = Box2D::new(
            Point2D::new(destination.min.x, destination.max.y),
            Point2D::new(destination.max.x, destination.min.y)
        );
        
        let rect = destination.to_rect();
        
        // Width and height of transfer area
        let destination_size = rect.size;
        
        // The destination coordinate of the transfer on the texture.
        // We have to invert the y coordingate as explained above
        let destination_point = Point2D::new(
            rect.origin.x,
            texture.size.height - rect.origin.y
        );
        
        assert!(
            destination_size.area() <= texture.size.area(),
            "Fatal: transfer size must be <= to the texture size"
        );
        
        let t_pixels: &[u8] = bytemuck::cast_slice(t_pixels);
        
        let extent = wgpu::Extent3d {
            width: destination_size.width,
            height: destination_size.height,
            depth_or_array_layers: 0,
        };
        Self::copy(
            &texture,
            Rect::new(destination_point, destination_size),
            &device.queue,
            t_pixels,
            t_pixels.len() as u32 / texture.extent.height * 4 as u32,
            extent
        )
    }
/// Transfer texture pixels to a rect in a texture
Transfer texture pixels to a rect in a texture
Transfer texture pixels to a rect in a texture
pub fn transfer<T>(
        texture: &Texture,
        t_pixels: &[T],
        rect: Rect<u32, ScreenSpace>,
        device: &Device,
    ) where
    T: bytemuck::Pod + Clone + Copy + 'static,
    {
        let destination = rect.to_box2d();
        // Make sure we have a positive rectangle
        let destination: Box2D<u32, ScreenSpace> = Box2D::new (
            Point2D::new(
                destination.min.x.min(destination.max.x),
                destination.min.y.min(destination.max.y)
            ),
            Point2D::new(
                destination.max.x.max(destination.min.x),
                destination.max.y.max(destination.max.y),
            )
        );
        // Flip y axis as wgpu has its texture y axis pointing down
        let destination: Box2D<u32, ScreenSpace> = Box2D::new(
            Point2D::new(destination.min.x, destination.max.y),
            Point2D::new(destination.max.x, destination.min.y)
        );
        let rect = destination.to_rect();
        // Width and height of transfer area
        let destination_size = rect.size;
        // The destination coordinate of the transfer on the texture.
        // We have to invert the y coordingate as explained above
        let destination_point = Point2D::new(
            rect.origin.x,
            texture.size.height - rect.origin.y
        );
        assert!(
            destination_size.area() <= texture.size.area(),
            "Fatal: transfer size must be <= to the texture size"
        );
        let t_pixels: &[u8] = bytemuck::cast_slice(t_pixels);
        let extent = wgpu::Extent3d {
            width: destination_size.width,
            height: destination_size.height,
            depth_or_array_layers: 0,
        };
        Self::copy(
            &texture,
            Rect::new(destination_point, destination_size),
            &device.queue,
            t_pixels,
            t_pixels.len() as u32 / texture.extent.height * 4 as u32,
            extent
        )
    }
pub fn transfer < T > ( texture : & Texture , t_pixels : & [ T ] , rect : Rect < u32 , ScreenSpace > , device : & Device , ) where T : bytemuck :: Pod + Clone + Copy + ' static , { let destination = rect . to_box2d ( ) ; // Make sure we have a positive rectangle let destination : Box2D < u32 , ScreenSpace > = Box2D :: new ( Point2D :: new ( destination . min . x . min ( destination . max . x ) , destination . min . y . min ( destination . max . y ) ) , Point2D :: new ( destination . max . x . max ( destination . min . x ) , destination . max . y . max ( destination . max . y ) , ) ) ; // Flip y axis as wgpu has its texture y axis pointing down let destination : Box2D < u32 , ScreenSpace > = Box2D :: new ( Point2D :: new ( destination . min . x , destination . max . y ) , Point2D :: new ( destination . max . x , destination . min . y ) ) ; let rect = destination . to_rect ( ) ; // Width and height of transfer area let destination_size = rect . size ; // The destination coordinate of the transfer on the texture. // We have to invert the y coordingate as explained above let destination_point = Point2D :: new ( rect . origin . x , texture . size . height - rect . origin . y ) ; assert ! ( destination_size area ( ) texture size area ( ) " " ) ; let t_pixels : & [ u8 ] = bytemuck :: cast_slice ( t_pixels ) ; let extent = wgpu :: Extent3d { width : destination_size . width , height : destination_size . height , depth_or_array_layers : 0 , } ; Self :: copy ( & texture , Rect :: new ( destination_point , destination_size ) , & device . queue , t_pixels , t_pixels . len ( ) as u32 / texture . extent . height * 4 as u32 , extent ) }
Transfer texture pixels to a rect in a texture
Transfer texture pixels to a rect in a texture
texture
&Texture
t_pixels
&[T]
rect
Rect<u32, ScreenSpace>
device
&Device