summaryrefslogtreecommitdiff
path: root/engine/src/texture.rs
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src/texture.rs')
-rw-r--r--engine/src/texture.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/engine/src/texture.rs b/engine/src/texture.rs
index 2d7ba51..b0f0278 100644
--- a/engine/src/texture.rs
+++ b/engine/src/texture.rs
@@ -1,5 +1,8 @@
+use std::collections::HashMap;
+use std::fmt::Display;
use std::path::Path;
+use ecs::Component;
use image::io::Reader as ImageReader;
use image::{DynamicImage, ImageError, Rgb, RgbImage};
@@ -74,6 +77,7 @@ impl Texture
}
}
+ #[must_use]
pub fn properties(&self) -> &Properties
{
&self.properties
@@ -84,16 +88,19 @@ impl Texture
&mut self.properties
}
+ #[must_use]
pub fn dimensions(&self) -> &Vec2<u32>
{
&self.dimensions
}
+ #[must_use]
pub fn pixel_data_format(&self) -> PixelDataFormat
{
self.pixel_data_format
}
+ #[must_use]
pub fn image(&self) -> &DynamicImage
{
&self.image
@@ -157,3 +164,28 @@ impl Id
self.id
}
}
+
+impl Display for Id
+{
+ fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result
+ {
+ self.id.fmt(formatter)
+ }
+}
+
+/// Texture map.
+#[derive(Component)]
+pub struct Map
+{
+ pub inner: HashMap<Id, Texture>,
+}
+
+impl FromIterator<(Id, Texture)> for Map
+{
+ fn from_iter<Iter>(iter: Iter) -> Self
+ where
+ Iter: IntoIterator<Item = (Id, Texture)>,
+ {
+ Self { inner: iter.into_iter().collect() }
+ }
+}