From 191332702b9c5cd52ccdc261acb7c9ce47dd8dda Mon Sep 17 00:00:00 2001 From: Elham Aryanpur Date: Mon, 12 Aug 2024 21:27:19 +0300 Subject: [PATCH] feat: more sane setter functions --- src/objects.rs | 16 +++++++++++----- src/render.rs | 5 +++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/objects.rs b/src/objects.rs index e35b3d0..8de5c7c 100644 --- a/src/objects.rs +++ b/src/objects.rs @@ -321,13 +321,13 @@ impl Object { /// This will flag object as changed and altered, leading to rebuilding parts, or entirety on next frame. /// Best used if you directly altered fields of the object. The functions normally flag the object as /// changed on every call anyways. But this function is to manually flag it yourself. - pub fn flag_as_changed(&mut self) { - self.changed = true; + pub fn flag_as_changed(&mut self, is_changed: bool) { + self.changed = is_changed; } - /// same as flag_as_changed, but inverse - pub fn flag_as_unchanged(&mut self) { - self.changed = false; + /// Sets if the object will be rendered or not + pub fn set_visibility(&mut self, is_visible: bool) { + self.is_visible = is_visible; } /// build an inverse of the transformation matrix to be sent to the gpu for lighting and other things. @@ -571,6 +571,12 @@ impl ShaderBuilder { shader_builder } + /// Sets the new shader + pub fn set_shader(&mut self, new_shader: String) { + self.shader = new_shader; + self.build(); + } + /// Builds the shader with the configuration defined pub fn build(&mut self) { for i in &self.configs { diff --git a/src/render.rs b/src/render.rs index 4dea6c3..128ce24 100644 --- a/src/render.rs +++ b/src/render.rs @@ -334,6 +334,11 @@ impl Renderer { Ok(()) } + + /// Sets the background color + pub fn set_clear_color(&mut self, r: f64, g: f64, b: f64, a: f64) { + self.clear_color = wgpu::Color { r, g, b, a } + } } // =========================== Extract Pipeline Data ===========================