lots of refactoring for the dynamic vertex in addition to planning out documentation
This commit is contained in:
@@ -23,7 +23,7 @@ use std::hash::Hash;
|
||||
use crate::canvas::canvas_buffer::{CanvasImage, CanvasTexture, CanvasFont};
|
||||
use crate::util::vertex_3d::{Vertex3D, TextVertex3D};
|
||||
use vulkano::pipeline::depth_stencil::{StencilFaceFlags, DynamicStencilValue};
|
||||
use crate::canvas::shader::common::{CompiledGraphicsPipeline, CompiledGraphicsPipelineHandle};
|
||||
use crate::canvas::shader::common::{CompiledGraphicsPipeline};
|
||||
use crate::canvas::shader::generic_shader::GenericShader;
|
||||
use vulkano::memory::pool::PotentialDedicatedAllocation::Generic;
|
||||
use std::borrow::Borrow;
|
||||
@@ -32,6 +32,8 @@ use std::fs::File;
|
||||
use std::io::Read;
|
||||
use rusttype::{Font, PositionedGlyph, Scale, Rect, point, GlyphId};
|
||||
use vulkano::pipeline::vertex::VertexDefinition;
|
||||
use crate::canvas::{CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle, CompiledGraphicsPipelineHandle};
|
||||
use crate::canvas::shader::dynamic_vertex::RuntimeVertexDef;
|
||||
|
||||
|
||||
// I don't think this is going to work without getting into Box'ing
|
||||
@@ -57,34 +59,20 @@ pub trait Drawable {
|
||||
fn get_image_handle(&self) -> Option<Arc<CanvasImageHandle>>;
|
||||
// fn get_text_handle(&self) -> Option<Arc<CanvasTextHandle>>;
|
||||
|
||||
fn collect(&self) -> Vec<Vertex3D> {
|
||||
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()
|
||||
// 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)]
|
||||
}
|
||||
}
|
||||
|
||||
/// Typed wrapper for a u32 texture handle (index id)
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
|
||||
pub struct CanvasTextureHandle {
|
||||
pub handle: u32
|
||||
}
|
||||
|
||||
/// Typed wrapper for a u32 image handle (index id)
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
|
||||
pub struct CanvasImageHandle {
|
||||
pub handle: u32
|
||||
}
|
||||
|
||||
/// Typed wrapper for a u32 font handle (index id)
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
|
||||
pub struct CanvasFontHandle {
|
||||
pub handle: u32
|
||||
}
|
||||
|
||||
/// 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
|
||||
@@ -100,6 +88,7 @@ pub struct CanvasState {
|
||||
texture_buffers: Vec<Arc<CanvasTexture>>,
|
||||
font_buffers: Vec<Arc<CanvasFont>>,
|
||||
|
||||
// Compiled Graphics pipelines have a handle which self describe their position in this vector
|
||||
shader_buffers: Vec<Arc<Box<dyn CompiledGraphicsPipeline>>>,
|
||||
|
||||
// Hold onto the vertices we get from the Compu and Canvas Frames
|
||||
@@ -455,7 +444,7 @@ impl CanvasState {
|
||||
let g = hprof::enter("Textured Vertex Buffer");
|
||||
for (k, v) in textured_drawables.drain() {
|
||||
let vertex_buffer = v.clone().iter()
|
||||
.fold(Vec::new(), |mut a: Vec<Vertex3D>, b| {
|
||||
.fold(Vec::new(), |mut a: Vec<RuntimeVertexDef>, b| {
|
||||
a.extend(b);
|
||||
a
|
||||
});
|
||||
@@ -476,7 +465,7 @@ impl CanvasState {
|
||||
let g = hprof::enter("Image Vertex Buffer");
|
||||
for (k, v) in image_drawables.drain() {
|
||||
let vertex_buffer = v.clone().iter()
|
||||
.fold(Vec::new(), |mut a: Vec<Vertex3D>, b| {
|
||||
.fold(Vec::new(), |mut a: Vec<&RuntimeVertexDef>, b| {
|
||||
a.extend(b);
|
||||
a
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user