#include "ImageViewer.hpp" namespace MC::Util { void ImageViewer::render(GFX::Actions& actions) { // TODO: Re-add texture support // TODO: Add orthographic camera support actions.add({ .program = GFX::Resources::Program::ImageViewer, .mesh = &m_mesh, .transform = Transform(), }); } GFX::Mesh ImageViewer::create_mesh(Real window_aspect, U32 image_width, U32 image_height) { auto aspect = (Real)image_width / image_height; Real max_size = view_size * 0.8; Real width = max_size * std::min(1.0, aspect); Real height = max_size * std::min(1.0, 1/aspect); Real x = (view_size * window_aspect - width) / 2.0f; Real y = (view_size - height) / 2.0f; return {{ std::vector>{ {x, y, 0.0f}, // top left {x, y + height, 0.0f}, // bottom left {x + width, y + height, 0.0f}, // bottom right {x + width, y, 0.0f} // top right }, std::vector>{ {0.0f, 0.0f}, {0.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, 0.0f}, }, }, {0, 1, 2, 0, 2, 3}}; } }