paddle/display/gpu/shader/
custom_shader.rs

1use crate::{quicksilver_compat::Color, AbstractVertex, Image, Paint, RenderPipelineHandle};
2
3pub struct CustomShader {
4    pipe: RenderPipelineHandle,
5    color: Option<Color>,
6    image: Option<Image>,
7}
8
9impl CustomShader {
10    pub fn new(pipe: RenderPipelineHandle) -> Self {
11        Self {
12            pipe,
13            color: None,
14            image: None,
15        }
16    }
17    pub fn with_color(mut self, color: Color) -> Self {
18        self.color = Some(color);
19        self
20    }
21    pub fn with_image(mut self, image: Image) -> Self {
22        self.image = Some(image);
23        self
24    }
25}
26
27impl Paint for CustomShader {
28    fn extra_vertex_attributes(&self, _index: usize, _vertex: &AbstractVertex) -> Option<Vec<f32>> {
29        None
30        // TODO?
31    }
32    fn render_pipeline(&self) -> RenderPipelineHandle {
33        self.pipe
34    }
35
36    fn image(&self) -> Option<&Image> {
37        self.image.as_ref()
38    }
39
40    fn color(&self) -> Option<Color> {
41        self.color
42    }
43}