Working alg
This commit is contained in:
42
src/lib.rs
42
src/lib.rs
@ -1,14 +1,17 @@
|
||||
#![allow(incomplete_features)]
|
||||
#![feature(generic_const_exprs)]
|
||||
|
||||
pub mod egui_renderer;
|
||||
pub mod state;
|
||||
pub mod voxel;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use winit::{
|
||||
application::ApplicationHandler,
|
||||
event::WindowEvent,
|
||||
event_loop::{self, EventLoop},
|
||||
window::Window,
|
||||
};
|
||||
use winit::application::ApplicationHandler;
|
||||
use winit::event::WindowEvent;
|
||||
use winit::event_loop::EventLoop;
|
||||
use winit::event_loop::{self};
|
||||
use winit::window::Window;
|
||||
|
||||
use crate::state::State;
|
||||
|
||||
@ -45,6 +48,10 @@ impl ApplicationHandler for App {
|
||||
self.state = Some(state);
|
||||
|
||||
window.request_redraw();
|
||||
window.set_cursor_visible(false);
|
||||
window
|
||||
.set_cursor_grab(winit::window::CursorGrabMode::Locked)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
fn window_event(
|
||||
@ -68,6 +75,29 @@ impl ApplicationHandler for App {
|
||||
WindowEvent::Resized(size) => {
|
||||
state.resize(size);
|
||||
}
|
||||
|
||||
WindowEvent::MouseWheel { delta, .. } => {
|
||||
state.mouse_wheel(delta);
|
||||
}
|
||||
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn device_event(
|
||||
&mut self,
|
||||
_event_loop: &event_loop::ActiveEventLoop,
|
||||
_device_id: winit::event::DeviceId,
|
||||
event: winit::event::DeviceEvent,
|
||||
) {
|
||||
let state = self.state.as_mut().unwrap();
|
||||
|
||||
#[allow(clippy::single_match)]
|
||||
match event {
|
||||
winit::event::DeviceEvent::MouseMotion { delta } => {
|
||||
state.cursor_moved(delta.0 as f32, delta.1 as f32);
|
||||
}
|
||||
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user