use crate::asset::Handle as AssetHandle; use crate::image::Image; use crate::util::builder; mod reexports { pub use crate::opengl::texture::{Filtering, Wrapping}; } pub use reexports::*; #[derive(Debug, Clone)] #[non_exhaustive] pub struct Texture { pub asset_handle: AssetHandle, pub properties: Properties, } impl Texture { pub fn new(asset_handle: AssetHandle) -> Self { Self { asset_handle, properties: Properties::default(), } } pub fn with_properties( asset_handle: AssetHandle, properties: Properties, ) -> Self { Self { asset_handle, properties } } } builder! { /// Texture properties #[builder(name = PropertiesBuilder, derives=(Debug, Clone))] #[derive(Debug, Clone)] #[non_exhaustive] pub struct Properties { pub wrap: Wrapping, pub magnifying_filter: Filtering, pub minifying_filter: Filtering, } } impl Properties { pub fn builder() -> PropertiesBuilder { PropertiesBuilder::default() } } impl Default for Properties { fn default() -> Self { Self { wrap: Wrapping::Repeat, magnifying_filter: Filtering::Linear, minifying_filter: Filtering::Nearest, } } } impl Default for PropertiesBuilder { fn default() -> Self { Properties::default().into() } }