summaryrefslogtreecommitdiff
path: root/assetFactory/assetFactory.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-04-14 14:48:59 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-04-14 14:48:59 +0100
commit1cdd7753d37bcf8f626298c3df97a02cc73f266c (patch)
treef8e83df70e00c9f7f3588638c756ac66a8ab0199 /assetFactory/assetFactory.cpp
parentCurrent thread partakes in work effort while waiting (diff)
downloadilt-1cdd7753d37bcf8f626298c3df97a02cc73f266c.tar.bz2
ilt-1cdd7753d37bcf8f626298c3df97a02cc73f266c.tar.xz
ilt-1cdd7753d37bcf8f626298c3df97a02cc73f266c.zip
Load texture images in Worker
Diffstat (limited to 'assetFactory/assetFactory.cpp')
-rw-r--r--assetFactory/assetFactory.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/assetFactory/assetFactory.cpp b/assetFactory/assetFactory.cpp
index 46b4642..e27e575 100644
--- a/assetFactory/assetFactory.cpp
+++ b/assetFactory/assetFactory.cpp
@@ -99,21 +99,25 @@ AssetFactory::createTexutre() const
{
if (!textureFragments.empty() && !texture) {
// * layout images
- std::vector<TexturePacker::Image> imageSizes;
+ std::map<std::string_view, std::unique_ptr<const Image>> images;
std::transform(
- textureFragments.begin(), textureFragments.end(), std::back_inserter(imageSizes), [](const auto & tf) {
- return TexturePacker::Image {tf.second->image->width, tf.second->image->height};
+ textureFragments.begin(), textureFragments.end(), std::inserter(images, images.end()), [](auto && tf) {
+ return decltype(images)::value_type {tf.first, tf.second->image->get()};
});
+ std::vector<TexturePacker::Image> imageSizes;
+ std::transform(images.begin(), images.end(), std::back_inserter(imageSizes), [](const auto & i) {
+ return TexturePacker::Image {i.second->width, i.second->height};
+ });
const auto [layout, outSize] = TexturePacker {imageSizes}.pack();
// * create texture
texture = std::make_shared<TextureAtlas>(outSize.x, outSize.y, layout.size());
- std::transform(textureFragments.begin(), textureFragments.end(),
+ std::transform(images.begin(), images.end(),
std::inserter(textureFragmentPositions, textureFragmentPositions.end()),
- [position = layout.begin(), size = imageSizes.begin(), this](const auto & tf) mutable {
- const auto m = texture->add(*position, *size, tf.second->image->data.data());
+ [position = layout.begin(), size = imageSizes.begin(), this](const auto & i) mutable {
+ const auto m = texture->add(*position, *size, i.second->data.data());
position++;
size++;
- return decltype(textureFragmentPositions)::value_type {tf.first, m};
+ return decltype(textureFragmentPositions)::value_type {i.first, m};
});
}
}