1use bytemuck::{Pod, Zeroable};
2
3#[repr(C)]
6#[derive(Copy, Clone, Debug, Pod, Zeroable)]
7pub struct GlyphInstance {
8 pub pos: [f32; 2],
10 pub size: [f32; 2],
12 pub uv_pos: [f32; 2],
14 pub uv_size: [f32; 2],
16 pub color: [f32; 4],
18 pub bg_color: [f32; 4],
20 pub clip_rect: [f32; 4],
22}
23
24impl GlyphInstance {
25 pub fn desc() -> wgpu::VertexBufferLayout<'static> {
27 wgpu::VertexBufferLayout {
28 array_stride: std::mem::size_of::<GlyphInstance>() as wgpu::BufferAddress,
29 step_mode: wgpu::VertexStepMode::Instance,
30 attributes: &[
31 wgpu::VertexAttribute { offset: 0, shader_location: 0, format: wgpu::VertexFormat::Float32x2 }, wgpu::VertexAttribute { offset: 8, shader_location: 1, format: wgpu::VertexFormat::Float32x2 }, wgpu::VertexAttribute { offset: 16, shader_location: 2, format: wgpu::VertexFormat::Float32x2 }, wgpu::VertexAttribute { offset: 24, shader_location: 3, format: wgpu::VertexFormat::Float32x2 }, wgpu::VertexAttribute { offset: 32, shader_location: 4, format: wgpu::VertexFormat::Float32x4 }, wgpu::VertexAttribute { offset: 48, shader_location: 5, format: wgpu::VertexFormat::Float32x4 }, wgpu::VertexAttribute { offset: 64, shader_location: 6, format: wgpu::VertexFormat::Float32x4 }, ],
39 }
40 }
41}