From 2111c1248b08236a839dcf22036f92735bceb31c Mon Sep 17 00:00:00 2001 From: tcmal Date: Sun, 25 Aug 2024 17:44:21 +0100 Subject: chore(all): style formatting and clippy fixes --- stockton-render/src/lib.rs | 67 +++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 34 deletions(-) (limited to 'stockton-render/src/lib.rs') diff --git a/stockton-render/src/lib.rs b/stockton-render/src/lib.rs index 0db4b76..7e7ea5b 100644 --- a/stockton-render/src/lib.rs +++ b/stockton-render/src/lib.rs @@ -21,58 +21,57 @@ extern crate gfx_hal as hal; extern crate shaderc; extern crate winit; -extern crate nalgebra_glm as na; extern crate image; extern crate log; +extern crate nalgebra_glm as na; -extern crate stockton_types; extern crate stockton_levels; +extern crate stockton_types; extern crate arrayvec; +mod culling; pub mod draw; mod error; mod types; -mod culling; -use stockton_types::World; use stockton_levels::prelude::*; +use stockton_types::World; -use error::{CreationError, FrameError}; -use draw::RenderingContext; use culling::get_visible_faces; +use draw::RenderingContext; +use error::{CreationError, FrameError}; /// Renders a world to a window when you tell it to. pub struct Renderer<'a, T: MinBSPFeatures> { - world: World, - pub context: RenderingContext<'a> + world: World, + pub context: RenderingContext<'a>, } - impl<'a, T: MinBSPFeatures> Renderer<'a, T> { - /// Create a new Renderer. - /// This initialises all the vulkan context, etc needed. - pub fn new(world: World, window: &winit::window::Window) -> Result { - let context = RenderingContext::new(window, &world.map)?; - - Ok(Renderer { - world, context - }) - } - - /// Render a single frame of the world - pub fn render_frame(&mut self) -> Result<(), FrameError>{ - // Get visible faces - let faces = get_visible_faces(self.context.camera_pos(), &self.world.map); - - // Then draw them - if let Err(_) = self.context.draw_vertices(&self.world.map, &faces) { - unsafe {self.context.handle_surface_change().unwrap()}; - - // If it fails twice, then error - self.context.draw_vertices(&self.world.map, &faces).map_err(|_| FrameError::PresentError)?; - } - - Ok(()) - } + /// Create a new Renderer. + /// This initialises all the vulkan context, etc needed. + pub fn new(world: World, window: &winit::window::Window) -> Result { + let context = RenderingContext::new(window, &world.map)?; + + Ok(Renderer { world, context }) + } + + /// Render a single frame of the world + pub fn render_frame(&mut self) -> Result<(), FrameError> { + // Get visible faces + let faces = get_visible_faces(self.context.camera_pos(), &self.world.map); + + // Then draw them + if self.context.draw_vertices(&self.world.map, &faces).is_err() { + unsafe { self.context.handle_surface_change().unwrap() }; + + // If it fails twice, then error + self.context + .draw_vertices(&self.world.map, &faces) + .map_err(|_| FrameError::PresentError)?; + } + + Ok(()) + } } -- cgit v1.2.3