mraphics_core/material/
material.rs

1use crate::render::GadgetData;
2
3pub struct MaterialView {
4    pub identifier: String,
5    pub shader_code: String,
6
7    pub uniforms: Vec<GadgetData>,
8    pub attributes: Vec<GadgetData>,
9}
10
11impl MaterialView {
12    pub fn new(identifier: &str) -> Self {
13        Self {
14            identifier: identifier.to_string(),
15            shader_code: String::new(),
16            uniforms: Vec::new(),
17            attributes: Vec::new(),
18        }
19    }
20
21    pub fn with_code(mut self, code: String) -> Self {
22        self.shader_code = code;
23        self
24    }
25
26    pub fn with_uniforms(mut self, uniforms: Vec<GadgetData>) -> Self {
27        self.uniforms = uniforms;
28        self
29    }
30
31    pub fn with_attributes(mut self, attributes: Vec<GadgetData>) -> Self {
32        self.attributes = attributes;
33        self
34    }
35
36    pub fn reset(&mut self) {
37        self.uniforms = Vec::new();
38        self.attributes = Vec::new();
39    }
40}
41
42pub trait Material {
43    fn identifier(&self) -> &str;
44    fn shader_code(&self) -> &str;
45    fn update_view(&self, view: &mut MaterialView);
46}