mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-12-22 11:58:21 -06:00
wip selection box
This commit is contained in:
parent
b4462a0176
commit
2bb22ddaec
8
shaders/selection_box.frag
Normal file
8
shaders/selection_box.frag
Normal file
|
@ -0,0 +1,8 @@
|
|||
#version 150 core
|
||||
|
||||
out vec4 color;
|
||||
uniform vec4 u_color;
|
||||
|
||||
void main() {
|
||||
color = u_color;
|
||||
}
|
10
shaders/selection_box.vert
Normal file
10
shaders/selection_box.vert
Normal 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.);
|
||||
}
|
|
@ -56,6 +56,9 @@ pub struct BlockTexturesPrefab(pub SrgbTexture2dArray);
|
|||
#[derive(Unique)]
|
||||
pub struct ChunkShaderPrefab(pub Program);
|
||||
|
||||
#[derive(Unique)]
|
||||
pub struct SelBoxShaderPrefab(pub Program);
|
||||
|
||||
pub fn load_prefabs(
|
||||
storages: AllStoragesView,
|
||||
renderer: NonSendSync<UniqueView<Renderer>>
|
||||
|
@ -74,4 +77,11 @@ pub fn load_prefabs(
|
|||
&renderer.display
|
||||
)
|
||||
));
|
||||
storages.add_unique_non_send_sync(SelBoxShaderPrefab(
|
||||
include_shader_prefab!(
|
||||
"../shaders/selection_box.vert",
|
||||
"../shaders/selection_box.frag",
|
||||
&renderer.display
|
||||
)
|
||||
));
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ use glium::{
|
|||
};
|
||||
use glam::Vec3;
|
||||
|
||||
pub mod primitives;
|
||||
pub mod world;
|
||||
pub mod selection_box;
|
||||
|
||||
|
|
32
src/rendering/primitives.rs
Normal file
32
src/rendering/primitives.rs
Normal 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
|
||||
];
|
|
@ -1,12 +1,16 @@
|
|||
use shipyard::{View, IntoIter, NonSendSync, UniqueViewMut};
|
||||
use glium::Surface;
|
||||
use glium::{Surface, implement_vertex};
|
||||
use crate::{
|
||||
world::raycast::LookingAtBlock,
|
||||
camera::Camera
|
||||
};
|
||||
use super::RenderTarget;
|
||||
|
||||
const CUBE_VERTICES: &[f32] = &[0.0];
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct SelBoxVertex {
|
||||
pub position: [f32; 3],
|
||||
}
|
||||
implement_vertex!(SelBoxVertex, position);
|
||||
|
||||
//wip
|
||||
pub fn render_selection_box(
|
||||
|
|
Loading…
Reference in a new issue