26 constexpr Descriptor(std::string name, std::filesystem::path imagePath,
const glm::uvec2 spriteResolution) noexcept
30 m_RuntimeID(s_NextRuntimeID.fetch_add(1, std::memory_order_relaxed))
35 [[nodiscard]] uint32_t
GetRuntimeID()
const {
return m_RuntimeID; }
38 return m_RuntimeID == other.m_RuntimeID;
43 return std::hash<uint32_t>{}(descriptor.m_RuntimeID);
52 const uint32_t m_RuntimeID{ 0 };
53 inline static std::atomic<uint32_t> s_NextRuntimeID{ 1 };
65 [[nodiscard]]
static std::shared_ptr<SpriteAtlas>
Create(std::string name,
const std::shared_ptr<Image>& image,
const glm::u16vec2 spriteResolution);
91 [[nodiscard]] std::string_view
GetName()
const;
97 [[nodiscard]] std::shared_ptr<Texture2D>
GetTexture()
const;
100 explicit SpriteAtlas(std::string name,
const std::shared_ptr<Image>& image,
const glm::u16vec2 spriteResolution,
const bool success);
103 [[nodiscard]]
static std::shared_ptr<SpriteAtlas>
Create(
const Descriptor& descriptor);
106 uint32_t m_SpriteCount;
107 std::shared_ptr<Texture2D> m_Texture;
108 glm::u16vec2 m_GridDimensions;
110 std::vector<UVs> m_SpriteUVs;
Used when you want to manually control the asset lifetime, loading, preloading, unloading.
const glm::uvec2 m_SpriteResolution
uint32_t GetRuntimeID() const
constexpr bool operator==(const Descriptor &other) const noexcept
const std::filesystem::path m_TexturePath
constexpr Descriptor(std::string name, std::filesystem::path imagePath, const glm::uvec2 spriteResolution) noexcept
Constructs a descriptor.
static std::shared_ptr< SpriteAtlas > Create(std::string name, const std::shared_ptr< Image > &image, const glm::u16vec2 spriteResolution)
Creates a SpriteAtlas.
bool GetSuccessStatus() const
Checks if the SpriteAtlas was created successfully.
const UVs & GetSpriteUVsAtPosition(glm::u16vec2 pos) const
Request the UVs for the spite at specific position.
std::shared_ptr< Texture2D > GetTexture() const
Retrieves the Texture2D stored in the SpriteAtlas.
std::string_view GetName() const
Retrieves the name of the SpriteAtlas.
const UVs & GetSpriteUVsAtIndex(uint32_t index) const
Request the UVs for the spite at specific index.
For InstanceMetrics to work with a type it should derive from this.
Almost everything connected to graphics is in this namespace.
std::size_t operator()(const Descriptor &descriptor) const noexcept