diff --git a/src/game.rs b/src/game.rs index 5cf540a..359eeba 100644 --- a/src/game.rs +++ b/src/game.rs @@ -24,9 +24,11 @@ pub fn run() { log::info!("loading assets"); let assets = Assets::load_all_sync(&display); log::info!("init camera"); - let mut camera = Camera::default(); - camera.position = [0., 0., -1.]; - camera.direction = [0., 0., 1.]; + let camera = Camera { + position: [0., 0., -1.], + direction: [0., 0., 1.], + ..Default::default() + }; log::info!("game loaded"); //======================= @@ -37,7 +39,9 @@ pub fn run() { let vertex_buffer = glium::VertexBuffer::new(&display, &shape).unwrap(); //======================= + event_loop.run(move |ev, _, control_flow| { + #[allow(clippy::single_match, clippy::collapsible_match)] match ev { Event::WindowEvent { event, .. } => match event { WindowEvent::CloseRequested => { @@ -56,7 +60,7 @@ pub fn run() { target.clear_color_and_depth((0.5, 0.5, 1., 1.), 1.); target.draw( &vertex_buffer, - &glium::index::NoIndices(glium::index::PrimitiveType::TrianglesList), + glium::index::NoIndices(glium::index::PrimitiveType::TrianglesList), &programs.chunk, &uniform! { model: [[0.0f32; 4]; 4], diff --git a/src/game/assets/textures.rs b/src/game/assets/textures.rs index ebf96f4..69780ea 100644 --- a/src/game/assets/textures.rs +++ b/src/game/assets/textures.rs @@ -6,7 +6,7 @@ fn load_png(file_path: &str, display: &glium::Display) -> SrgbTexture2d { //Load file let data = fs::read(file_path) - .expect(&format!("Failed to load texture: {}", file_path)); + .unwrap_or_else(|_| panic!("Failed to load texture: {}", file_path)); //decode image data let image_data = image::load( diff --git a/src/game/camera.rs b/src/game/camera.rs index 1e87db8..c7e8db0 100644 --- a/src/game/camera.rs +++ b/src/game/camera.rs @@ -14,10 +14,6 @@ pub struct Camera { pub zfar: f32, } impl Camera { - pub fn new() -> Self { - Default::default() - } - pub fn view_matrix(&self) -> [[f32; 4]; 4] { let position = self.position; let direction = self.direction; diff --git a/src/game/display.rs b/src/game/display.rs index f195f1c..ec81722 100644 --- a/src/game/display.rs +++ b/src/game/display.rs @@ -8,5 +8,5 @@ use glium::glutin::{ pub fn init_display(event_loop: &EventLoop<()>) -> Display { let wb = WindowBuilder::new(); let cb = ContextBuilder::new().with_depth_buffer(24); - Display::new(wb, cb, &event_loop).unwrap() + Display::new(wb, cb, event_loop).unwrap() } diff --git a/src/game/shaders/colored2d.rs b/src/game/shaders/colored2d.rs index 099e209..83f7207 100644 --- a/src/game/shaders/colored2d.rs +++ b/src/game/shaders/colored2d.rs @@ -1,4 +1,4 @@ -use glium::{Display, Program, implement_vertex}; +use glium::implement_vertex; #[derive(Clone, Copy)] pub struct Vertex {