From d311a65e0c86aaec94f6d9a61d5f9b374f90aa5c Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Sat, 4 Aug 2018 19:57:19 +0500 Subject: Implemented texture atlas --- src/AssetManager.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/AssetManager.cpp') diff --git a/src/AssetManager.cpp b/src/AssetManager.cpp index 25e9f24..9e360c0 100644 --- a/src/AssetManager.cpp +++ b/src/AssetManager.cpp @@ -603,7 +603,20 @@ AssetTreeNode * AssetManager::GetAssetByAssetName(const std::string & assetName) } void AssetManager::LoadTextures() { - + std::vector textureData; + size_t id = 0; + RecursiveWalkAsset("/minecraft/textures/", [&](AssetTreeNode &node) { + TextureData data; + AssetTexture *textureAsset = dynamic_cast(node.asset.get()); + if (!textureAsset) + return; + data.data = std::move(textureAsset->textureData); + data.width = textureAsset->realWidth; + data.height = textureAsset->realHeight; + textureData.push_back(data); + textureAsset->id = id++; + }); + atlas = std::make_unique(textureData); } void AssetManager::ParseAssetTexture(AssetTreeNode &node) { -- cgit v1.2.3