diff --git a/Cargo.toml b/Cargo.toml index 4c6b812..9951fb5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,4 +15,3 @@ simdnoise = "3.1" [features] default = [] -polygon_rendering = [] diff --git a/src/game.rs b/src/game.rs index 54cfb44..68a7cdb 100644 --- a/src/game.rs +++ b/src/game.rs @@ -123,7 +123,7 @@ pub fn run() { let view = state.camera.view_matrix(); //Draw chunks - state.world.render(&mut target, &programs, &assets, perspective, view); + state.world.render(&mut target, &programs, &assets, perspective, view, &options); //Draw example triangle // target.draw( diff --git a/src/game/options.rs b/src/game/options.rs index 962c5d8..7a19998 100644 --- a/src/game/options.rs +++ b/src/game/options.rs @@ -1,11 +1,13 @@ #[derive(Clone, Debug)] pub struct GameOptions { pub render_distance: u8, + pub debug_wireframe_mode: bool, } impl Default for GameOptions { fn default() -> Self { Self { render_distance: if cfg!(debug_assertions) { 8 } else { 16 }, + debug_wireframe_mode: false, } } } diff --git a/src/game/world.rs b/src/game/world.rs index c4e6612..0b0be45 100644 --- a/src/game/world.rs +++ b/src/game/world.rs @@ -2,7 +2,8 @@ use glam::{Vec2, IVec2}; use glium::{ Display, Frame, Surface, DrawParameters, Depth, - DepthTest, uniform, + DepthTest, PolygonMode, + uniform, uniforms::{ Sampler, SamplerBehavior, MinifySamplerFilter, MagnifySamplerFilter, @@ -55,7 +56,8 @@ impl World { programs: &Programs, assets: &Assets, perspective: [[f32; 4]; 4], - view: [[f32; 4]; 4] + view: [[f32; 4]; 4], + options: &GameOptions ) { let sampler = SamplerBehavior { minify_filter: MinifySamplerFilter::Linear, @@ -69,7 +71,11 @@ impl World { write: true, ..Default::default() }, - #[cfg(feature = "polygon_rendering")] polygon_mode: glium::PolygonMode::Line, + polygon_mode: if options.debug_wireframe_mode { + PolygonMode::Line + } else { + PolygonMode::Fill + }, backface_culling: glium::draw_parameters::BackfaceCullingMode::CullCounterClockwise, ..Default::default() };