use bytemuck::{Pod, Zeroable};
use wgpu::{VertexAttribute, VertexBufferLayout, VertexFormat, VertexStepMode};
const ATTRIBUTES: &[VertexAttribute] = &[
VertexAttribute {
format: VertexFormat::Float32x3,
offset: 0,
shader_location: 0,
},
VertexAttribute {
format: VertexFormat::Float32x2,
offset: std::mem::offset_of!(TexturedVertex, u) as u64,
shader_location: 1,
},
];
#[repr(C)]
#[derive(Debug, Clone, Copy, Pod, Zeroable)]
pub struct TexturedVertex {
x: f32,
y: f32,
z: f32,
u: f32,
v: f32,
}
impl TexturedVertex {
#[allow(clippy::many_single_char_names)]
pub const fn new(x: f32, y: f32, z: f32, u: f32, v: f32) -> Self {
Self { x, y, z, u, v }
}
pub(crate) const fn descriptor() -> VertexBufferLayout<'static> {
VertexBufferLayout {
array_stride: std::mem::size_of::<Self>() as u64,
step_mode: VertexStepMode::Vertex,
attributes: ATTRIBUTES,
}
}
}
#[repr(C)]
#[derive(Debug, Default, Clone, Copy, Pod, Zeroable)]
pub(crate) struct ScreenInfo {
pub width: f32,
pub height: f32,
pub half_width: f32,
pub half_height: f32,
}