This commit is contained in:
griffi-gh 2023-01-28 22:43:25 +01:00
parent 665b3b841e
commit 827ed16aa1

View file

@ -7,9 +7,7 @@ use glium::{
VertexBuffer, uniform, VertexBuffer, uniform,
DrawParameters, DrawParameters,
BackfaceCullingMode, BackfaceCullingMode,
Blend, BlendingFunction, Blend, Depth, DepthTest,
LinearBlendingFactor,
Depth, DepthTest,
}; };
use crate::{ use crate::{
world::raycast::LookingAtBlock, world::raycast::LookingAtBlock,
@ -62,36 +60,27 @@ pub fn render_selection_box(
&display.display, &display.display,
BOX_VERTICES BOX_VERTICES
).unwrap(); ).unwrap();
let index = IndexBuffer::new( let index = IndexBuffer::new(
&display.display, &display.display,
PrimitiveType::TrianglesList, PrimitiveType::TrianglesList,
CUBE_INDICES CUBE_INDICES
).unwrap(); ).unwrap();
//Darken block
target.0.draw( target.0.draw(
&vert, &vert,
&index, &index,
&program.0, &program.0,
&uniform! { &uniform! {
color: [0., 0., 0., 1.], u_color: [0., 0., 0., 0.5_f32],
u_position: lookat.block_position.as_vec3().to_array(), u_position: lookat.block_position.as_vec3().to_array(),
perspective: camera.perspective_matrix.to_cols_array_2d(), perspective: camera.perspective_matrix.to_cols_array_2d(),
view: camera.view_matrix.to_cols_array_2d(), view: camera.view_matrix.to_cols_array_2d(),
}, },
&DrawParameters { &DrawParameters {
backface_culling: BackfaceCullingMode::CullClockwise, backface_culling: BackfaceCullingMode::CullClockwise,
blend: Blend { blend: Blend::alpha_blending(),
//for some reason only constant alpha works???
color: BlendingFunction::Addition {
source: LinearBlendingFactor::ConstantAlpha,
destination: LinearBlendingFactor::OneMinusConstantAlpha,
},
alpha: BlendingFunction::Addition {
source: LinearBlendingFactor::ConstantAlpha,
destination: LinearBlendingFactor::OneMinusConstantAlpha
},
constant_value: (0.0, 0.0, 0.0, 0.5)
},
depth: Depth { depth: Depth {
test: DepthTest::IfLessOrEqual, //this may be unreliable! test: DepthTest::IfLessOrEqual, //this may be unreliable!
..Default::default() ..Default::default()