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

79 lines
1.9 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 TextureVertex2D {
pub v_position: [f32; 2],
pub ti_position: [f32; 2],
}
vulkano::impl_vertex!(TextureVertex2D, v_position, ti_position);
#[derive(Default, Debug, Clone, Copy)]
pub struct ColorVertex2D {
pub v_position: [f32; 2],
pub color: [f32; 4],
}
vulkano::impl_vertex!(ColorVertex2D, v_position, color);
#[derive(Default, Debug, Clone, Copy)]
pub struct ImageVertex2D {
pub v_position: [f32; 2],
pub color: [f32; 4],
}
vulkano::impl_vertex!(ImageVertex2D, v_position, color);
#[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(Debug, Clone)]
pub enum VertexTypes {
TextureType(Vec<TextureVertex2D>, Arc<CanvasTextureHandle>),
ImageType(Vec<ImageVertex2D>, Arc<CanvasImageHandle>),
ColorType(Vec<ColorVertex2D>),
ThreeDType(Vec<Vertex3D>),
}
#[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)>>,
}