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
74
75
76
77
78
79
80
|
use ecs::pair::{ChildOf, Pair};
use ecs::phase::{Phase, POST_UPDATE as POST_UPDATE_PHASE};
use ecs::{declare_entity, Component};
use crate::builder;
pub mod opengl;
declare_entity!(
pub RENDER_PHASE,
(
Phase,
Pair::builder()
.relation::<ChildOf>()
.target_id(*POST_UPDATE_PHASE)
.build()
)
);
builder! {
/// Window graphics properties.
#[builder(name=GraphicsPropertiesBuilder, derives=(Debug, Clone))]
#[derive(Debug, Clone, Component)]
#[non_exhaustive]
pub struct GraphicsProperties
{
/// Number of samples for multisampling. `None` means no multisampling.
#[builder(skip_generate_fn)]
pub multisampling_sample_cnt: Option<u8>,
/// Whether graphics API debugging is enabled.
pub debug: bool,
/// Whether depth testing is enabled
pub depth_test: bool,
}
}
impl GraphicsProperties
{
pub fn builder() -> GraphicsPropertiesBuilder
{
GraphicsPropertiesBuilder::default()
}
}
impl Default for GraphicsProperties
{
fn default() -> Self
{
Self::builder().build()
}
}
impl GraphicsPropertiesBuilder
{
pub fn multisampling_sample_cnt(mut self, multisampling_sample_cnt: u8) -> Self
{
self.multisampling_sample_cnt = Some(multisampling_sample_cnt);
self
}
pub fn no_multisampling(mut self) -> Self
{
self.multisampling_sample_cnt = None;
self
}
}
impl Default for GraphicsPropertiesBuilder
{
fn default() -> Self
{
Self {
multisampling_sample_cnt: Some(8),
debug: false,
depth_test: true,
}
}
}
|