baryon 0.3.0

Fast prototyping 3D engine
Documentation
use bc::ContextDetail as _;

#[derive(Default)]
pub struct Clear;

impl bc::Pass for Clear {
    fn draw(
        &mut self,
        targets: &[crate::TargetRef],
        _scene: &crate::Scene,
        camera: &crate::Camera,
        context: &crate::Context,
    ) {
        let target = context.get_target(targets[0]);
        let mut encoder = context
            .device()
            .create_command_encoder(&wgpu::CommandEncoderDescriptor::default());

        {
            let _pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
                label: Some("clear"),
                color_attachments: &[wgpu::RenderPassColorAttachment {
                    view: &target.view,
                    resolve_target: None,
                    ops: wgpu::Operations {
                        load: wgpu::LoadOp::Clear(camera.background.into()),
                        store: true,
                    },
                }],
                depth_stencil_attachment: None,
            });
        }

        context.queue().submit(Some(encoder.finish()));
    }
}