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
use core::*;
#[must_use]
#[derive(Clone)]
pub struct TextureBuilder<'a> {
info : TextureInfo<'a>,
context : &'a RenderContext,
}
impl<'a> TextureBuilder<'a> {
pub fn width(mut self: Self, width: u32) -> Self {
self.info.width = width;
self
}
pub fn height(mut self: Self, height: u32) -> Self {
self.info.height = height;
self
}
pub fn dimensions<T>(mut self: Self, dimensions: T) -> Self where Point2<u32>: From<T> {
let dimensions = Point2::<u32>::from(dimensions);
self.info.width = dimensions.0;
self.info.height = dimensions.1;
self
}
pub fn minify(mut self: Self, minify: TextureFilter) -> Self {
self.info.minify = minify;
self
}
pub fn magnify(mut self: Self, magnify: TextureFilter) -> Self {
self.info.magnify = magnify;
self
}
pub fn wrap(mut self: Self, wrap: TextureWrap) -> Self {
self.info.wrap = wrap;
self
}
pub fn format(mut self: Self, format: TextureFormat) -> Self {
self.info.format = format;
self
}
pub fn file(mut self: Self, file: &'a str) -> Self {
self.info.file = Some(file);
self
}
pub fn build(self: Self) -> Result<Texture> {
Texture::from_info(self.context, self.info)
}
pub(crate) fn new<'b>(context: &'b RenderContext) -> TextureBuilder {
TextureBuilder {
context : context,
info : TextureInfo { ..TextureInfo::default() },
}
}
}