You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Trac3r-rust/src/util/vertex.rs

90 lines
2.3 KiB

use crate::canvas::managed::handles::{CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle};
use std::sync::Arc;
use vulkano::buffer::BufferAccess;
use std::collections::HashMap;
#[derive(Default, Debug, Clone, Copy)]
pub struct TextureVertex3D {
pub v_position: [f32; 3],
pub ti_position: [f32; 2],
}
vulkano::impl_vertex!(TextureVertex3D, v_position, ti_position);
#[derive(Default, Debug, Clone, Copy)]
pub struct ColorVertex3D {
pub v_position: [f32; 3],
pub color: [f32; 4],
}
vulkano::impl_vertex!(ColorVertex3D, v_position, color);
#[derive(Default, Debug, Clone, Copy)]
pub struct ImageVertex3D {
pub v_position: [f32; 3],
pub ti_position: [f32; 2],
}
vulkano::impl_vertex!(ImageVertex3D, v_position, ti_position);
#[derive(Default, Debug, Clone, Copy)]
pub struct Vertex3D {
pub v_position: [f32; 3],
pub color : [f32; 4],
pub ti_position: [f32; 2],
}
vulkano::impl_vertex!(Vertex3D, v_position, color, ti_position);
/// Text vertex 3d with vertex position
#[derive(Default, Debug, Clone, Copy)]
pub struct TextVertex3D {
pub position: [f32; 3],
}
vulkano::impl_vertex!(TextVertex3D, position);
#[derive(Default, Debug, Clone, Copy)]
pub struct GlyphInstance {
pub screen_position: (f32, f32),
pub atlas_position: (f32, f32),
pub atlas_size: (f32, f32),
pub scale: f32,
}
vulkano::impl_vertex!(GlyphInstance, screen_position, atlas_position, atlas_size, scale);
// ==============================================================================
#[derive(Debug, Clone)]
pub enum VertexTypes {
TextureType(Vec<TextureVertex3D>, Arc<CanvasTextureHandle>),
ImageType(Vec<ImageVertex3D>, Arc<CanvasImageHandle>),
ColorType(Vec<ColorVertex3D>),
ThreeDType(Vec<Vertex3D>),
TextType(Vec<ColorVertex3D>),
}
#[derive(Clone)]
pub struct CanvasFrameAllocation {
pub colored_vertex_buffer: Vec<Arc<(dyn BufferAccess + Send + Sync)>>,
pub textured_vertex_buffer: HashMap<Arc<CanvasTextureHandle>, Arc<(dyn BufferAccess + Send + Sync)>>,
pub image_vertex_buffer: HashMap<Arc<CanvasImageHandle>, Arc<(dyn BufferAccess + Send + Sync)>>,
pub text_instances: HashMap<Arc<CanvasFontHandle>, Arc<(dyn BufferAccess + Send + Sync)>>,
pub text_vertex_buffer: Vec<Arc<(dyn BufferAccess + Send + Sync)>>,
}