From 27e590f716f063f603e170f6fc9dd66b8fc099ff Mon Sep 17 00:00:00 2001 From: Mel Date: Fri, 7 Jul 2023 23:06:04 +0200 Subject: Fix Util::ImageViewer on aspect other than 1 --- src/Util/ImageViewer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Util/ImageViewer.cpp') diff --git a/src/Util/ImageViewer.cpp b/src/Util/ImageViewer.cpp index f94ccd0..9720408 100644 --- a/src/Util/ImageViewer.cpp +++ b/src/Util/ImageViewer.cpp @@ -20,7 +20,7 @@ ImageViewer::ImageViewer( model_uniform.set(Math::MVP::model({}, {})); view_uniform.set(Math::MVP::view({}, {})); - projection_uniform.set(Math::MVP::orthographic_projection(1000 * window_aspect, 1000, 0.0f, 100.0f)); + projection_uniform.set(Math::MVP::orthographic_projection(view_size * window_aspect, view_size, 0.0f, 100.0f)); m_program.unbind(); } @@ -37,12 +37,12 @@ void ImageViewer::render() const { GFX::Mesh ImageViewer::create_mesh(float window_aspect, uint32_t image_width, uint32_t image_height) { auto aspect = (float)image_width / image_height; - float max_size = 500.0f; + float max_size = view_size * 0.8f; float width = max_size * std::min(1.0f, aspect); float height = max_size * std::min(1.0f, 1/aspect); - float x = max_size * window_aspect - width / 2.0f; - float y = max_size - height / 2.0f; + float x = (view_size * window_aspect - width) / 2.0f; + float y = (view_size - height) / 2.0f; return {{ std::vector>{ -- cgit 1.4.1