three_d_asset/texture/texture2d.rs
1#[doc(inline)]
2pub use super::{Interpolation, Mipmap, TextureData, Wrapping};
3
4///
5/// A CPU-side version of a 2D texture.
6///
7#[derive(Clone, Debug, PartialEq)]
8#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9pub struct Texture2D {
10 /// Name of this texture.
11 pub name: String,
12 /// The pixel data for the image
13 pub data: TextureData,
14 /// The width of the image
15 pub width: u32,
16 /// The height of the image
17 pub height: u32,
18 /// The way the pixel data is interpolated when the texture is far away
19 pub min_filter: Interpolation,
20 /// The way the pixel data is interpolated when the texture is close
21 pub mag_filter: Interpolation,
22 /// Specifies the [Mipmap] settings for this texture. If this is `None`, no mipmaps are created.
23 pub mipmap: Option<Mipmap>,
24 /// Determines how the texture is sampled outside the [0..1] s coordinate range (the first value of the uv coordinates).
25 pub wrap_s: Wrapping,
26 /// Determines how the texture is sampled outside the [0..1] t coordinate range (the second value of the uv coordinates).
27 pub wrap_t: Wrapping,
28}
29
30impl Default for Texture2D {
31 fn default() -> Self {
32 Self {
33 name: "default".to_owned(),
34 data: TextureData::RgbaU8(vec![[0, 0, 0, 0]]),
35 width: 1,
36 height: 1,
37 min_filter: Interpolation::Linear,
38 mag_filter: Interpolation::Linear,
39 mipmap: Some(Mipmap::default()),
40 wrap_s: Wrapping::Repeat,
41 wrap_t: Wrapping::Repeat,
42 }
43 }
44}