diff options
author | tcmal <me@aria.rip> | 2024-08-25 17:44:22 +0100 |
---|---|---|
committer | tcmal <me@aria.rip> | 2024-08-25 17:44:22 +0100 |
commit | bf9573764c695e65b1504419fafb76ccabb0322b (patch) | |
tree | 1702411472e080b436d27f34655ae4ada68ecc7b /stockton-render/src/draw/texture/resolver.rs | |
parent | dfb74318dae09b3430acf533374dc7004df65c65 (diff) |
feat(render): generic and empty texture stores
Diffstat (limited to 'stockton-render/src/draw/texture/resolver.rs')
-rw-r--r-- | stockton-render/src/draw/texture/resolver.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/stockton-render/src/draw/texture/resolver.rs b/stockton-render/src/draw/texture/resolver.rs index 21e7628..610d43a 100644 --- a/stockton-render/src/draw/texture/resolver.rs +++ b/stockton-render/src/draw/texture/resolver.rs @@ -17,6 +17,7 @@ //! Resolves a texture in a BSP File to an image +use crate::draw::texture::image::LoadableImage; use stockton_levels::traits::textures::Texture; use image::{io::Reader, RgbaImage}; @@ -24,9 +25,10 @@ use image::{io::Reader, RgbaImage}; use std::path::Path; /// An object that can be used to resolve a texture from a BSP File -pub trait TextureResolver { +pub trait TextureResolver<T: LoadableImage> { + /// Get the given texture, or None if it's corrupt/not there. - fn resolve(&mut self, texture: &Texture) -> Option<RgbaImage>; + fn resolve(&mut self, texture: &Texture) -> Option<T>; } /// A basic filesystem resolver which expects no file extension and guesses the image format @@ -40,7 +42,7 @@ impl<'a> BasicFSResolver<'a> { } } -impl<'a> TextureResolver for BasicFSResolver<'a> { +impl<'a> TextureResolver<RgbaImage> for BasicFSResolver<'a> { fn resolve(&mut self, tex: &Texture) -> Option<RgbaImage> { let path = self.path.join(&tex.name); |