move wireframe mode to options

This commit is contained in:
griffi-gh 2023-01-17 21:42:20 +01:00
parent 717e219003
commit a439dc9dcf
4 changed files with 12 additions and 5 deletions

View file

@ -15,4 +15,3 @@ simdnoise = "3.1"
[features]
default = []
polygon_rendering = []

View file

@ -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(

View file

@ -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,
}
}
}

View file

@ -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()
};