// Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once #ifndef NAZARA_TEXTSPRITE_HPP #define NAZARA_TEXTSPRITE_HPP #include #include #include #include #include #include #include #include class NzTextSprite; using NzTextSpriteConstRef = NzObjectRef; using NzTextSpriteLibrary = NzObjectLibrary; using NzTextSpriteRef = NzObjectRef; class NAZARA_API NzTextSprite : public NzRenderable { public: NzTextSprite(); NzTextSprite(const NzTextSprite& sprite); ~NzTextSprite() = default; void AddToRenderQueue(NzAbstractRenderQueue* renderQueue, const InstanceData& instanceData) const override; void Clear(); NzTextSprite* Clone() const; NzTextSprite* Create() const; const NzColor& GetColor() const; NzMaterial* GetMaterial() const; float GetScale() const; void InvalidateVertices(); bool IsDrawable() const; void SetColor(const NzColor& color); void SetDefaultMaterial(); void SetMaterial(NzMaterial* material); void SetScale(float scale); void Update(const NzAbstractTextDrawer& drawer); NzTextSprite& operator=(const NzTextSprite& text); template static NzTextSpriteRef New(Args&&... args); private: void MakeBoundingVolume() const override; void OnAtlasInvalidated(const NzAbstractAtlas* atlas); void OnAtlasLayerChange(const NzAbstractAtlas* atlas, NzAbstractImage* oldLayer, NzAbstractImage* newLayer); void UpdateData(InstanceData* instanceData) const override; struct RenderIndices { unsigned int first; unsigned int count; }; struct AtlasSlots { NazaraSlot(NzAbstractAtlas, OnAtlasCleared, clearSlot); NazaraSlot(NzAbstractAtlas, OnAtlasLayerChange, layerChangeSlot); NazaraSlot(NzAbstractAtlas, OnAtlasRelease, releaseSlot); }; std::unordered_map m_atlases; mutable std::unordered_map m_renderInfos; mutable std::vector m_localVertices; NzColor m_color; NzMaterialRef m_material; NzRectui m_localBounds; mutable bool m_verticesUpdated; float m_scale; static NzTextSpriteLibrary::LibraryMap s_library; }; #include #endif // NAZARA_TEXTSPRITE_HPP