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
72
73
#[cfg(feature = "serde")]
use serde::{Deserialize, Deserializer, Serialize, Serializer};
#[derive(Clone, Debug, Copy)]
pub struct GLContextAttributes {
pub alpha: bool,
pub depth: bool,
pub stencil: bool,
pub antialias: bool,
pub premultiplied_alpha: bool,
pub preserve_drawing_buffer: bool,
}
#[cfg(feature = "serde")]
impl Deserialize for GLContextAttributes {
fn deserialize<D>(deserializer: &mut D) -> Result<Self, D::Error>
where D: Deserializer
{
let values = try!(<[_; 6]>::deserialize(deserializer));
Ok(GLContextAttributes {
alpha: values[0],
depth: values[1],
stencil: values[2],
antialias: values[3],
premultiplied_alpha: values[4],
preserve_drawing_buffer: values[5],
})
}
}
#[cfg(feature = "serde")]
impl Serialize for GLContextAttributes {
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
where S: Serializer
{
let values = [
self.alpha, self.depth, self.stencil,
self.antialias, self.premultiplied_alpha, self.preserve_drawing_buffer,
];
values.serialize(serializer)
}
}
impl GLContextAttributes {
pub fn any() -> GLContextAttributes {
GLContextAttributes {
alpha: false,
depth: false,
stencil: false,
antialias: false,
premultiplied_alpha: false,
preserve_drawing_buffer: false,
}
}
}
impl Default for GLContextAttributes {
fn default() -> GLContextAttributes {
GLContextAttributes {
alpha: true,
depth: true,
stencil: false,
antialias: false,
premultiplied_alpha: true,
preserve_drawing_buffer: false
}
}
}