From b90e5c4e0560226695a35444732d646117658ce8 Mon Sep 17 00:00:00 2001 From: Cameron Hart Date: Mon, 17 Aug 2020 12:01:58 +1200 Subject: Upgrade glam to 0.9 & use glam's Mat4 ortho rh gl. --- graphics/Cargo.toml | 2 +- graphics/src/transformation.rs | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) (limited to 'graphics') diff --git a/graphics/Cargo.toml b/graphics/Cargo.toml index 8e078d75..723b9232 100644 --- a/graphics/Cargo.toml +++ b/graphics/Cargo.toml @@ -13,7 +13,7 @@ opengl = [] [dependencies] bytemuck = "1.2" -glam = "0.8" +glam = "0.9" raw-window-handle = "0.3" [dependencies.iced_native] diff --git a/graphics/src/transformation.rs b/graphics/src/transformation.rs index ff3b1d00..2ae74134 100644 --- a/graphics/src/transformation.rs +++ b/graphics/src/transformation.rs @@ -1,4 +1,4 @@ -use glam::{Mat4, Vec3, Vec4}; +use glam::{Mat4, Vec3}; use std::ops::Mul; /// A 2D transformation matrix. @@ -14,12 +14,7 @@ impl Transformation { /// Creates an orthographic projection. #[rustfmt::skip] pub fn orthographic(width: u32, height: u32) -> Transformation { - Transformation(Mat4::from_cols( - Vec4::new(2.0 / width as f32, 0.0, 0.0, 0.0), - Vec4::new(0.0, -2.0 / height as f32, 0.0, 0.0), - Vec4::new(0.0, 0.0, -1.0, 0.0), - Vec4::new(-1.0, 1.0, 0.0, 1.0) - )) + Transformation(Mat4::orthographic_rh_gl(0.0, width as f32, 0.0, height as f32, -1.0, 1.0)) } /// Creates a translate transformation. -- cgit From 02ca90a22d5c4235de4491f840dc9f55f9967618 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 17 Aug 2020 18:11:11 +0200 Subject: Invert Y axis in `Transformation::orthographic` --- graphics/src/transformation.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'graphics') diff --git a/graphics/src/transformation.rs b/graphics/src/transformation.rs index 2ae74134..2a19caed 100644 --- a/graphics/src/transformation.rs +++ b/graphics/src/transformation.rs @@ -14,7 +14,11 @@ impl Transformation { /// Creates an orthographic projection. #[rustfmt::skip] pub fn orthographic(width: u32, height: u32) -> Transformation { - Transformation(Mat4::orthographic_rh_gl(0.0, width as f32, 0.0, height as f32, -1.0, 1.0)) + Transformation(Mat4::orthographic_rh_gl( + 0.0, width as f32, + height as f32, 0.0, + -1.0, 1.0 + )) } /// Creates a translate transformation. -- cgit