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
use crate::{
assets::Shader,
id::Id,
renderer::{ Bindings, Options, Renderer, ScissorsRect },
};
/// Rendering control component
#[derive(Default)]
pub struct Pipeline {
/// [`Id`] of the shader
pub shader: Id<Shader>,
/// Rendering bindings
pub bindings: Bindings,
/// rendering cycle
pub cycle: usize,
/// is rendering disabled
pub disabled: bool,
/// Pipeline Options
pub options: Options,
}
impl Pipeline {
/// Checks if rendering cycle should be performed
pub fn cycle(&self, renderer: &Renderer) -> bool {
!self.disabled && self.cycle != renderer.cycle() && !self.shader.is_null()
}
/// Returns true if Pipeline is ready to run
pub fn ready(&self) -> bool {
self.bindings.loaded()
}
/// Adds scissors rectangle for rendering
pub fn with_scissors_rect(
mut self,
clip_min_x: u32,
clip_min_y: u32,
width: u32,
height: u32,
) -> Self {
self.options.scissors_rect = Some (
ScissorsRect {
clip_min_x,
clip_min_y,
width,
height,
}
);
self
}
}