diff options
author | 2020-06-05 15:05:30 +0200 | |
---|---|---|
committer | 2020-06-05 15:05:30 +0200 | |
commit | fd3801ed38a5adbba11ede16f552cd80c0a8bb58 (patch) | |
tree | 61b8ad6a0c8fad3103020b7c2e6e2ab05b3e1a9e /examples/integration/src/scene.rs | |
parent | 969de1d31ce7c17f297b2b8abffd071caa562646 (diff) | |
download | iced-fd3801ed38a5adbba11ede16f552cd80c0a8bb58.tar.gz iced-fd3801ed38a5adbba11ede16f552cd80c0a8bb58.tar.bz2 iced-fd3801ed38a5adbba11ede16f552cd80c0a8bb58.zip |
Clear frames explicitly in `integration` example
Diffstat (limited to '')
-rw-r--r-- | examples/integration/src/scene.rs | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/examples/integration/src/scene.rs b/examples/integration/src/scene.rs index b79a7ff4..6c1a4581 100644 --- a/examples/integration/src/scene.rs +++ b/examples/integration/src/scene.rs @@ -16,38 +16,37 @@ impl Scene { } } - pub fn draw( + pub fn clear<'a>( &self, - encoder: &mut wgpu::CommandEncoder, - target: &wgpu::TextureView, + target: &'a wgpu::TextureView, + encoder: &'a mut wgpu::CommandEncoder, background_color: Color, - ) { - let mut rpass = - encoder.begin_render_pass(&wgpu::RenderPassDescriptor { - color_attachments: &[ - wgpu::RenderPassColorAttachmentDescriptor { - attachment: target, - resolve_target: None, - load_op: wgpu::LoadOp::Clear, - store_op: wgpu::StoreOp::Store, - clear_color: { - let [r, g, b, a] = background_color.into_linear(); + ) -> wgpu::RenderPass<'a> { + encoder.begin_render_pass(&wgpu::RenderPassDescriptor { + color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { + attachment: target, + resolve_target: None, + load_op: wgpu::LoadOp::Clear, + store_op: wgpu::StoreOp::Store, + clear_color: { + let [r, g, b, a] = background_color.into_linear(); - wgpu::Color { - r: r as f64, - g: g as f64, - b: b as f64, - a: a as f64, - } - }, - }, - ], - depth_stencil_attachment: None, - }); + wgpu::Color { + r: r as f64, + g: g as f64, + b: b as f64, + a: a as f64, + } + }, + }], + depth_stencil_attachment: None, + }) + } - rpass.set_pipeline(&self.pipeline); - rpass.set_bind_group(0, &self.bind_group, &[]); - rpass.draw(0..3, 0..1); + pub fn draw<'a>(&'a self, render_pass: &mut wgpu::RenderPass<'a>) { + render_pass.set_pipeline(&self.pipeline); + render_pass.set_bind_group(0, &self.bind_group, &[]); + render_pass.draw(0..3, 0..1); } } |