summaryrefslogtreecommitdiff
path: root/assetFactory/assetFactory.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-03-15 02:10:31 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-03-15 02:10:31 +0000
commitac90f8e60b1c971c342cdd98769388563e157557 (patch)
tree87b0092c13be552aed47fb2b15bdd87b007f0247 /assetFactory/assetFactory.cpp
parentTexture member to save the texture as a TGA (diff)
downloadilt-ac90f8e60b1c971c342cdd98769388563e157557.tar.bz2
ilt-ac90f8e60b1c971c342cdd98769388563e157557.tar.xz
ilt-ac90f8e60b1c971c342cdd98769388563e157557.zip
Populate super texture with fragments
This is kinda buggy due to TexturePacker sorting its input array and the client having no idea the order of the results.
Diffstat (limited to 'assetFactory/assetFactory.cpp')
-rw-r--r--assetFactory/assetFactory.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/assetFactory/assetFactory.cpp b/assetFactory/assetFactory.cpp
index 276c258..77dd554 100644
--- a/assetFactory/assetFactory.cpp
+++ b/assetFactory/assetFactory.cpp
@@ -118,21 +118,25 @@ AssetFactory::createTexutre() const
});
const auto [layout, outSize] = TexturePacker {imageSizes}.pack();
// * create texture
- std::vector<glm::u8vec4> textureData(TexturePacker::area(outSize), {127, 127, 127, 255});
+ texture = std::make_shared<Texture>(outSize.x, outSize.y, TextureOptions {.wrap = GL_CLAMP_TO_EDGE});
std::transform(textureFragments.begin(), textureFragments.end(),
std::inserter(textureFragmentPositions, textureFragmentPositions.end()),
- [position = layout.begin(), size = imageSizes.begin(), outSize = outSize](const auto & tf) mutable {
- const glm::vec4 positionFraction {
- static_cast<float>(position->x) / static_cast<float>(outSize.x),
- static_cast<float>(position->y) / static_cast<float>(outSize.y),
- static_cast<float>(position->x + size->x) / static_cast<float>(outSize.x),
- static_cast<float>(position->y + size->y) / static_cast<float>(outSize.y),
+ [position = layout.begin(), image = images.begin(), size = imageSizes.begin(),
+ outSize = glm::vec2 {outSize}](const auto & tf) mutable {
+ glm::vec4 positionFraction {
+ static_cast<float>(position->x) / outSize.x,
+ static_cast<float>(position->y) / outSize.y,
+ static_cast<float>(position->x + size->x) / outSize.x,
+ static_cast<float>(position->y + size->y) / outSize.y,
};
+ glTexSubImage2D(GL_TEXTURE_2D, 0, static_cast<GLint>(position->x), static_cast<GLint>(position->y),
+ static_cast<GLint>(size->x), static_cast<GLint>(size->y), GL_RGBA, GL_UNSIGNED_BYTE,
+ image->get()->data.data());
position++;
+ image++;
size++;
return decltype(textureFragmentPositions)::value_type {tf.first, positionFraction};
});
- texture = std::make_shared<Texture>(outSize.x, outSize.y, textureData.data());
}
}