|
|
|
@ -1,8 +1,9 @@
|
|
|
|
|
use crate::util::vertex_3d::{Vertex3D};
|
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
use std::collections::HashMap;
|
|
|
|
|
use crate::canvas::canvas_state::{Drawable, CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle};
|
|
|
|
|
use crate::canvas::canvas_state::{Drawable, CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle, DrawableTest};
|
|
|
|
|
use crate::canvas::shader::text_shader::GlyphInstance;
|
|
|
|
|
use std::hash::Hash;
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
pub struct CanvasFrame {
|
|
|
|
@ -12,10 +13,6 @@ pub struct CanvasFrame {
|
|
|
|
|
pub text_drawables: HashMap<Arc<CanvasFontHandle>, Vec<GlyphInstance>>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub struct GenericCanvasFrame<V, H, Im, In, T> {
|
|
|
|
|
frame_data: HashMap<Arc<H>, Vec<(V, Im, In, T)>>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl CanvasFrame {
|
|
|
|
|
|
|
|
|
|
/// Creates a bare canvas frame with empty accumulators
|
|
|
|
@ -55,3 +52,24 @@ impl CanvasFrame {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub struct GenericCanvasFrame<H, V, In> {
|
|
|
|
|
frame_data: HashMap<H, Vec<(Vec<V>, Vec<In>)>>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<H, V, In> GenericCanvasFrame<H, V, In> {
|
|
|
|
|
|
|
|
|
|
/// Creates a bare canvas frame with empty accumulators
|
|
|
|
|
pub fn new() -> GenericCanvasFrame<H, V, In> where H: Eq + Hash {
|
|
|
|
|
GenericCanvasFrame {
|
|
|
|
|
frame_data: Default::default()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn draw(&mut self, drawable: &dyn DrawableTest<V, H, In>) where H: Eq + Hash + Clone {
|
|
|
|
|
self.frame_data
|
|
|
|
|
.entry(drawable.get_handle().clone())
|
|
|
|
|
.or_insert(Vec::new())
|
|
|
|
|
.push((drawable.get_vertices(), drawable.get_instances()));
|
|
|
|
|
}
|
|
|
|
|
}
|