pub fn request_texture<P: AsRef<Path>>(&self, path: P) -> Texture {
        let mut state = self.state();

        if let Some(texture) = state.find_texture(path.as_ref()) {
            return texture;
        }

        let texture = Texture::new(ResourceState::new_pending(path.as_ref().to_owned()));
        state.textures.push(TimedEntry {
            value: texture.clone(),
            time_to_live: DEFAULT_RESOURCE_LIFETIME,
        });
        let result = texture.clone();
        let options = state.textures_import_options.clone();
        let path = path.as_ref().to_owned();
        let upload_sender = state
            .upload_sender
            .as_ref()
            .expect("Upload sender must be set!")
            .clone();

        #[cfg(target_arch = "wasm32")]
        crate::core::wasm_bindgen_futures::spawn_local(async move {
            load_texture(texture, path, options, upload_sender).await;
        });

        #[cfg(not(target_arch = "wasm32"))]
        state.thread_pool.spawn_ok(async move {
            load_texture(texture, path, options, upload_sender).await;
        });

        result
    }
/// Tries to load texture from given path or get instance of existing, if any. This method is asynchronous,
/// it immediately returns a texture which can be shared across multiple places, the loading may fail, but it is
/// internal state of the texture. The engine does not care if texture failed to load, it just won't use
/// such texture during the rendering. If you need to access internals of the texture you have to get state first
/// and then use pattern matching to get TextureData which contains actual texture data.
///
/// # Async/.await
///
/// Each Texture implements Future trait and can be used in async contexts.
///
/// # Supported formats
///
/// To load images and decode them, rg3d uses image create which supports following image
/// formats: png, tga, bmp, dds, jpg, gif, tiff, dxt.
Tries to load texture from given path or get instance of existing, if any. This method is asynchronous,
it immediately returns a texture which can be shared across multiple places, the loading may fail, but it is
internal state of the texture. The engine does not care if texture failed to load, it just won't use
such texture during the rendering. If you need to access internals of the texture you have to get state first
and then use pattern matching to get TextureData which contains actual texture data.
Tries to load texture from given path or get instance of existing if any . This method is asynchronous it immediately returns a texture which can be shared across multiple places the loading may fail but it is internal state of the texture . The engine does not care if texture failed to load it just won ' t use such texture during the rendering . If you need to access internals of the texture you have to get state first and then use pattern matching to get TextureData which contains actual texture data .
pub fn request_texture<P: AsRef<Path>>(&self, path: P) -> Texture {
        let mut state = self.state();
        if let Some(texture) = state.find_texture(path.as_ref()) {
            return texture;
        }
        let texture = Texture::new(ResourceState::new_pending(path.as_ref().to_owned()));
        state.textures.push(TimedEntry {
            value: texture.clone(),
            time_to_live: DEFAULT_RESOURCE_LIFETIME,
        });
        let result = texture.clone();
        let options = state.textures_import_options.clone();
        let path = path.as_ref().to_owned();
        let upload_sender = state
            .upload_sender
            .as_ref()
            .expect("Upload sender must be set!")
            .clone();
        #[cfg(target_arch = "wasm32")]
        crate::core::wasm_bindgen_futures::spawn_local(async move {
            load_texture(texture, path, options, upload_sender).await;
        });
        #[cfg(not(target_arch = "wasm32"))]
        state.thread_pool.spawn_ok(async move {
            load_texture(texture, path, options, upload_sender).await;
        });
        result
    }
pub fn request_texture < P : AsRef < Path > > ( & self , path : P ) -> Texture { let mut state = self . state ( ) ; if let Some ( texture ) = state . find_texture ( path . as_ref ( ) ) { return texture ; } let texture = Texture :: new ( ResourceState :: new_pending ( path . as_ref ( ) . to_owned ( ) ) ) ; state . textures . push ( TimedEntry { value : texture . clone ( ) , time_to_live : DEFAULT_RESOURCE_LIFETIME , } ) ; let result = texture . clone ( ) ; let options = state . textures_import_options . clone ( ) ; let path = path . as_ref ( ) . to_owned ( ) ; let upload_sender = state . upload_sender . as_ref ( ) . expect ( " " ) . clone ( ) ; # [ cfg ( target_arch " " ) ] crate :: core :: wasm_bindgen_futures :: spawn_local ( async move { load_texture ( texture , path , options , upload_sender ) . await ; } ) ; # [ cfg ( not ( target_arch " " ) ) ] state . thread_pool . spawn_ok ( async move { load_texture ( texture , path , options , upload_sender ) . await ; } ) ; result }
Tries to load texture from given path or get instance of existing, if any.
Tries to load texture from given path or get instance of existing if any .
&self
path
P
async/.await
Each Texture implements Future trait and can be used in async contexts.
Each Texture implements Future trait and can be used in async contexts .
supported formats
To load images and decode them, rg3d uses image create which supports following image
formats: png, tga, bmp, dds, jpg, gif, tiff, dxt.
To load images and decode them rg3d uses image create which supports following image formats : png tga bmp dds jpg gif tiff dxt .