removed the colored vertex and combined into one. Half fixed texturing. Fully fixed images and compute swapping

This commit is contained in:
2019-09-10 21:13:48 -07:00
parent e8507f9dfc
commit 9043c2cd3c
13 changed files with 148 additions and 249 deletions

View File

@@ -3,7 +3,9 @@ use std::sync::Arc;
#[derive(Debug, Clone)]
pub struct Sprite {
pub vertices: [(f32, f32); 6],
pub ti_position: [(f32, f32); 6],
position: (f32, f32),
size: (f32, f32),
@@ -37,6 +39,14 @@ impl Sprite {
],
position: position,
ti_position: [
(-1.0, -1.0), // top left
(-1.0, 1.0), // bottom left
( 1.0, 1.0), // bottom right
(-1.0, -1.0), // top left
( 1.0, 1.0), // bottom right
( 1.0, -1.0), // top right
],
size: size,
color: color,
textured: false,
@@ -58,6 +68,14 @@ impl Sprite {
(position.0 + fsize.0, position.1 ), // top right
],
position: position,
ti_position: [
(-1.0, -1.0), // top left
(-1.0, 1.0), // bottom left
( 1.0, 1.0), // bottom right
(-1.0, -1.0), // top left
( 1.0, 1.0), // bottom right
( 1.0, -1.0), // top right
],
size: size,
color: (0.0, 0.0, 0.0, 0.0),
textured: true,
@@ -78,6 +96,10 @@ impl Drawable for Sprite {
self.color.clone()
}
fn get_ti_coords(&self) -> Vec<(f32, f32)> {
self.ti_position.to_vec()
}
fn get_texture_handle(&self) -> Option<Arc<CanvasTextureHandle>> {
match self.textured {
true => {