pub fn new(device: Arc<Device>) -> Result<Self> {
        let sampler = unsafe {
            use crate::graphics::ext::SamplerFactory;
            device.create_sampler(
                "default sampler",
                vk::SamplerCreateInfo {
                    mag_filter: vk::Filter::LINEAR,
                    min_filter: vk::Filter::LINEAR,
                    address_mode_u: vk::SamplerAddressMode::REPEAT,
                    address_mode_v: vk::SamplerAddressMode::REPEAT,
                    address_mode_w: vk::SamplerAddressMode::REPEAT,
                    anisotropy_enable: 0,
                    border_color: vk::BorderColor::INT_OPAQUE_BLACK,
                    unnormalized_coordinates: 0,
                    compare_enable: 0,
                    compare_op: vk::CompareOp::ALWAYS,
                    mipmap_mode: vk::SamplerMipmapMode::LINEAR,
                    mip_lod_bias: 0.0,
                    min_lod: 0.0,
                    max_lod: vk::LOD_CLAMP_NONE,
                    ..Default::default()
                },
            )?
        };

        let default_texture = unsafe {
            let mut transfer_buffer = CpuBuffer::new(
                device.clone(),
                vk::BufferUsageFlags::TRANSFER_SRC,
            )?;

            let white_pixel: [u8; 4] = [255, 255, 255, 255];
            transfer_buffer.write_data(&white_pixel)?;

            let mut tex = device.create_empty_2d_texture("default", 1, 1, 1)?;
            tex.upload_from_buffer(&transfer_buffer)?;
            tex
        };

        let mut bindings = vec![];
        bindings.reserve(MAX_SUPPORTED_TEXTURES);

        bindings.push(Some(Binding {
            texture: default_texture,
            sampler_handle: SamplerHandle::default(),
        }));

        for _ in 1..MAX_SUPPORTED_TEXTURES {
            bindings.push(None);
        }

        Ok(Self {
            textures: bindings,
            version: AtlasVersion::new_out_of_date().increment(),
            samplers: vec![sampler],
            device,
        })
    }
/// Create a new texture atlas which loads image data into GPU memory.
Create a new texture atlas which loads image data into GPU memory.
Create a new texture atlas which loads image data into GPU memory .
pub fn new(device: Arc<Device>) -> Result<Self> {
        let sampler = unsafe {
            use crate::graphics::ext::SamplerFactory;
            device.create_sampler(
                "default sampler",
                vk::SamplerCreateInfo {
                    mag_filter: vk::Filter::LINEAR,
                    min_filter: vk::Filter::LINEAR,
                    address_mode_u: vk::SamplerAddressMode::REPEAT,
                    address_mode_v: vk::SamplerAddressMode::REPEAT,
                    address_mode_w: vk::SamplerAddressMode::REPEAT,
                    anisotropy_enable: 0,
                    border_color: vk::BorderColor::INT_OPAQUE_BLACK,
                    unnormalized_coordinates: 0,
                    compare_enable: 0,
                    compare_op: vk::CompareOp::ALWAYS,
                    mipmap_mode: vk::SamplerMipmapMode::LINEAR,
                    mip_lod_bias: 0.0,
                    min_lod: 0.0,
                    max_lod: vk::LOD_CLAMP_NONE,
                    ..Default::default()
                },
            )?
        };
        let default_texture = unsafe {
            let mut transfer_buffer = CpuBuffer::new(
                device.clone(),
                vk::BufferUsageFlags::TRANSFER_SRC,
            )?;
            let white_pixel: [u8; 4] = [255, 255, 255, 255];
            transfer_buffer.write_data(&white_pixel)?;
            let mut tex = device.create_empty_2d_texture("default", 1, 1, 1)?;
            tex.upload_from_buffer(&transfer_buffer)?;
            tex
        };
        let mut bindings = vec![];
        bindings.reserve(MAX_SUPPORTED_TEXTURES);
        bindings.push(Some(Binding {
            texture: default_texture,
            sampler_handle: SamplerHandle::default(),
        }));
        for _ in 1..MAX_SUPPORTED_TEXTURES {
            bindings.push(None);
        }
        Ok(Self {
            textures: bindings,
            version: AtlasVersion::new_out_of_date().increment(),
            samplers: vec![sampler],
            device,
        })
    }
pub fn new ( device : Arc < Device > ) -> Result < Self > { let sampler = unsafe { use crate :: graphics :: ext :: SamplerFactory ; device . create_sampler ( " " , vk :: SamplerCreateInfo { mag_filter : vk :: Filter :: LINEAR , min_filter : vk :: Filter :: LINEAR , address_mode_u : vk :: SamplerAddressMode :: REPEAT , address_mode_v : vk :: SamplerAddressMode :: REPEAT , address_mode_w : vk :: SamplerAddressMode :: REPEAT , anisotropy_enable : 0 , border_color : vk :: BorderColor :: INT_OPAQUE_BLACK , unnormalized_coordinates : 0 , compare_enable : 0 , compare_op : vk :: CompareOp :: ALWAYS , mipmap_mode : vk :: SamplerMipmapMode :: LINEAR , mip_lod_bias : 0.0 , min_lod : 0.0 , max_lod : vk :: LOD_CLAMP_NONE , .. Default :: default ( ) } , ) ? } ; let default_texture = unsafe { let mut transfer_buffer = CpuBuffer :: new ( device . clone ( ) , vk :: BufferUsageFlags :: TRANSFER_SRC , ) ? ; let white_pixel : [ u8 ; 4 ] = [ 255 , 255 , 255 , 255 ] ; transfer_buffer . write_data ( & white_pixel ) ? ; let mut tex = device . create_empty_2d_texture ( " " , 1 , 1 , 1 ) ? ; tex . upload_from_buffer ( & transfer_buffer ) ? ; tex } ; let mut bindings = vec ! [ ] ; bindings . reserve ( MAX_SUPPORTED_TEXTURES ) ; bindings . push ( Some ( Binding { texture : default_texture , sampler_handle : SamplerHandle :: default ( ) , } ) ) ; for _ in 1 .. MAX_SUPPORTED_TEXTURES { bindings . push ( None ) ; } Ok ( Self { textures : bindings , version : AtlasVersion :: new_out_of_date ( ) . increment ( ) , samplers : vec ! [ sampler ] , device , } ) }
Create a new texture atlas which loads image data into GPU memory.
Create a new texture atlas which loads image data into GPU memory .
device
Arc<Device>