summaryrefslogtreecommitdiff
path: root/assetFactory
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-04-14 01:04:38 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-04-14 01:04:38 +0100
commit79506d6072ad7482ace521cc3a60671e78fd1597 (patch)
tree93039f2c30404b823fbe83583032d0a4e3920b80 /assetFactory
parentMerge branch 'materials' into assimp (diff)
downloadilt-79506d6072ad7482ace521cc3a60671e78fd1597.tar.bz2
ilt-79506d6072ad7482ace521cc3a60671e78fd1597.tar.xz
ilt-79506d6072ad7482ace521cc3a60671e78fd1597.zip
Reduce texture size determined by packer if non-pot sizes are supported
Diffstat (limited to 'assetFactory')
-rw-r--r--assetFactory/texturePacker.cpp13
1 files changed, 13 insertions, 0 deletions
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 <GL/glew.h>
#include <algorithm>
#include <cstdio>
+#include <glm/common.hpp>
#include <numeric>
#include <ostream>
#include <set>
@@ -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};
}