[oden] Garbage assets, need to rewrite to IO

This commit is contained in:
John Doty 2023-06-27 17:16:37 -07:00
parent 75fcc427ac
commit 17805fa4a6
17 changed files with 240 additions and 94 deletions

View file

@ -1,4 +1,3 @@
use anyhow::*;
use image::GenericImageView;
pub struct Texture {
@ -8,22 +7,22 @@ pub struct Texture {
}
impl Texture {
pub fn from_bytes(
device: &wgpu::Device,
queue: &wgpu::Queue,
bytes: &[u8],
label: &str,
) -> Result<Self> {
let img = image::load_from_memory(bytes)?;
Self::from_image(device, queue, &img, Some(label))
}
// pub fn from_bytes(
// device: &wgpu::Device,
// queue: &wgpu::Queue,
// bytes: &[u8],
// label: &str,
// ) -> Result<Self> {
// let img = image::load_from_memory(bytes)?;
// Ok(Self::from_image(device, queue, &img, Some(label)))
// }
pub fn from_image(
device: &wgpu::Device,
queue: &wgpu::Queue,
img: &image::DynamicImage,
label: Option<&str>,
) -> Result<Self> {
) -> Self {
let rgba = img.to_rgba8();
let dimensions = img.dimensions();
@ -70,10 +69,10 @@ impl Texture {
..Default::default()
});
Ok(Self {
Self {
texture,
view,
sampler,
})
}
}
}