From 969de1d31ce7c17f297b2b8abffd071caa562646 Mon Sep 17 00:00:00 2001 From: hatoo Date: Wed, 3 Jun 2020 22:01:28 +0900 Subject: Add a comment of how to clear the display to `integration` example --- examples/integration/src/main.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'examples') diff --git a/examples/integration/src/main.rs b/examples/integration/src/main.rs index 6b4aa968..2206d906 100644 --- a/examples/integration/src/main.rs +++ b/examples/integration/src/main.rs @@ -163,6 +163,29 @@ pub fn main() { program.background_color(), ); + // If you are using this example and you have no `scene` on your application, + // you can clear screen by this code. + /* + let _ = + encoder.begin_render_pass(&wgpu::RenderPassDescriptor { + color_attachments: &[ + wgpu::RenderPassColorAttachmentDescriptor { + attachment: &frame.view, + resolve_target: None, + load_op: wgpu::LoadOp::Clear, + store_op: wgpu::StoreOp::Store, + clear_color: wgpu::Color { + r: 1.0, + g: 1.0, + b: 1.0, + a: 1.0, + }, + }, + ], + depth_stencil_attachment: None, + }); + */ + // And then iced on top let mouse_interaction = renderer.backend_mut().draw( &mut device, -- cgit From fd3801ed38a5adbba11ede16f552cd80c0a8bb58 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 5 Jun 2020 15:05:30 +0200 Subject: Clear frames explicitly in `integration` example --- examples/integration/src/main.rs | 38 +++++++-------------------- examples/integration/src/scene.rs | 55 +++++++++++++++++++-------------------- 2 files changed, 37 insertions(+), 56 deletions(-) (limited to 'examples') diff --git a/examples/integration/src/main.rs b/examples/integration/src/main.rs index 2206d906..db8b4366 100644 --- a/examples/integration/src/main.rs +++ b/examples/integration/src/main.rs @@ -154,37 +154,19 @@ pub fn main() { &wgpu::CommandEncoderDescriptor { label: None }, ); - // We draw the scene first let program = state.program(); - scene.draw( - &mut encoder, - &frame.view, - program.background_color(), - ); + { + // We clear the frame + let mut render_pass = scene.clear( + &frame.view, + &mut encoder, + program.background_color(), + ); - // If you are using this example and you have no `scene` on your application, - // you can clear screen by this code. - /* - let _ = - encoder.begin_render_pass(&wgpu::RenderPassDescriptor { - color_attachments: &[ - wgpu::RenderPassColorAttachmentDescriptor { - attachment: &frame.view, - resolve_target: None, - load_op: wgpu::LoadOp::Clear, - store_op: wgpu::StoreOp::Store, - clear_color: wgpu::Color { - r: 1.0, - g: 1.0, - b: 1.0, - a: 1.0, - }, - }, - ], - depth_stencil_attachment: None, - }); - */ + // Draw the scene + scene.draw(&mut render_pass); + } // And then iced on top let mouse_interaction = renderer.backend_mut().draw( 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); } } -- cgit From 40750d9b36286056508e340ad14ac77c432366ee Mon Sep 17 00:00:00 2001 From: Richard <30560559+derezzedex@users.noreply.github.com> Date: Mon, 8 Jun 2020 06:03:34 -0300 Subject: Removed empty bind group from integration example (#390) --- examples/integration/src/scene.rs | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) (limited to 'examples') diff --git a/examples/integration/src/scene.rs b/examples/integration/src/scene.rs index 6c1a4581..74cbb925 100644 --- a/examples/integration/src/scene.rs +++ b/examples/integration/src/scene.rs @@ -3,17 +3,13 @@ use iced_winit::Color; pub struct Scene { pipeline: wgpu::RenderPipeline, - bind_group: wgpu::BindGroup, } impl Scene { pub fn new(device: &wgpu::Device) -> Scene { - let (pipeline, bind_group) = build_pipeline(device); + let pipeline = build_pipeline(device); - Scene { - pipeline, - bind_group, - } + Scene { pipeline } } pub fn clear<'a>( @@ -45,14 +41,11 @@ impl Scene { 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); } } -fn build_pipeline( - device: &wgpu::Device, -) -> (wgpu::RenderPipeline, wgpu::BindGroup) { +fn build_pipeline(device: &wgpu::Device) -> wgpu::RenderPipeline { let vs = include_bytes!("shader/vert.spv"); let fs = include_bytes!("shader/frag.spv"); @@ -64,21 +57,9 @@ fn build_pipeline( &wgpu::read_spirv(std::io::Cursor::new(&fs[..])).unwrap(), ); - let bind_group_layout = - device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { - label: None, - bindings: &[], - }); - - let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor { - label: None, - layout: &bind_group_layout, - bindings: &[], - }); - let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { - bind_group_layouts: &[&bind_group_layout], + bind_group_layouts: &[], }); let pipeline = @@ -116,5 +97,5 @@ fn build_pipeline( alpha_to_coverage_enabled: false, }); - (pipeline, bind_group) + pipeline } -- cgit From 4960a8827e46cafca672ed7c4550086a9c6029bc Mon Sep 17 00:00:00 2001 From: Duncan Freeman Date: Mon, 8 Jun 2020 02:07:45 -0700 Subject: Add on_release message to Slider (#378) * Add on_finish callback to Slider * Fix formatting * Rename Slider's on_finish to on_release, make the message simply an event without data * Satisfy Clone impl requirement on Message in integration test * Only call on_release after dragging a slider --- examples/integration/src/controls.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/integration/src/controls.rs b/examples/integration/src/controls.rs index 81c35072..e6e74995 100644 --- a/examples/integration/src/controls.rs +++ b/examples/integration/src/controls.rs @@ -9,7 +9,7 @@ pub struct Controls { sliders: [slider::State; 3], } -#[derive(Debug)] +#[derive(Debug, Clone)] pub enum Message { BackgroundColorChanged(Color), } -- cgit From be0cc2c780256ba776e52e0dd14f384553d6a332 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 8 Jun 2020 18:25:23 +0200 Subject: Add `leeway` support to `PaneGrid::on_resize` --- examples/pane_grid/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/pane_grid/src/main.rs b/examples/pane_grid/src/main.rs index b4bbd68f..a821072f 100644 --- a/examples/pane_grid/src/main.rs +++ b/examples/pane_grid/src/main.rs @@ -103,7 +103,7 @@ impl Sandbox for Example { .height(Length::Fill) .spacing(10) .on_drag(Message::Dragged) - .on_resize(Message::Resized) + .on_resize(10, Message::Resized) .on_key_press(handle_hotkey); Container::new(pane_grid) -- cgit