tirbofish/dropbear · commit
2f038d7e62aeb33bdc2766943bd0729ba3f0ed39
feature: rows and columns + scripting
feature: scripting for rectangles
fix: dpi implemented
Signature present but could not be verified.
Unverified
@@ -1,5 +1,5 @@ -use bytemuck::{Pod, Zeroable}; -use glam::{Mat4, Vec2}; + use bytemuck::{Pod, Zeroable}; +use glam::{Mat4, Vec2, Vec3}; use crate::math::Rect; pub struct Camera2D { @@ -19,15 +19,24 @@ impl Default for Camera2D { impl Camera2D { /// Returns the orthographic view-projection matrix for the current camera state pub fn view_proj(&self, screen_size: Vec2) -> Mat4 { - let width = screen_size.x / self.zoom; - let height = screen_size.y / self.zoom; + let (width, height) = (screen_size.x, screen_size.y); - let left = self.position.x; - let right = self.position.x + width; - let top = self.position.y; - let bottom = self.position.y + height; + let view = Mat4::look_at_rh( + self.position.extend(1.0), + self.position.extend(0.0), + Vec3::Y, + ); - Mat4::orthographic_lh(left, right, bottom, top, -1.0, 1.0) + let proj = Mat4::orthographic_rh( + 0.0, + width, + height, + 0.0, + -1.0, + 1.0, + ); + + proj * view } /// Set the camera's position (top-left corner of view) @@ -0,0 +1,218 @@
Large diffs are not rendered by default. Showing the first 50 of 976 lines. Show full diff