render: make ClearColor a tuple struct

This commit is contained in:
Carter Anderson 2020-06-26 21:39:30 -07:00
parent a4afa4e7f3
commit 1e614e41f1
3 changed files with 4 additions and 17 deletions

View file

@ -19,25 +19,12 @@ impl TextureAttachment {
}
#[derive(Clone, Debug)]
pub struct ClearColor {
pub color: Color,
}
impl ClearColor {
pub fn new(color: Color) -> Self {
ClearColor {
color,
}
}
}
pub struct ClearColor(pub Color);
impl Default for ClearColor {
fn default() -> Self {
Self {
color: Color::rgb(0.1, 0.1, 0.1),
}
Self(Color::rgb(0.1, 0.1, 0.1))
}
}
#[derive(Debug, Clone)]

View file

@ -111,7 +111,7 @@ impl Node for PassNode {
for (i, color_attachment) in self.descriptor.color_attachments.iter_mut().enumerate() {
if self.default_clear_color_inputs.contains(&i) {
if let Some(default_clear_color) = resources.get::<ClearColor>() {
color_attachment.clear_color = default_clear_color.color;
color_attachment.clear_color = default_clear_color.0;
}
}
if let Some(input_index) = self.color_attachment_input_indices[i] {

View file

@ -2,7 +2,7 @@ use bevy::prelude::*;
fn main() {
App::build()
.add_resource(ClearColor::new(Color::rgb(0.2, 0.2, 0.8)))
.add_resource(ClearColor(Color::rgb(0.2, 0.2, 0.8)))
.add_default_plugins()
.run();
}