bug fix
This commit is contained in:
parent
b6e89be8a9
commit
f540afdd0a
@ -98,10 +98,10 @@ fn handle_window_event(state: &mut State, event: WindowEvent) -> ControlFlow {
|
||||
// toggle fullscreen
|
||||
state.set_fullscreen(!state.is_fullscreen());
|
||||
}
|
||||
_ => state.process_key(key, elem_state),
|
||||
_ => if state.is_focused() { state.process_key(key, elem_state); }
|
||||
}
|
||||
|
||||
_ => ()
|
||||
_ => (),
|
||||
}
|
||||
|
||||
return ControlFlow::Poll;
|
||||
@ -171,7 +171,7 @@ fn real_main() -> Result<(), &'static str> {
|
||||
|
||||
frames += 1;
|
||||
if total_elapsed >= 1.0 {
|
||||
println!("frames in the past {total_elapsed}: {frames:?}");
|
||||
println!("frames in the past {total_elapsed}s: {frames:?}");
|
||||
frames = 0;
|
||||
total_elapsed = 0.0;
|
||||
}
|
||||
|
43
src/state.rs
43
src/state.rs
@ -211,11 +211,13 @@ impl State {
|
||||
|
||||
let window = self.window();
|
||||
if to {
|
||||
drop(window
|
||||
.set_cursor_grab(winit::window::CursorGrabMode::Confined)
|
||||
.or_else(|_| window.set_cursor_grab(winit::window::CursorGrabMode::Locked)));
|
||||
window.set_cursor_visible(false);
|
||||
window.set_cursor_grab(winit::window::CursorGrabMode::Confined).expect("failed to lock cursor");
|
||||
} else {
|
||||
window.set_cursor_visible(true);
|
||||
window.set_cursor_grab(winit::window::CursorGrabMode::None).expect("failed to unlock cursor");
|
||||
window.set_cursor_visible(true);
|
||||
}
|
||||
|
||||
self.focused = to;
|
||||
@ -285,25 +287,26 @@ impl State {
|
||||
let mut encoder = self.device.create_command_encoder(&(wgpu::CommandEncoderDescriptor {
|
||||
label: Some("Render Encoder"),
|
||||
}));
|
||||
{
|
||||
let mut 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(Default::default()),
|
||||
store: true,
|
||||
},
|
||||
})],
|
||||
depth_stencil_attachment: None,
|
||||
}));
|
||||
render_pass.set_pipeline(&(self.render_pipeline));
|
||||
|
||||
render_pass.set_bind_group(0, &(self.camera_bind_group), &[]);
|
||||
render_pass.set_vertex_buffer(0, self.vertex_buffer.slice(..));
|
||||
render_pass.draw(0..6, 0..1);
|
||||
}
|
||||
let mut 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(Default::default()),
|
||||
store: true,
|
||||
},
|
||||
})],
|
||||
depth_stencil_attachment: None,
|
||||
}));
|
||||
render_pass.set_pipeline(&(self.render_pipeline));
|
||||
|
||||
render_pass.set_bind_group(0, &(self.camera_bind_group), &[]);
|
||||
render_pass.set_vertex_buffer(0, self.vertex_buffer.slice(..));
|
||||
render_pass.draw(0..6, 0..1);
|
||||
|
||||
drop(render_pass);
|
||||
|
||||
// submit will accept anything that implements IntoIter
|
||||
self.queue.submit(std::iter::once(encoder.finish()));
|
||||
|
Loading…
Reference in New Issue
Block a user