Skip to content

Commit

Permalink
Merge pull request #74 from AryanpurTech/More-Setter-Functions
Browse files Browse the repository at this point in the history
More Setter Functions
  • Loading branch information
ElhamAryanpur authored Aug 12, 2024
2 parents 13c86e4 + 1913327 commit a08f574
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ===========================
Expand Down

0 comments on commit a08f574

Please sign in to comment.