/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* text_library.h :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/04/10 11:52:30 by maldavid #+# #+# */ /* Updated: 2023/04/12 11:38:57 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef __MLX_TEXT_LIBRARY__ #define __MLX_TEXT_LIBRARY__ #include #include #include #include #include #include #include namespace mlx { using TextID = uint32_t; constexpr TextID nulltext = 0; class TextData { public: TextData() = default; void init(std::string text, std::vector vbo_data, std::vector ibo_data); void bind(class Renderer& renderer) noexcept; inline uint32_t getIBOsize() noexcept { return _ibo.getSize(); } inline const std::string& getText() const { return _text; } void destroy() noexcept; ~TextData() = default; private: C_VBO _vbo; C_IBO _ibo; std::string _text; }; class TextLibrary { public: TextLibrary() = default; std::shared_ptr getTextData(TextID id); TextID addTextToLibrary(std::shared_ptr text); void removeTextFromLibrary(TextID id); void clearLibrary(); ~TextLibrary() = default; private: std::unordered_map> _cache; TextID _current_id = 1; }; } #endif