1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
pub enum Interpolation {
Nearest,
Linear
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
pub enum Wrapping {
Repeat,
MirroredRepeat,
ClampToEdge
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
pub enum Format {
R8,
R32F,
RGB8,
RGB32F,
SRGB8,
RGBA8,
SRGBA8,
RGBA32F
}
pub struct CPUTexture<T> {
pub data: Vec<T>,
pub width: usize,
pub height: usize,
pub depth: usize,
pub format: Format,
pub min_filter: Interpolation,
pub mag_filter: Interpolation,
pub mip_map_filter: Option<Interpolation>,
pub wrap_s: Wrapping,
pub wrap_t: Wrapping,
pub wrap_r: Wrapping
}
impl Default for CPUTexture<u8> {
fn default() -> Self {
Self {
data: [255u8, 255, 0, 255].into(),
width: 1,
height: 1,
depth: 1,
format: Format::RGBA8,
min_filter: Interpolation::Linear,
mag_filter: Interpolation::Linear,
mip_map_filter: Some(Interpolation::Linear),
wrap_s: Wrapping::Repeat,
wrap_t: Wrapping::Repeat,
wrap_r: Wrapping::Repeat
}
}
}