Got the vertex definition into the load function. Which is something
This commit is contained in:
@@ -53,20 +53,44 @@ impl CanvasFrame {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct Pair<T> {
|
||||
x: T,
|
||||
y: T,
|
||||
}
|
||||
|
||||
impl Pair<Vertex3D> {
|
||||
fn new(x: Vertex3D, y: Vertex3D) -> Self {
|
||||
Self {
|
||||
x,
|
||||
y,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Pair<GlyphInstance> {
|
||||
fn new(x: GlyphInstance, y: GlyphInstance) -> Self {
|
||||
Self {
|
||||
x,
|
||||
y,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct GenericCanvasFrame<H, V, In> {
|
||||
frame_data: HashMap<H, Vec<(Vec<V>, Vec<In>)>>
|
||||
}
|
||||
|
||||
impl<H, V, In> GenericCanvasFrame<H, V, In> {
|
||||
impl<V, In> GenericCanvasFrame<Vertex3D, V, In> {
|
||||
|
||||
/// Creates a bare canvas frame with empty accumulators
|
||||
pub fn new() -> GenericCanvasFrame<H, V, In> where H: Eq + Hash {
|
||||
pub fn new() -> GenericCanvasFrame<Vertex3D, V, In> {
|
||||
GenericCanvasFrame {
|
||||
frame_data: Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn draw(&mut self, drawable: &dyn DrawableTest<V, H, In>) where H: Eq + Hash + Clone {
|
||||
pub fn draw(&mut self, drawable: &dyn DrawableTest<V, Vertex3D, In>) {
|
||||
self.frame_data
|
||||
.entry(drawable.get_handle().clone())
|
||||
.or_insert(Vec::new())
|
||||
|
||||
@@ -318,16 +318,17 @@ impl CanvasState {
|
||||
|
||||
/// Load and Compile a shader with the filename at resources/shaders
|
||||
/// Takes physical and capabilities as we don't store that in Canvas
|
||||
pub fn load_shader<T: 'static>(&mut self,
|
||||
pub fn load_shader<T: 'static, V>(&mut self,
|
||||
filename: String,
|
||||
physical: PhysicalDevice,
|
||||
capabilities: Capabilities) -> Option<Arc<CompiledGraphicsPipelineHandle>>
|
||||
where T: CompiledGraphicsPipeline {
|
||||
|
||||
let handle = Arc::new(CompiledGraphicsPipelineHandle {
|
||||
handle: self.shader_buffers.len() as u32
|
||||
});
|
||||
|
||||
let shader: Box<dyn CompiledGraphicsPipeline> = Box::new(T::new(
|
||||
let shader: Box<dyn CompiledGraphicsPipeline> = Box::new(T::new::<V>(
|
||||
filename.clone(),
|
||||
self.device.clone(),
|
||||
handle.clone(),
|
||||
|
||||
@@ -103,7 +103,7 @@ pub struct CompiledGraphicsPipelineHandle {
|
||||
}
|
||||
|
||||
pub trait CompiledGraphicsPipeline {
|
||||
fn new(filename: String,
|
||||
fn new<T>(filename: String,
|
||||
device: Arc<Device>,
|
||||
handle: Arc<CompiledGraphicsPipelineHandle>,
|
||||
render_pass: Arc<dyn RenderPassAbstract + Send + Sync>) -> Self where Self: Sized;
|
||||
|
||||
@@ -39,7 +39,7 @@ impl CompiledGraphicsPipelineResources for GenericShader {}
|
||||
impl CompiledGraphicsPipeline for GenericShader {
|
||||
|
||||
/// This will explode when the shader does not want to compile
|
||||
fn new(filename: String,
|
||||
fn new<T>(filename: String,
|
||||
device: Arc<Device>,
|
||||
handle: Arc<CompiledGraphicsPipelineHandle>,
|
||||
render_pass: Arc<dyn RenderPassAbstract + Send + Sync>) -> GenericShader {
|
||||
@@ -78,7 +78,8 @@ impl CompiledGraphicsPipeline for GenericShader {
|
||||
graphics_pipeline:
|
||||
Some(Arc::new(GraphicsPipeline::start()
|
||||
|
||||
.vertex_input(SingleBufferDefinition::<Vertex3D>::new())
|
||||
//SingleBufferDefinition::<Vertex3D>
|
||||
.vertex_input(T::new())
|
||||
|
||||
.vertex_shader(vertex_entry_point.clone(), ShaderSpecializationConstants {
|
||||
first_constant: 0,
|
||||
|
||||
@@ -45,7 +45,7 @@ impl CompiledGraphicsPipelineResources for TextShader {}
|
||||
impl CompiledGraphicsPipeline for TextShader {
|
||||
|
||||
/// This will explode when the shader does not want to compile
|
||||
fn new(filename: String,
|
||||
fn new<T>(filename: String,
|
||||
device: Arc<Device>,
|
||||
handle: Arc<CompiledGraphicsPipelineHandle>,
|
||||
render_pass: Arc<dyn RenderPassAbstract + Send + Sync>) -> TextShader {
|
||||
@@ -107,8 +107,8 @@ impl CompiledGraphicsPipeline for TextShader {
|
||||
TextShader {
|
||||
graphics_pipeline:
|
||||
Some(Arc::new(GraphicsPipeline::start()
|
||||
|
||||
.vertex_input(OneVertexOneInstanceDefinition::<Vertex3D, GlyphInstance>::new())
|
||||
//OneVertexOneInstanceDefinition::<Vertex3D, GlyphInstance>
|
||||
.vertex_input(T::new())
|
||||
|
||||
.vertex_shader(vertex_entry_point.clone(), ShaderSpecializationConstants {
|
||||
first_constant: 0,
|
||||
|
||||
Reference in New Issue
Block a user