#pragma once #include "config/types.h" #include #include #include class TexturePacker { public: using Position = TextureAbsCoord; using Size = TextureAbsCoord; struct Area { #ifndef __cpp_aggregate_paren_init constexpr Area(Position p, Size s) : position {std::move(p)}, size {std::move(s)} { } #endif Position position; Size size; bool operator<(const Area & other) const { return area(size) < area(other.size); } }; using Image = Size; using Space = Area; using Positions = std::vector; using Result = std::pair; TexturePacker(std::span); Result pack(Size) const; Result pack() const; Size minSize() const; static decltype(Size::x) area(const Size & size); private: std::span inputImages; std::vector sortedIndexes; GLsizei maxTextureSize; };