save
This commit is contained in:
parent
303e39bd12
commit
d5cc4a3330
@ -17,7 +17,7 @@ impl Vertex {
|
||||
const DESC: VertexBufferLayout<'static> = VertexBufferLayout {
|
||||
array_stride: std::mem::size_of::<Vertex>() as wgpu::BufferAddress,
|
||||
step_mode: wgpu::VertexStepMode::Vertex,
|
||||
attributes: &wgpu::vertex_attr_array![0 => Float32x2, 1 => Float32x4],
|
||||
attributes: &wgpu::vertex_attr_array![0 => Float32x2, 1 => Float32x4, 2 => Uint32],
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -16,8 +16,25 @@ fn vs_main(
|
||||
@location(2) effect: u32
|
||||
) -> VertexOutput {
|
||||
var out: VertexOutput;
|
||||
out.color = color;
|
||||
out.pos = vec4f((pos - uniforms.camera) * uniforms.zooms, 0, 1);
|
||||
switch effect {
|
||||
case 1u, 3u: {
|
||||
var v = (color.r*0.299) + (color.g*0.587) + (color.b*0.114);
|
||||
out.color = vec4f(v, v, v, color.a);
|
||||
}
|
||||
case 0u, 2u: {
|
||||
out.color = color;
|
||||
}
|
||||
default: {}
|
||||
}
|
||||
switch effect {
|
||||
case 0u, 1u: {
|
||||
out.pos = vec4f(pos, 0, 1);
|
||||
}
|
||||
case 2u, 3u: {
|
||||
out.pos = vec4f((pos - uniforms.camera) * uniforms.zooms, 0, 1);
|
||||
}
|
||||
default: {}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
use winit::event::{Touch, TouchPhase, WindowEvent};
|
||||
use crate::graphics::Vertex;
|
||||
|
||||
const BOTTOM_TAB_BAR_HEIGHT: f32 = 0.1;
|
||||
const SECONDARY_COLOR: [f32; 4] = [255./84., 255./33., 255./32., 1.];
|
||||
const BOTTOM_TAB_BAR_HEIGHT: f32 = 0.2;
|
||||
const SECONDARY_COLOR: [f32; 4] = [84./255., 33./255., 32./255., 1.];
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Kind {
|
||||
@ -65,8 +65,27 @@ impl UI {
|
||||
}
|
||||
}
|
||||
pub fn render(&self, vertices: &mut Vec<Vertex>, indices: &mut Vec<u32>) {
|
||||
//let vs = [
|
||||
// Vertex { color: SECONDARY_COLOR, pos: [] }
|
||||
//];
|
||||
let vs = [
|
||||
// Terrain
|
||||
Vertex { color: SECONDARY_COLOR, pos: [-1., -1.+(BOTTOM_TAB_BAR_HEIGHT*2.)], effect: 0 },
|
||||
Vertex { color: SECONDARY_COLOR, pos: [-1., -1.], effect: 0 },
|
||||
Vertex { color: SECONDARY_COLOR, pos: [0., -1.], effect: 0 },
|
||||
Vertex { color: SECONDARY_COLOR, pos: [0., -1.+(BOTTOM_TAB_BAR_HEIGHT*2.)], effect: 0 },
|
||||
|
||||
// Entities
|
||||
// 3,
|
||||
// 2,
|
||||
Vertex { color: SECONDARY_COLOR, pos: [1., -1.], effect: 0 },
|
||||
Vertex { color: SECONDARY_COLOR, pos: [1., -1.+(BOTTOM_TAB_BAR_HEIGHT*2.)], effect: 0 }
|
||||
];
|
||||
let ids = [
|
||||
0,1,2,
|
||||
2,3,0,
|
||||
3,2,4,
|
||||
4,5,3
|
||||
];
|
||||
let i = vertices.len() as u32;
|
||||
vertices.extend_from_slice(&vs);
|
||||
indices.extend_from_slice(&ids.map(|id| id+i));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user