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.hpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/AssetManager.hpp') diff --git a/src/AssetManager.hpp b/src/AssetManager.hpp index b8748ae..1b64215 100644 --- a/src/AssetManager.hpp +++ b/src/AssetManager.hpp @@ -11,6 +11,7 @@ #include "Vector.hpp" #include "Block.hpp" +#include "TextureAtlas.hpp" class Texture; @@ -160,8 +161,8 @@ struct AssetBlockModel : Asset { struct AssetTexture : Asset { std::vector textureData; - double x, y, w, h; unsigned int realWidth, realHeight; + size_t id; }; class AssetManager { @@ -171,6 +172,7 @@ class AssetManager { std::map textureAtlasIndexes; std::map blockIdToBlockName; std::unique_ptr assetTree; + std::unique_ptr atlas; public: AssetManager(); @@ -219,4 +221,15 @@ public: void LoadTextures(); void ParseAssetTexture(AssetTreeNode &node); + + inline GLuint GetTextureAtlasId() { + return atlas->GetRawTextureId(); + } + + inline TextureCoord GetTexture(const std::string assetName) { + AssetTexture *asset = GetAsset(assetName); + if (!asset) + return {}; + return atlas->GetTexture(asset->id); + } }; -- cgit v1.2.3