kick
/Users/morten/Programmering/cpp/kick/src/kick/texture/texture_atlas.h
00001 //
00002 // Created by morten on 30/06/14.
00003 //
00004 
00005 #pragma once
00006 #include "kick/core/project_asset.h"
00007 #include "glm/glm.hpp"
00008 #include <map>
00009 #include <memory>
00010 
00011 namespace kick {
00012     class Texture2D;
00013     class TextureAtlas;
00014     class Project;
00015     class Shader;
00016 
00017 
00018     struct TextureAtlasEntry {
00019         bool rotated = false;
00020         bool trimmed = false;
00021         glm::ivec4 frame = glm::ivec4{0};
00022         glm::ivec4 spriteSourceSize = glm::ivec4{0};
00023         glm::ivec2 sourceSize = glm::ivec2{0};
00024     };
00025 
00026     class TextureAtlas : public ProjectAsset  {
00027     public:
00028         TextureAtlas();
00029 
00030         bool load(std::string filename, std::string texture);
00031 
00032         std::shared_ptr<Texture2D> texture() const;
00033         TextureAtlasEntry get(std::string name);
00034         glm::ivec2 textureSize() const;
00035 
00036         std::shared_ptr<Shader> shader() const;
00037         void setShader(std::shared_ptr<Shader> shader);
00038     private:
00039         glm::ivec2 mTextureSize;
00040         std::map<std::string, TextureAtlasEntry> mAtlas;
00041         std::shared_ptr<Texture2D> mTexture;
00042         std::shared_ptr<Shader> mShader;
00043     };
00044 }
 All Classes Functions Variables