|
|
|
@ -6,37 +6,54 @@ use crate::canvas::*;
|
|
|
|
|
use crate::canvas::managed::shader::dynamic_vertex::RuntimeVertexDef;
|
|
|
|
|
use crate::canvas::managed::handles::{CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle, Handle};
|
|
|
|
|
use crate::canvas::managed::shader::text_shader::GlyphInstance;
|
|
|
|
|
use vulkano::pipeline::vertex::Vertex;
|
|
|
|
|
|
|
|
|
|
// I don't think this is going to work without getting into Box'ing
|
|
|
|
|
pub trait DrawableTest<V, H, In> where H: Handle{
|
|
|
|
|
pub trait DrawableTest<V, H> where H: Handle{
|
|
|
|
|
fn get_vertices(&self) -> Vec<V>;
|
|
|
|
|
fn get_instances(&self) -> Vec<In>;
|
|
|
|
|
fn get_handle(&self) -> H;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub struct DrawableTestee {
|
|
|
|
|
pub vertices: Vec<u32>,
|
|
|
|
|
pub instances: Vec<u32>,
|
|
|
|
|
pub vertices: Vec<ImplVertexData>,
|
|
|
|
|
pub handle: Arc<CanvasTextureHandle>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<V, H: Handle, In> DrawableTest<V, H, In> for DrawableTestee {
|
|
|
|
|
impl<V, H: Handle> DrawableTest<V, H> for DrawableTestee {
|
|
|
|
|
fn get_vertices(&self) -> Vec<V> {
|
|
|
|
|
unimplemented!()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn get_instances(&self) -> Vec<In> {
|
|
|
|
|
fn get_handle(&self) -> H {
|
|
|
|
|
unimplemented!()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn get_handle(&self) -> H {
|
|
|
|
|
unimplemented!()
|
|
|
|
|
pub struct ImplVertexData {
|
|
|
|
|
pub x: i32,
|
|
|
|
|
pub y: i32,
|
|
|
|
|
}
|
|
|
|
|
impl VertexData for ImplVertexData {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub trait VertexData : Sized {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CanvasFrameTest will be drawn to by objects implementing DrawableTest
|
|
|
|
|
pub struct CanvasFrameTest<V: VertexData + Sized, H: Handle + Sized> {
|
|
|
|
|
pub map: HashMap<H, Vec<V>>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<V: VertexData + Sized, H: Handle + Sized + Eq + Hash> CanvasFrameTest<V, H> {
|
|
|
|
|
|
|
|
|
|
pub fn draw(&mut self, drawable: &dyn DrawableTest<V, H>) {
|
|
|
|
|
drawable.get_vertices();
|
|
|
|
|
self.map.insert(drawable.get_handle(), drawable.get_vertices());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub trait Drawable {
|
|
|
|
|
|
|
|
|
@ -62,10 +79,15 @@ pub trait Drawable {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub trait VertexDefinitionAndData {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub struct CanvasFrame {
|
|
|
|
|
pub colored_drawables: Vec<RuntimeVertexDef>,
|
|
|
|
|
pub textured_drawables: HashMap<Arc<CanvasTextureHandle>, Vec<Vec<RuntimeVertexDef>>>,
|
|
|
|
@ -85,7 +107,6 @@ impl CanvasFrame {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// pub fn draw_test<V : VertexDefinitionAndData, H: Handle, In>(&mut self, drawable: &dyn DrawableTest<V, H, In>) {
|
|
|
|
|
// let h = drawable.get_handle();
|
|
|
|
|
//
|
|
|
|
|