From 79506d6072ad7482ace521cc3a60671e78fd1597 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 14 Apr 2023 01:04:38 +0100 Subject: Reduce texture size determined by packer if non-pot sizes are supported --- assetFactory/texturePacker.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'assetFactory/texturePacker.cpp') diff --git a/assetFactory/texturePacker.cpp b/assetFactory/texturePacker.cpp index 68a6010..30f1c37 100644 --- a/assetFactory/texturePacker.cpp +++ b/assetFactory/texturePacker.cpp @@ -1,7 +1,9 @@ #include "texturePacker.h" #include "collections.hpp" +#include #include #include +#include #include #include #include @@ -55,6 +57,17 @@ TexturePacker::pack(Size size) const } } } + if (GLEW_ARB_texture_non_power_of_two) { + // Crop the size back to minimum size + size = std::transform_reduce( + result.begin(), result.end(), inputImages.begin(), Size {}, + [](auto && max, auto && limit) { + return glm::max(max, limit); + }, + [](auto && pos, auto && size) { + return pos + size; + }); + } return {result, size}; } -- cgit v1.2.3