going to save here. re-evaluating drawable now that runtimevertexdef is in

This commit is contained in:
2020-02-05 20:02:06 -08:00
parent 1fde36e42c
commit 0c1f513225
16 changed files with 166 additions and 198 deletions

View File

@@ -29,48 +29,14 @@ use std::io::Read;
use rusttype::{Font, PositionedGlyph, Scale, Rect, point, GlyphId, Line, Curve, Segment};
use vulkano::pipeline::vertex::VertexDefinition;
use crate::canvas::managed::shader::dynamic_vertex::RuntimeVertexDef;
use crate::canvas::managed::handles::{CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle, CompiledGraphicsPipelineHandle, Handle};
use crate::canvas::managed::handles::{CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle, CompiledShaderHandle, Handle};
use crate::canvas::managed::gpu_buffers::{CanvasImage, CanvasTexture, CanvasFont};
use crate::canvas::managed::shader::shader_common::CompiledGraphicsPipeline;
use crate::canvas::managed::shader::generic_shader::GenericShader;
// I don't think this is going to work without getting into Box'ing
pub trait DrawableTest<V, H, In> {
fn get_vertices(&self) -> Vec<V>;
fn get_instances(&self) -> Vec<In>;
fn get_handle(&self) -> H;
}
/// A drawable object can be passed into a CanvasFrame to be rendered
/// Very generic implementation. (N % 2 == 0) vertices, ditto for texture coords, and rgba color
/// Provides Image and Texture handles for drawing
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>>;
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)]
}
}
/// Canvas state is used for storage of texture and image buffers in addition to vertex buffers
/// Canvas state also contains logic for writing the stored buffers to the command_buffer
#[derive(Clone)]
@@ -308,10 +274,10 @@ impl CanvasState {
pub fn load_shader<T: 'static>(&mut self,
filename: String,
physical: PhysicalDevice,
capabilities: Capabilities) -> Option<Arc<CompiledGraphicsPipelineHandle>>
capabilities: Capabilities) -> Option<Arc<CompiledShaderHandle>>
where T: CompiledGraphicsPipeline {
let handle = Arc::new(CompiledGraphicsPipelineHandle {
let handle = Arc::new(CompiledShaderHandle {
handle: self.shader_buffers.len() as u32
});
@@ -396,7 +362,7 @@ impl CanvasState {
/// Using the shader name, iterates through the stored shaders and matches by the name
pub fn get_shader_handle(&self, shader_name: String)
-> Option<Arc<CompiledGraphicsPipelineHandle>> {
-> Option<Arc<CompiledShaderHandle>> {
for shader in self.shader_buffers.clone() {
if shader.get_name() == shader_name {
return Some(shader.get_handle().clone());