#ifndef GRAPHICS_CORE_ATLAS_HPP_ #define GRAPHICS_CORE_ATLAS_HPP_ #include #include #include #include #include #include "../../maths/UVRegion.hpp" #include "../../typedefs.hpp" class ImageData; class Texture; class Atlas { std::unique_ptr texture; std::unique_ptr image; std::unordered_map regions; public: /// @param image atlas raster /// @param regions atlas regions /// @param prepare generate texture (.prepare()) Atlas( std::unique_ptr image, std::unordered_map regions, bool prepare ); ~Atlas(); void prepare(); bool has(const std::string& name) const; const UVRegion& get(const std::string& name) const; Texture* getTexture() const; ImageData* getImage() const; }; struct atlasentry { std::string name; std::shared_ptr image; }; class AtlasBuilder { std::vector entries; std::set names; public: AtlasBuilder() {} void add(const std::string& name, std::unique_ptr image); bool has(const std::string& name) const; const std::set& getNames() { return names; }; /// @brief Build atlas from all added images /// @param extrusion textures extrusion pixels /// (greather is less mip-mapping artifacts) /// @param prepare generate atlas texture (calls .prepare()) /// @param maxResolution max atlas resolution std::unique_ptr build(uint extrusion, bool prepare=true, uint maxResolution=0); }; #endif // GRAPHICS_CORE_ATLAS_HPP_