diagramming out what I want to do here. CanvasFont will live with the buffers. Need to figure out how and where I'm going to query the font data for rendering
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use crate::canvas::canvas_state::{Drawable, CanvasTextureHandle, CanvasImageHandle};
|
||||
use crate::canvas::canvas_state::{Drawable, CanvasTextureHandle, CanvasImageHandle, DrawableTest};
|
||||
use std::sync::Arc;
|
||||
use crate::canvas::shader::text_shader::GlyphInstance;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Sprite {
|
||||
@@ -14,6 +15,7 @@ pub struct Sprite {
|
||||
textured: bool,
|
||||
texture_handle: Option<Arc<CanvasTextureHandle>>,
|
||||
|
||||
value: GlyphInstance,
|
||||
}
|
||||
|
||||
/// Container class which implements drawable.
|
||||
@@ -52,7 +54,13 @@ impl Sprite {
|
||||
size: size,
|
||||
color: color,
|
||||
textured: false,
|
||||
texture_handle: None
|
||||
texture_handle: None,
|
||||
value: GlyphInstance {
|
||||
screen_position: (0.0, 0.0),
|
||||
atlas_position: (0.0, 0.0),
|
||||
atlas_size: (0.0, 0.0),
|
||||
scale: 0.0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,6 +101,16 @@ impl Sprite {
|
||||
|
||||
}
|
||||
|
||||
impl<V, H> DrawableTest<V, H> for Sprite {
|
||||
fn get_vertices(&self) -> Vec<V> {
|
||||
|
||||
}
|
||||
|
||||
fn get_handle(&self) -> Vec<H> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drawable for Sprite {
|
||||
|
||||
fn get_vertices(&self) -> Vec<(f32,f32,f32)> {
|
||||
@@ -135,6 +153,9 @@ pub struct Poly {
|
||||
textured: bool,
|
||||
texture_handle: Option<Arc<CanvasTextureHandle>>,
|
||||
|
||||
// ==================================
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// Container class which implements drawable.
|
||||
@@ -248,3 +269,77 @@ impl Drawable for Poly {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Poly {
|
||||
|
||||
pub vertices: Vec<(f32, f32, f32)>,
|
||||
pub ti_position: Vec<(f32, f32)>,
|
||||
|
||||
position: (f32, f32),
|
||||
size: (f32, f32),
|
||||
color: (f32, f32, f32, f32),
|
||||
|
||||
textured: bool,
|
||||
texture_handle: Option<Arc<CanvasTextureHandle>>,
|
||||
|
||||
// ==================================
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// Container class which implements drawable.
|
||||
impl Poly {
|
||||
|
||||
pub fn new(position: (f32, f32), size: (f32, f32)) -> Poly {
|
||||
Poly::new_with_color(position, size, 0, (0.,0.,0.,0.))
|
||||
}
|
||||
|
||||
pub fn new_with_color(position: (f32, f32),
|
||||
size: (f32, f32),
|
||||
depth: u32,
|
||||
color: (f32, f32, f32, f32)) -> Poly {
|
||||
|
||||
let normalized_depth = (depth as f32 / 255.0);
|
||||
|
||||
Poly {
|
||||
vertices: vec![],
|
||||
|
||||
position: position,
|
||||
ti_position: vec![],
|
||||
size: size,
|
||||
color: color,
|
||||
textured: false,
|
||||
texture_handle: None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drawable for Poly {
|
||||
|
||||
fn get_vertices(&self) -> Vec<(f32,f32,f32)> {
|
||||
self.vertices.to_vec()
|
||||
}
|
||||
|
||||
fn get_color(&self) -> (f32, f32, f32, f32) {
|
||||
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 => {
|
||||
self.texture_handle.clone()
|
||||
},
|
||||
false => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn get_image_handle(&self) -> Option<Arc<CanvasImageHandle>> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user