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