Clear frames explicitly in integration example
				
					
				
			This commit is contained in:
		
							parent
							
								
									969de1d31c
								
							
						
					
					
						commit
						fd3801ed38
					
				| @ -154,37 +154,19 @@ pub fn main() { | |||||||
|                     &wgpu::CommandEncoderDescriptor { label: None }, |                     &wgpu::CommandEncoderDescriptor { label: None }, | ||||||
|                 ); |                 ); | ||||||
| 
 | 
 | ||||||
|                 // We draw the scene first
 |  | ||||||
|                 let program = state.program(); |                 let program = state.program(); | ||||||
| 
 | 
 | ||||||
|                 scene.draw( |                 { | ||||||
|                     &mut encoder, |                     // We clear the frame
 | ||||||
|                     &frame.view, |                     let mut render_pass = scene.clear( | ||||||
|                     program.background_color(), |                         &frame.view, | ||||||
|                 ); |                         &mut encoder, | ||||||
|  |                         program.background_color(), | ||||||
|  |                     ); | ||||||
| 
 | 
 | ||||||
|                 // If you are using this example and you have no `scene` on your application,
 |                     // Draw the scene
 | ||||||
|                 // you can clear screen by this code.
 |                     scene.draw(&mut render_pass); | ||||||
|                 /* |                 } | ||||||
|                 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
 |                 // And then iced on top
 | ||||||
|                 let mouse_interaction = renderer.backend_mut().draw( |                 let mouse_interaction = renderer.backend_mut().draw( | ||||||
|  | |||||||
| @ -16,38 +16,37 @@ impl Scene { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     pub fn draw( |     pub fn clear<'a>( | ||||||
|         &self, |         &self, | ||||||
|         encoder: &mut wgpu::CommandEncoder, |         target: &'a wgpu::TextureView, | ||||||
|         target: &wgpu::TextureView, |         encoder: &'a mut wgpu::CommandEncoder, | ||||||
|         background_color: Color, |         background_color: Color, | ||||||
|     ) { |     ) -> wgpu::RenderPass<'a> { | ||||||
|         let mut rpass = |         encoder.begin_render_pass(&wgpu::RenderPassDescriptor { | ||||||
|             encoder.begin_render_pass(&wgpu::RenderPassDescriptor { |             color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { | ||||||
|                 color_attachments: &[ |                 attachment: target, | ||||||
|                     wgpu::RenderPassColorAttachmentDescriptor { |                 resolve_target: None, | ||||||
|                         attachment: target, |                 load_op: wgpu::LoadOp::Clear, | ||||||
|                         resolve_target: None, |                 store_op: wgpu::StoreOp::Store, | ||||||
|                         load_op: wgpu::LoadOp::Clear, |                 clear_color: { | ||||||
|                         store_op: wgpu::StoreOp::Store, |                     let [r, g, b, a] = background_color.into_linear(); | ||||||
|                         clear_color: { |  | ||||||
|                             let [r, g, b, a] = background_color.into_linear(); |  | ||||||
| 
 | 
 | ||||||
|                             wgpu::Color { |                     wgpu::Color { | ||||||
|                                 r: r as f64, |                         r: r as f64, | ||||||
|                                 g: g as f64, |                         g: g as f64, | ||||||
|                                 b: b as f64, |                         b: b as f64, | ||||||
|                                 a: a as f64, |                         a: a as f64, | ||||||
|                             } |                     } | ||||||
|                         }, |                 }, | ||||||
|                     }, |             }], | ||||||
|                 ], |             depth_stencil_attachment: None, | ||||||
|                 depth_stencil_attachment: None, |         }) | ||||||
|             }); |     } | ||||||
| 
 | 
 | ||||||
|         rpass.set_pipeline(&self.pipeline); |     pub fn draw<'a>(&'a self, render_pass: &mut wgpu::RenderPass<'a>) { | ||||||
|         rpass.set_bind_group(0, &self.bind_group, &[]); |         render_pass.set_pipeline(&self.pipeline); | ||||||
|         rpass.draw(0..3, 0..1); |         render_pass.set_bind_group(0, &self.bind_group, &[]); | ||||||
|  |         render_pass.draw(0..3, 0..1); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user