couple tools
This commit is contained in:
parent
274cca6568
commit
6043c23c19
@ -12,6 +12,13 @@ pub enum TextureLoader{
|
|||||||
pub enum Texture{
|
pub enum Texture{
|
||||||
ImageDDS(Vec<u8>),
|
ImageDDS(Vec<u8>),
|
||||||
}
|
}
|
||||||
|
impl AsRef<[u8]> for Texture{
|
||||||
|
fn as_ref(&self)->&[u8]{
|
||||||
|
match self{
|
||||||
|
Texture::ImageDDS(data)=>data.as_ref(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct Textures{
|
pub struct Textures{
|
||||||
textures:Vec<Texture>,
|
textures:Vec<Texture>,
|
||||||
@ -25,6 +32,9 @@ impl Textures{
|
|||||||
pub fn get_texture(&self,texture_id:TextureId)->Option<&Texture>{
|
pub fn get_texture(&self,texture_id:TextureId)->Option<&Texture>{
|
||||||
self.textures.get(texture_id.get() as usize)
|
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{
|
pub trait TextureLoaderTrait{
|
||||||
|
Loading…
Reference in New Issue
Block a user