use crate::size::Size;
#[repr(C)]
#[derive(Copy, Clone, Debug, bytemuck::Pod, bytemuck::Zeroable)]
pub struct ImageVertex {
pub position: [f32; 2],
pub tex_coords: [f32; 2],
pub screen_size: [f32; 2],
}
impl ImageVertex {
pub fn new_coord(pos: [f32; 2], coord: [f32; 2], screen: Size) -> ImageVertex {
ImageVertex {
position: pos,
tex_coords: coord,
screen_size: screen.as_gamma_size(),
}
}
pub const ATTRIBS: [wgpu::VertexAttribute; 3] =
wgpu::vertex_attr_array![
0 => Float32x2, 1 => Float32x2, 2 => Float32x2, ];
pub fn desc() -> wgpu::VertexBufferLayout<'static> {
wgpu::VertexBufferLayout {
array_stride: std::mem::size_of::<ImageVertex>() as wgpu::BufferAddress,
step_mode: wgpu::VertexStepMode::Vertex,
attributes: &Self::ATTRIBS,
}
}
}