use super::texture::{Mipmap, Texture};
use super::{MinFilter, TextureFilter};
impl Texture {
pub fn compressed(
mipmaps: Vec<Mipmap>,
width: u32,
height: u32,
format: wgpu::TextureFormat,
) -> Self {
assert!(
!mipmaps.is_empty(),
"three-rs: a CompressedTexture needs at least one mip level"
);
let texture = Texture::new(width, height, None);
{
let mut inner = texture.borrow_mut_inner();
inner.flip_y = false;
inner.generate_mipmaps = false;
inner.format = format;
inner.mipmaps = mipmaps;
}
texture
}
pub fn compressed_array(
mipmaps: Vec<Mipmap>,
width: u32,
height: u32,
depth: u32,
format: wgpu::TextureFormat,
) -> Self {
assert!(
depth >= 1,
"three-rs: a CompressedArrayTexture has at least one layer"
);
let texture = Texture::compressed(mipmaps, width, height, format);
texture.borrow_mut_inner().depth = depth;
texture
}
pub fn set_filters(&self, min_filter: MinFilter, mag_filter: TextureFilter) {
let mut inner = self.borrow_mut_inner();
inner.min_filter = min_filter;
inner.mag_filter = mag_filter;
}
pub fn set_premultiply_alpha(&self, premultiply_alpha: bool) {
self.borrow_mut_inner().premultiply_alpha = premultiply_alpha;
}
pub fn is_array(&self) -> bool {
self.borrow().depth > 0
}
}