going to save here. re-evaluating drawable now that runtimevertexdef is in
This commit is contained in:
@@ -1,13 +1,70 @@
|
||||
use crate::util::vertex_3d::{Vertex3D};
|
||||
use std::sync::Arc;
|
||||
use std::collections::HashMap;
|
||||
use crate::canvas::canvas_state::{Drawable};
|
||||
use std::hash::Hash;
|
||||
use crate::canvas::*;
|
||||
use crate::canvas::managed::shader::dynamic_vertex::RuntimeVertexDef;
|
||||
use crate::canvas::managed::handles::{CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle};
|
||||
use crate::canvas::managed::handles::{CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle, Handle};
|
||||
use crate::canvas::managed::shader::text_shader::GlyphInstance;
|
||||
|
||||
// I don't think this is going to work without getting into Box'ing
|
||||
pub trait DrawableTest<V, H, In> 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 handle: Arc<CanvasTextureHandle>
|
||||
}
|
||||
|
||||
impl<V, H: Handle, In> DrawableTest<V, H, In> for DrawableTestee {
|
||||
fn get_vertices(&self) -> Vec<V> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn get_instances(&self) -> Vec<In> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn get_handle(&self) -> H {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
pub trait Drawable {
|
||||
|
||||
fn get_vertices(&self) -> Vec<(f32, f32, f32)>;
|
||||
fn get_color(&self) -> (f32, f32, f32, f32);
|
||||
fn get_ti_coords(&self) -> Vec<(f32, f32)>;
|
||||
|
||||
fn get_texture_handle(&self) -> Option<Arc<CanvasTextureHandle>>;
|
||||
fn get_image_handle(&self) -> Option<Arc<CanvasImageHandle>>;
|
||||
// fn get_text_handle(&self) -> Option<Arc<CanvasTextHandle>>;
|
||||
|
||||
// These needs to return a vector of raw-ass data in addition to the definition for this data
|
||||
fn collect(&self) -> Vec<RuntimeVertexDef> {
|
||||
let color = self.get_color();
|
||||
// self.get_vertices().iter().zip(self.get_ti_coords().iter()).map(|(a, b)|
|
||||
// Vertex3D {
|
||||
// v_position: [a.0, a.1, a.2],
|
||||
// color: [color.0, color.1, color.2, color.3],
|
||||
// ti_position: [b.0, b.1],
|
||||
// }).collect()
|
||||
// TODO
|
||||
vec![RuntimeVertexDef::from_primitive(0)]
|
||||
}
|
||||
}
|
||||
|
||||
pub trait VertexDefinitionAndData {
|
||||
|
||||
}
|
||||
|
||||
pub struct CanvasFrame {
|
||||
pub colored_drawables: Vec<RuntimeVertexDef>,
|
||||
@@ -16,70 +73,6 @@ pub struct CanvasFrame {
|
||||
pub text_drawables: HashMap<Arc<CanvasFontHandle>, Vec<GlyphInstance>>
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
This is sort of the beginning of our interface with the user definable sprites.
|
||||
Will be taking in multiple type of items
|
||||
|
||||
TEXT
|
||||
FontHandle
|
||||
VertexDefintion
|
||||
color
|
||||
position
|
||||
instances (string)
|
||||
Textured
|
||||
TextureHandle
|
||||
VertexDefintion
|
||||
position
|
||||
coords
|
||||
size
|
||||
|
||||
Vertex definition is directly correlated to the compiled code. How do I bucket these
|
||||
|
||||
I guess I could store them and set handles like I do textures
|
||||
|
||||
The only ent that can create these vertex handles is the vkprocessor.
|
||||
So Text can only get a vertex definition by going like shader.get_definition()
|
||||
|
||||
|
||||
Text
|
||||
FontHandle
|
||||
VertexHandle
|
||||
|
||||
|
||||
Drawable must include
|
||||
shader_handle (but how to I get this to the text? this is runtime)
|
||||
|
||||
Okay, no. Maybe a default shader type of setup. With a shader handle override????
|
||||
|
||||
Type: Text
|
||||
Textured
|
||||
Img
|
||||
Color
|
||||
|
||||
frame.draw(text) {
|
||||
|
||||
text.type == TEXT { // When it matches to default text shader
|
||||
text_shader.get_definition()
|
||||
text_shader.get_pipeline()
|
||||
}
|
||||
...
|
||||
else { // When the user passes in a shader
|
||||
text.shader_handle.get_definition()
|
||||
text.shader_handle.get_pipeline()
|
||||
}
|
||||
}
|
||||
|
||||
// Has default shader
|
||||
let text = Text::new("asdoif");
|
||||
|
||||
let frame = CanvasFrame::new();
|
||||
frame.draw(text);
|
||||
|
||||
vkprocessor.run(frame);
|
||||
|
||||
*/
|
||||
|
||||
impl CanvasFrame {
|
||||
|
||||
/// Creates a bare canvas frame with empty accumulators a
|
||||
@@ -92,6 +85,19 @@ impl CanvasFrame {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// pub fn draw_test<V : VertexDefinitionAndData, H: Handle, In>(&mut self, drawable: &dyn DrawableTest<V, H, In>) {
|
||||
// let h = drawable.get_handle();
|
||||
//
|
||||
// let v = drawable.get_vertices();
|
||||
//
|
||||
// let v = v.get(0).unwrap();
|
||||
//
|
||||
// // need to fill up the drawables....
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
// TODO: Fix this for text and fonts
|
||||
/// Accumulates the drawables collected Vertex2D's
|
||||
@@ -118,25 +124,4 @@ impl CanvasFrame {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct GenericCanvasFrame<H, V, In> {
|
||||
frame_data: HashMap<H, Vec<(Vec<V>, Vec<In>)>>
|
||||
}
|
||||
//
|
||||
//impl<V, In> GenericCanvasFrame<Vertex3D, V, In> {
|
||||
//
|
||||
// /// Creates a bare canvas frame with empty accumulators
|
||||
// pub fn new() -> GenericCanvasFrame<Vertex3D, V, In> {
|
||||
// GenericCanvasFrame {
|
||||
// frame_data: Default::default()
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// pub fn draw(&mut self, drawable: &dyn DrawableTest<V, Vertex3D, In>) {
|
||||
// self.frame_data
|
||||
// .entry(drawable.get_handle().clone())
|
||||
// .or_insert(Vec::new())
|
||||
// .push((drawable.get_vertices(), drawable.get_instances()));
|
||||
// }
|
||||
//}
|
||||
}
|
||||
Reference in New Issue
Block a user