Going to just normalize to a single hardcoded enum of vertex definitions. Seems like quite a backpeddle....
This commit is contained in:
76
src/main.rs
76
src/main.rs
@@ -25,10 +25,11 @@ use crate::util::load_raw;
|
||||
use crate::sprite::{Poly, Text, TextHandle, TextVertex, TextInstance};
|
||||
use vulkano::instance::debug::DebugCallback;
|
||||
use crate::compute::compu_frame::CompuFrame;
|
||||
use crate::canvas::canvas_frame::{CanvasFrame, CanvasFrameTest};
|
||||
use crate::canvas::canvas_frame::{CanvasFrame, CanvasFrameTest, DrawableTest};
|
||||
use crate::compute::managed::compu_sprite::CompuSprite;
|
||||
use std::sync::Arc;
|
||||
use crate::canvas::managed::handles::CanvasTextureHandle;
|
||||
use crate::canvas::managed::handles::{CanvasTextureHandle, Handle};
|
||||
use crate::canvas::canvas_frame::dynhash::DynHash;
|
||||
|
||||
|
||||
pub mod util;
|
||||
@@ -55,22 +56,48 @@ pub mod compute;
|
||||
|
||||
|
||||
*/
|
||||
pub struct ImplVertexData1 {
|
||||
pub x: i32,
|
||||
pub y: i32,
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct TextureVertex2D {
|
||||
pub v_position: [f32; 2],
|
||||
pub ti_position: [f32; 2],
|
||||
}
|
||||
vulkano::impl_vertex!(TextureVertex2D, v_position, ti_position);
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ColorVertex2D {
|
||||
pub v_position: [f32; 2],
|
||||
pub color: [f32; 4],
|
||||
}
|
||||
vulkano::impl_vertex!(ColorVertex2D, v_position, color);
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ImageVertex2D {
|
||||
pub v_position: [f32; 2],
|
||||
pub color: [f32; 4],
|
||||
}
|
||||
vulkano::impl_vertex!(ImageVertex2D, v_position, color);
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum VertexTypes {
|
||||
TextureType(Vec<TextureVertex2D>),
|
||||
ColorType(Vec<ColorVertex2D>),
|
||||
ImageType(Vec<ImageVertex2D>),
|
||||
}
|
||||
|
||||
pub struct ImplVertexData2 {
|
||||
pub x: i32,
|
||||
pub y: i32,
|
||||
pub struct DrawableTestee {
|
||||
vertices: VertexTypes,
|
||||
handle: Arc<CanvasTextureHandle>,
|
||||
}
|
||||
|
||||
impl ImplVertexData1 {}
|
||||
impl ImplVertexData2 {}
|
||||
impl<VTypes: Into<VertexTypes>, H: Handle + DynHash> DrawableTest<VTypes, H> for DrawableTestee {
|
||||
fn get_vertices(&self) -> VTypes {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
enum VertexTypes {
|
||||
VType1(ImplVertexData1),
|
||||
VType2(ImplVertexData2),
|
||||
fn get_handle(&self) -> H {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
@@ -199,27 +226,30 @@ pub fn main() {
|
||||
break;
|
||||
}
|
||||
|
||||
// let dt = DrawableTestee{
|
||||
// vertices: vec![ImplVertexData{ x: 0, y: 0 }],
|
||||
// handle: Arc::new(CanvasTextureHandle{ handle: 0 })
|
||||
// };
|
||||
let mut cft : CanvasFrameTest<VertexTypes> =
|
||||
let sprite = Sprite::new((0.0,0.0), (0.0,0.0));
|
||||
|
||||
let dt = DrawableTestee {
|
||||
vertices: VertexTypes::TexturedType(vec![ImplVertexData1 {x:0,y:0}]),
|
||||
handle: Arc::new(CanvasTextureHandle{ handle: 0 })
|
||||
};
|
||||
let mut canvas_frame : CanvasFrameTest<VertexTypes> =
|
||||
CanvasFrameTest{ map: Default::default() };
|
||||
|
||||
// cft.draw(&dt);
|
||||
canvas_frame.draw(dt.vertices);
|
||||
canvas_frame.draw(sprite.get_vertices());
|
||||
|
||||
let mut compu_frame = CompuFrame::new();
|
||||
// compu_frame.add(compute_buffer.clone(), compute_kernel.clone());
|
||||
// compu_frame.add_with_image_swap(compute_buffer.clone(), compute_kernel.clone(), &compu_sprite1);
|
||||
//
|
||||
let mut canvas = CanvasFrame::new();
|
||||
canvas.draw(&funky_sprite);
|
||||
canvas.draw(&test_polygon);
|
||||
// let mut canvas = CanvasFrame::new();
|
||||
// canvas.draw(&funky_sprite);
|
||||
// canvas.draw(&test_polygon);
|
||||
|
||||
{
|
||||
let g = hprof::enter("Run");
|
||||
processor.run(&surface,
|
||||
canvas,
|
||||
canvas_frame,
|
||||
compu_frame);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user