separate render function
This commit is contained in:
parent
9054765bcc
commit
c99f127da3
28
src/main.rs
28
src/main.rs
|
|
@ -37,6 +37,32 @@ impl MainWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn render(&self, output: &wgpu::Texture) {
|
||||||
|
let view = output.create_view(&wgpu::TextureViewDescriptor::default());
|
||||||
|
let mut encoder = self
|
||||||
|
.device
|
||||||
|
.create_command_encoder(&wgpu::CommandEncoderDescriptor::default());
|
||||||
|
encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||||
|
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
|
||||||
|
view: &view,
|
||||||
|
depth_slice: None,
|
||||||
|
resolve_target: None,
|
||||||
|
ops: wgpu::Operations {
|
||||||
|
load: wgpu::LoadOp::Clear(wgpu::Color {
|
||||||
|
r: 0.1,
|
||||||
|
g: 0.2,
|
||||||
|
b: 0.8,
|
||||||
|
a: 1.0,
|
||||||
|
}),
|
||||||
|
store: wgpu::StoreOp::Store,
|
||||||
|
},
|
||||||
|
})],
|
||||||
|
depth_stencil_attachment: None,
|
||||||
|
..Default::default()
|
||||||
|
});
|
||||||
|
self.queue.submit(std::iter::once(encoder.finish()));
|
||||||
|
}
|
||||||
|
|
||||||
fn event(&mut self, event_loop: &ActiveEventLoop, event: WindowEvent) {
|
fn event(&mut self, event_loop: &ActiveEventLoop, event: WindowEvent) {
|
||||||
match event {
|
match event {
|
||||||
WindowEvent::CloseRequested => event_loop.exit(),
|
WindowEvent::CloseRequested => event_loop.exit(),
|
||||||
|
|
@ -62,8 +88,8 @@ impl MainWindow {
|
||||||
if !self.surface_configured {
|
if !self.surface_configured {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let output = self.surface.get_current_texture().unwrap();
|
let output = self.surface.get_current_texture().unwrap();
|
||||||
|
self.render(&output.texture);
|
||||||
output.present();
|
output.present();
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user