added hello-world example + modified vkproccessor to live inside specs

This commit is contained in:
2020-08-08 23:38:44 -07:00
parent b070a7dd32
commit c10115e7b9
15 changed files with 150 additions and 102 deletions

View File

@@ -1,11 +1,11 @@
use std::sync::Arc;
use crate::canvas::managed::handles::{CanvasImageHandle, CanvasTextureHandle};
use crate::canvas::canvas_frame::Drawable;
use crate::util::vertex::{VertexType, ImageVertex3D};
use crate::util::vertex::{VertexTypeContainer, ImageVertex3D};
pub struct CompuSprite {
pub verts: VertexType,
pub verts: VertexTypeContainer,
position: (f32, f32),
size: (f32, f32),
@@ -44,7 +44,7 @@ impl CompuSprite {
];
CompuSprite {
verts: VertexType::ImageType(verts, image_handle.clone()),
verts: VertexTypeContainer::ImageType(verts, image_handle.clone()),
position: position,
size: size,
color: (0.0, 0.0, 0.0, 0.0),
@@ -53,7 +53,7 @@ impl CompuSprite {
}
impl Drawable for CompuSprite {
fn get(&self, window_size: (u32, u32)) -> Vec<VertexType> {
fn get(&self, window_size: (u32, u32)) -> Vec<VertexTypeContainer> {
vec![self.verts.clone()]
}
}

View File

@@ -2,14 +2,14 @@ use std::sync::Arc;
use crate::canvas::*;
use crate::canvas::managed::handles::{CanvasFontHandle, CanvasImageHandle, CanvasTextureHandle, Handle};
use crate::canvas::canvas_frame::{Drawable};
use crate::util::vertex::{VertexType, TextureVertex3D, Vertex3D, ColorVertex3D};
use crate::util::vertex::{VertexTypeContainer, TextureVertex3D, Vertex3D, ColorVertex3D};
use crate::drawables::sprite::Sprite;
/// Convex multi verticy polygon
#[derive(Debug, Clone)]
pub struct Polygon {
pub verts: VertexType,
pub verts: VertexTypeContainer,
position: (f32, f32),
size: (f32, f32),
@@ -54,14 +54,14 @@ impl Polygon {
Polygon {
verts: VertexType::ColorType(verts),
verts: VertexTypeContainer::ColorType(verts),
position: position,
size: size,
}
}
}
impl Drawable for Polygon {
fn get(&self, window_size: (u32, u32)) -> Vec<VertexType> {
fn get(&self, window_size: (u32, u32)) -> Vec<VertexTypeContainer> {
vec![self.verts.clone()]
}

View File

@@ -1,5 +1,5 @@
use crate::canvas::canvas_frame::Drawable;
use crate::util::vertex::{VertexType, ColorVertex3D};
use crate::util::vertex::{VertexTypeContainer, ColorVertex3D};
///
#[derive(Debug, Clone)]
@@ -73,9 +73,9 @@ impl Rect {
}
impl Drawable for Rect {
fn get(&self, window_size: (u32, u32)) -> Vec<VertexType> {
fn get(&self, window_size: (u32, u32)) -> Vec<VertexTypeContainer> {
vec![
VertexType::ColorType(
VertexTypeContainer::ColorType(
Rect::generate_vertices(window_size, self.position, self.size, self.depth, self.color)
)
]

View File

@@ -5,7 +5,7 @@ use winit::event::Event;
use crate::canvas::canvas_frame::{Drawable, Eventable};
use crate::drawables::rect::Rect;
use crate::drawables::sprite::Sprite;
use crate::util::vertex::VertexType;
use crate::util::vertex::VertexTypeContainer;
pub struct Slider {
handle: Rect,
@@ -45,14 +45,14 @@ impl Slider {
}
impl Drawable for Slider {
fn get(&self, window_size: (u32, u32)) -> Vec<VertexType> {
fn get(&self, window_size: (u32, u32)) -> Vec<VertexTypeContainer> {
let mut vertices = self.handle.get(window_size).clone();
vertices.extend_from_slice(
self.guide.iter()
.map(|x| x.get(window_size))
.flatten()
.collect::<Vec<VertexType>>()
.collect::<Vec<VertexTypeContainer>>()
.as_slice()
);

View File

@@ -2,7 +2,7 @@ use std::sync::Arc;
use crate::canvas::*;
use crate::canvas::managed::handles::{CanvasFontHandle, CanvasImageHandle, CanvasTextureHandle, Handle};
use crate::canvas::canvas_frame::{Drawable, Eventable, Updatable};
use crate::util::vertex::{VertexType, TextureVertex3D, Vertex3D};
use crate::util::vertex::{VertexTypeContainer, TextureVertex3D, Vertex3D};
use winit::event::{DeviceEvent, MouseButton, ElementState, Event, WindowEvent};
///
@@ -73,9 +73,9 @@ impl Sprite {
}
impl Drawable for Sprite {
fn get(&self, window_size: (u32, u32)) -> Vec<VertexType> {
fn get(&self, window_size: (u32, u32)) -> Vec<VertexTypeContainer> {
vec![
VertexType::TextureType(
VertexTypeContainer::TextureType(
Sprite::generate_verts(window_size, self.position, self.size, self.depth),
self.texture_handle.clone())
]

View File

@@ -1,10 +1,10 @@
use crate::canvas::canvas_frame::Drawable;
use crate::util::vertex::{VertexType, ColorVertex3D};
use crate::util::vertex::{VertexTypeContainer, ColorVertex3D};
///
#[derive(Debug, Clone)]
pub struct Text {
pub verts: VertexType,
pub verts: VertexTypeContainer,
position: (f32, f32),
size: (f32, f32),
@@ -129,7 +129,7 @@ impl Text {
};
Text {
verts: VertexType::TextType(verts),
verts: VertexTypeContainer::TextType(verts),
position: position,
size: size,
}
@@ -137,7 +137,7 @@ impl Text {
}
impl Drawable for Text {
fn get(&self, window_size: (u32, u32)) -> Vec<VertexType> {
fn get(&self, window_size: (u32, u32)) -> Vec<VertexTypeContainer> {
vec![self.verts.clone()]
}
}