Skip to main content

rotex_types/
frame.rs

1#[derive(Debug, Clone)]
2pub struct PassDescriptor {
3    pub name: String,
4    pub clear_color: [f32; 4],
5    pub clear_depth: Option<f32>,
6    pub instance_indices: Vec<usize>,
7}
8
9impl PassDescriptor {
10    pub fn new(name: impl Into<String>) -> Self {
11        Self {
12            name: name.into(),
13            clear_color: [0.04, 0.05, 0.08, 1.0],
14            clear_depth: None,
15            instance_indices: Vec::new(),
16        }
17    }
18
19    pub fn with_clear_color(mut self, clear_color: [f32; 4]) -> Self {
20        self.clear_color = clear_color;
21        self
22    }
23
24    pub fn with_clear_depth(mut self, clear_depth: Option<f32>) -> Self {
25        self.clear_depth = clear_depth;
26        self
27    }
28
29    pub fn with_instance_indices(mut self, instance_indices: Vec<usize>) -> Self {
30        self.instance_indices = instance_indices;
31        self
32    }
33}
34
35#[derive(Debug, Clone)]
36pub struct FrameDescriptor {
37    pub passes: Vec<PassDescriptor>,
38}
39
40impl FrameDescriptor {
41    pub fn new(passes: Vec<PassDescriptor>) -> Self {
42        Self { passes }
43    }
44
45    pub fn single_pass(clear_color: [f32; 4], clear_depth: Option<f32>) -> Self {
46        Self {
47            passes: vec![
48                PassDescriptor::new("main")
49                    .with_clear_color(clear_color)
50                    .with_clear_depth(clear_depth),
51            ],
52        }
53    }
54}