Piping just the vertex glyph representation first to test the stencil buffer
This commit is contained in:
133
src/drawables/text.rs
Normal file
133
src/drawables/text.rs
Normal file
@@ -0,0 +1,133 @@
|
||||
use crate::canvas::canvas_frame::Drawable;
|
||||
use crate::util::vertex::{VertexTypes, ColorVertex3D};
|
||||
|
||||
///
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Text {
|
||||
pub verts: VertexTypes,
|
||||
|
||||
position: (f32, f32),
|
||||
size: (f32, f32),
|
||||
}
|
||||
|
||||
/// Container class which implements drawable.
|
||||
impl Text {
|
||||
///
|
||||
pub fn new(position: (f32, f32),
|
||||
size: (f32, f32),
|
||||
depth: u32) -> Text {
|
||||
let normalized_depth = (depth as f32 / 255.0);
|
||||
|
||||
let verts = {
|
||||
vec![
|
||||
ColorVertex3D {
|
||||
v_position: [-0.5, -0.5, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-1.0, 1.0, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-0.25, 0.0, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-0.25, 0.0, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-1.0, 1.0, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.0, 0.5, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.25, 0.0, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-1.0, 1.0, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.0, 0.5, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.5, -0.5, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-1.0, 1.0, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.25, 0.0, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.25, -0.5, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-1.0, 1.0, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.5, -0.5, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.25, -0.5, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-1.0, 1.0, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.0, -0.1, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-0.25, -0.5, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-1.0, 1.0, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.0, -0.1, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-0.5, -0.5, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-1.0, 1.0, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-0.25, -0.5, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
}]
|
||||
};
|
||||
|
||||
Text {
|
||||
verts: VertexTypes::ColorType(verts),
|
||||
position: position,
|
||||
size: size,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drawable for Text {
|
||||
fn get(&self) -> VertexTypes {
|
||||
self.verts.clone()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user