~ma3ke/laurel

9440237266392bcfa2f9436f23313731b3b2c199 — Marieke Westendorp 10 months ago a356c25
Unify clear_color setting for Pixels and Screen
2 files changed, 8 insertions(+), 3 deletions(-)

M src/main.rs
M src/screen.rs
M src/main.rs => src/main.rs +6 -1
@@ 68,15 68,20 @@ fn main() -> Result<(), pixels::Error> {
        .build(&event_loop)
        .unwrap();

    let background = colors::BLACK;
    let pixels = {
        let PhysicalSize { width, height } = window.inner_size();
        let surface_texture = SurfaceTexture::new(width, height, &window);
        PixelsBuilder::new(width, height, surface_texture)
            .clear_color({
                let [r, g, b, a] = background.map(|v| v as f64 / u8::MAX as f64);
                pixels::wgpu::Color { r, g, b, a }
            })
            .present_mode(pixels::wgpu::PresentMode::AutoVsync)
            .blend_state(pixels::wgpu::BlendState::ALPHA_BLENDING)
            .build()?
    };
    let mut screen = Screen::new(pixels);
    let mut screen = Screen::new(pixels, background);

    event_loop.run(move |event, _, control_flow| {
        *control_flow = ControlFlow::Wait;

M src/screen.rs => src/screen.rs +2 -2
@@ 11,10 11,10 @@ pub struct Screen {
}

impl Screen {
    pub fn new(pixels: Pixels) -> Self {
    pub fn new(pixels: Pixels, clear_color: Pixel) -> Self {
        Self {
            pixels,
            clear_color: [0x00; PIXEL_SIZE],
            clear_color,
            old_list: Vec::new(),
        }
    }