mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-25 16:28:42 -06:00
move wireframe mode to options
This commit is contained in:
parent
717e219003
commit
a439dc9dcf
|
@ -15,4 +15,3 @@ simdnoise = "3.1"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
polygon_rendering = []
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ pub fn run() {
|
||||||
let view = state.camera.view_matrix();
|
let view = state.camera.view_matrix();
|
||||||
|
|
||||||
//Draw chunks
|
//Draw chunks
|
||||||
state.world.render(&mut target, &programs, &assets, perspective, view);
|
state.world.render(&mut target, &programs, &assets, perspective, view, &options);
|
||||||
|
|
||||||
//Draw example triangle
|
//Draw example triangle
|
||||||
// target.draw(
|
// target.draw(
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct GameOptions {
|
pub struct GameOptions {
|
||||||
pub render_distance: u8,
|
pub render_distance: u8,
|
||||||
|
pub debug_wireframe_mode: bool,
|
||||||
}
|
}
|
||||||
impl Default for GameOptions {
|
impl Default for GameOptions {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
render_distance: if cfg!(debug_assertions) { 8 } else { 16 },
|
render_distance: if cfg!(debug_assertions) { 8 } else { 16 },
|
||||||
|
debug_wireframe_mode: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,8 @@ use glam::{Vec2, IVec2};
|
||||||
use glium::{
|
use glium::{
|
||||||
Display, Frame, Surface,
|
Display, Frame, Surface,
|
||||||
DrawParameters, Depth,
|
DrawParameters, Depth,
|
||||||
DepthTest, uniform,
|
DepthTest, PolygonMode,
|
||||||
|
uniform,
|
||||||
uniforms::{
|
uniforms::{
|
||||||
Sampler, SamplerBehavior,
|
Sampler, SamplerBehavior,
|
||||||
MinifySamplerFilter, MagnifySamplerFilter,
|
MinifySamplerFilter, MagnifySamplerFilter,
|
||||||
|
@ -55,7 +56,8 @@ impl World {
|
||||||
programs: &Programs,
|
programs: &Programs,
|
||||||
assets: &Assets,
|
assets: &Assets,
|
||||||
perspective: [[f32; 4]; 4],
|
perspective: [[f32; 4]; 4],
|
||||||
view: [[f32; 4]; 4]
|
view: [[f32; 4]; 4],
|
||||||
|
options: &GameOptions
|
||||||
) {
|
) {
|
||||||
let sampler = SamplerBehavior {
|
let sampler = SamplerBehavior {
|
||||||
minify_filter: MinifySamplerFilter::Linear,
|
minify_filter: MinifySamplerFilter::Linear,
|
||||||
|
@ -69,7 +71,11 @@ impl World {
|
||||||
write: true,
|
write: true,
|
||||||
..Default::default()
|
..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,
|
backface_culling: glium::draw_parameters::BackfaceCullingMode::CullCounterClockwise,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue