couple tools

This commit is contained in:
Quaternions 2024-02-13 01:50:10 -08:00
parent 274cca6568
commit 6043c23c19

View File

@ -12,6 +12,13 @@ pub enum TextureLoader{
pub enum Texture{
ImageDDS(Vec<u8>),
}
impl AsRef<[u8]> for Texture{
fn as_ref(&self)->&[u8]{
match self{
Texture::ImageDDS(data)=>data.as_ref(),
}
}
}
pub struct Textures{
textures:Vec<Texture>,
@ -25,6 +32,9 @@ impl Textures{
pub fn get_texture(&self,texture_id:TextureId)->Option<&Texture>{
self.textures.get(texture_id.get() as usize)
}
pub fn into_iter(self)->impl Iterator<Item=(TextureId,Texture)>{
self.textures.into_iter().enumerate().map(|(texture_id,texture)|(TextureId::new(texture_id as u32),texture))
}
}
pub trait TextureLoaderTrait{