rust/lib-hedgewars-engine/src/render/camera.rs
changeset 14739 5915a199cb81
parent 14730 65c971417780
child 15141 febccab419b1
--- a/rust/lib-hedgewars-engine/src/render/camera.rs	Sat Mar 23 03:44:11 2019 +0300
+++ b/rust/lib-hedgewars-engine/src/render/camera.rs	Sun Mar 24 20:11:55 2019 +0300
@@ -34,4 +34,31 @@
             self.position.y + half_height,
         )
     }
+
+    pub fn projection(&self) -> [f32; 16] {
+        let viewport = self.viewport();
+        let left = viewport.left() as f32;
+        let width = viewport.width() as f32;
+        let height = viewport.height() as f32;
+        let top = viewport.top() as f32;
+
+        [
+            2f32 / width,
+            0f32,
+            0f32,
+            0f32,
+            0f32,
+            2f32 / -height,
+            0f32,
+            0f32,
+            0f32,
+            0f32,
+            0.5f32,
+            0f32,
+            -(2.0 * left + width) / width,
+            (2.0 * top + height) / height,
+            0.5f32,
+            1f32,
+        ]
+    }
 }