material constructor

This commit is contained in:
Carter Anderson 2019-12-02 11:05:35 -08:00
parent 6b937d5df4
commit df5c74a0ea
2 changed files with 13 additions and 3 deletions

View file

@ -17,19 +17,19 @@ fn main() {
world.insert((), vec![
(
Material { color: math::vec4(0.1, 0.2, 0.1, 1.0), bind_group: None, uniform_buf: None },
Material::new(math::vec4(0.1, 0.2, 0.1, 1.0)),
plane_handle.clone(),
LocalToWorld(math::translation(&math::vec3(0.0, 0.0, 0.0))),
Translation::new(0.0, 0.0, 0.0)
),
(
Material { color: math::vec4(0.1, 0.1, 0.6, 1.0), bind_group: None, uniform_buf: None },
Material::new(math::vec4(0.1, 0.1, 0.6, 1.0)),
mesh_handle.clone(),
LocalToWorld(math::translation(&math::vec3(1.5, 0.0, 1.0))),
Translation::new(0.0, 0.0, 0.0)
),
(
Material { color: math::vec4(0.6, 0.1, 0.1, 1.0), bind_group: None, uniform_buf: None },
Material::new(math::vec4(0.6, 0.1, 0.1, 1.0)),
mesh_handle,
LocalToWorld(math::translation(&math::vec3(-1.5, 0.0, 1.0))),
Translation::new(0.0, 0.0, 0.0)

View file

@ -7,6 +7,16 @@ pub struct Material {
pub uniform_buf: Option<wgpu::Buffer>,
}
impl Material {
pub fn new(color: math::Vec4) -> Self {
Material {
color,
bind_group: None,
uniform_buf: None,
}
}
}
#[repr(C)]
#[derive(Clone, Copy, AsBytes, FromBytes)]
pub struct RenderedUniforms {