Render colored quads

This commit is contained in:
Héctor Ramón Jiménez 2019-10-07 03:56:16 +02:00
parent 70c17b053b
commit c9510db551
13 changed files with 396 additions and 6 deletions

View file

@ -0,0 +1,30 @@
#[derive(Debug, Clone, Copy)]
pub struct Transformation([f32; 16]);
impl Transformation {
#[rustfmt::skip]
pub fn identity() -> Self {
Transformation([
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0,
])
}
#[rustfmt::skip]
pub fn orthographic(width: u16, height: u16) -> Self {
Transformation([
2.0 / width as f32, 0.0, 0.0, 0.0,
0.0, 2.0 / height as f32, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
-1.0, -1.0, 0.0, 1.0,
])
}
}
impl From<Transformation> for [f32; 16] {
fn from(transformation: Transformation) -> [f32; 16] {
transformation.0
}
}