From df5c74a0eabb490bbe8c34da95394e4ae3c71be2 Mon Sep 17 00:00:00 2001 From: Carter Anderson Date: Mon, 2 Dec 2019 11:05:35 -0800 Subject: [PATCH] material constructor --- examples/simple.rs | 6 +++--- src/render/material.rs | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/examples/simple.rs b/examples/simple.rs index 42c228b4b7..72888c9bcc 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -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) diff --git a/src/render/material.rs b/src/render/material.rs index 005460aebf..66a4ce075e 100644 --- a/src/render/material.rs +++ b/src/render/material.rs @@ -7,6 +7,16 @@ pub struct Material { pub uniform_buf: Option, } +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 {