Basic clear screen
This commit is contained in:
parent
9d332655be
commit
0ee15a1c06
49
src/main.rs
49
src/main.rs
|
@ -1,5 +1,47 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use crawl::winit::event::{Event, WindowEvent};
|
use crawl::{
|
||||||
|
wgpu,
|
||||||
|
winit::event::{Event, WindowEvent},
|
||||||
|
};
|
||||||
|
|
||||||
|
fn render(ctx: &mut crawl::Context) -> Result<()> {
|
||||||
|
let frame = ctx.surface.get_current_texture()?;
|
||||||
|
let view = frame
|
||||||
|
.texture
|
||||||
|
.create_view(&wgpu::TextureViewDescriptor::default());
|
||||||
|
|
||||||
|
let mut encoder = ctx
|
||||||
|
.device
|
||||||
|
.create_command_encoder(&wgpu::CommandEncoderDescriptor {
|
||||||
|
label: Some("Base Render Encoder"),
|
||||||
|
});
|
||||||
|
|
||||||
|
let _render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||||
|
label: Some("Render Pass"),
|
||||||
|
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
|
||||||
|
view: &view,
|
||||||
|
resolve_target: None,
|
||||||
|
ops: wgpu::Operations {
|
||||||
|
load: wgpu::LoadOp::Clear(wgpu::Color {
|
||||||
|
r: 0.4,
|
||||||
|
g: 0.4,
|
||||||
|
b: 0.4,
|
||||||
|
a: 1.0,
|
||||||
|
}),
|
||||||
|
store: wgpu::StoreOp::Store,
|
||||||
|
},
|
||||||
|
})],
|
||||||
|
depth_stencil_attachment: None,
|
||||||
|
occlusion_query_set: None,
|
||||||
|
timestamp_writes: None,
|
||||||
|
});
|
||||||
|
drop(_render_pass);
|
||||||
|
|
||||||
|
ctx.queue.submit(Some(encoder.finish()));
|
||||||
|
frame.present();
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
|
@ -17,7 +59,10 @@ fn main() -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let WindowEvent::RedrawRequested = event {
|
if let WindowEvent::RedrawRequested = event {
|
||||||
log::info!("Epic");
|
if let Err(err) = render(&mut context) {
|
||||||
|
log::error!("{err:?}");
|
||||||
|
}
|
||||||
|
|
||||||
context.window.request_redraw();
|
context.window.request_redraw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue