wip selection box

This commit is contained in:
griffi-gh 2023-01-28 04:35:55 +01:00
parent b4462a0176
commit 2bb22ddaec
6 changed files with 67 additions and 2 deletions

View file

@ -0,0 +1,8 @@
#version 150 core
out vec4 color;
uniform vec4 u_color;
void main() {
color = u_color;
}

View file

@ -0,0 +1,10 @@
#version 150 core
in vec3 position;
uniform vec3 u_position;
uniform mat4 perspective;
uniform mat4 view;
void main() {
gl_Position = perspective * view * vec4(position + u_position, 1.);
}

View file

@ -56,6 +56,9 @@ pub struct BlockTexturesPrefab(pub SrgbTexture2dArray);
#[derive(Unique)] #[derive(Unique)]
pub struct ChunkShaderPrefab(pub Program); pub struct ChunkShaderPrefab(pub Program);
#[derive(Unique)]
pub struct SelBoxShaderPrefab(pub Program);
pub fn load_prefabs( pub fn load_prefabs(
storages: AllStoragesView, storages: AllStoragesView,
renderer: NonSendSync<UniqueView<Renderer>> renderer: NonSendSync<UniqueView<Renderer>>
@ -74,4 +77,11 @@ pub fn load_prefabs(
&renderer.display &renderer.display
) )
)); ));
storages.add_unique_non_send_sync(SelBoxShaderPrefab(
include_shader_prefab!(
"../shaders/selection_box.vert",
"../shaders/selection_box.frag",
&renderer.display
)
));
} }

View file

@ -9,6 +9,7 @@ use glium::{
}; };
use glam::Vec3; use glam::Vec3;
pub mod primitives;
pub mod world; pub mod world;
pub mod selection_box; pub mod selection_box;

View file

@ -0,0 +1,32 @@
const CUBE_VERTICES: &[f32] = &[
// front
-1.0, -1.0, 1.0,
1.0, -1.0, 1.0,
1.0, 1.0, 1.0,
-1.0, 1.0, 1.0,
// back
-1.0, -1.0, -1.0,
1.0, -1.0, -1.0,
1.0, 1.0, -1.0,
-1.0, 1.0, -1.0
];
const CUBE_INDICES: &[u16] = &[
// front
0, 1, 2,
2, 3, 0,
// right
1, 5, 6,
6, 2, 1,
// back
7, 6, 5,
5, 4, 7,
// left
4, 0, 3,
3, 7, 4,
// bottom
4, 5, 1,
1, 0, 4,
// top
3, 2, 6,
6, 7, 3
];

View file

@ -1,12 +1,16 @@
use shipyard::{View, IntoIter, NonSendSync, UniqueViewMut}; use shipyard::{View, IntoIter, NonSendSync, UniqueViewMut};
use glium::Surface; use glium::{Surface, implement_vertex};
use crate::{ use crate::{
world::raycast::LookingAtBlock, world::raycast::LookingAtBlock,
camera::Camera camera::Camera
}; };
use super::RenderTarget; use super::RenderTarget;
const CUBE_VERTICES: &[f32] = &[0.0]; #[derive(Clone, Copy)]
pub struct SelBoxVertex {
pub position: [f32; 3],
}
implement_vertex!(SelBoxVertex, position);
//wip //wip
pub fn render_selection_box( pub fn render_selection_box(