Begin implement input management
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 8m4s
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 8m4s
This commit is contained in:
parent
2c3392c3ea
commit
c4c691c4dd
3 changed files with 99 additions and 1 deletions
|
@ -16,6 +16,7 @@ use winit::event::WindowEvent;
|
|||
use winit::event_loop::ActiveEventLoop;
|
||||
use winit::window::WindowId;
|
||||
|
||||
use super::input::InputState;
|
||||
use super::vulkan_context::VulkanContext;
|
||||
|
||||
pub struct App {
|
||||
|
@ -24,6 +25,7 @@ pub struct App {
|
|||
gui: HashMap<WindowId, Gui>,
|
||||
scene: Option<Scene>,
|
||||
clear_color: [f32; 3],
|
||||
input_state: InputState,
|
||||
}
|
||||
|
||||
impl From<VulkanoContext> for App {
|
||||
|
@ -34,6 +36,7 @@ impl From<VulkanoContext> for App {
|
|||
gui: HashMap::new(),
|
||||
scene: None,
|
||||
clear_color: [0.0, 0.0, 0.0],
|
||||
input_state: InputState::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +83,10 @@ impl ApplicationHandler for App {
|
|||
fn window_event(&mut self, event_loop: &ActiveEventLoop, id: WindowId, event: WindowEvent) {
|
||||
let renderer = self.vulkano_windows.get_renderer_mut(id).unwrap();
|
||||
let gui = self.gui.get_mut(&id).unwrap();
|
||||
gui.update(&event);
|
||||
|
||||
if !gui.update(&event) {
|
||||
self.input_state.process_event(&event);
|
||||
}
|
||||
|
||||
match event {
|
||||
WindowEvent::CloseRequested => {
|
||||
|
@ -94,6 +100,8 @@ impl ApplicationHandler for App {
|
|||
renderer.resize();
|
||||
}
|
||||
WindowEvent::RedrawRequested => {
|
||||
self.input_state.update();
|
||||
|
||||
let acquire_future = renderer.acquire(None, |_| {}).unwrap();
|
||||
|
||||
let mut builder = AutoCommandBufferBuilder::primary(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue