1 #ifndef LXGUI_GUI_ATLAS_HPP
2 #define LXGUI_GUI_ATLAS_HPP
4 #include "lxgui/gui_bounds2.hpp"
5 #include "lxgui/gui_material.hpp"
6 #include "lxgui/lxgui.hpp"
7 #include "lxgui/utils.hpp"
12 #include <unordered_map>
53 std::shared_ptr<material>
fetch_material(
const std::string& file_name)
const;
68 std::shared_ptr<font>
fetch_font(
const std::string& font_name)
const;
76 bool add_font(
const std::string& font_name, std::shared_ptr<gui::font> fnt);
91 virtual std::shared_ptr<material>
115 std::optional<bounds2f> find_location_(
float width,
float height)
const;
117 std::unordered_map<std::string, std::weak_ptr<gui::material>> texture_list_;
118 std::unordered_map<std::string, std::weak_ptr<gui::font>> font_list_;
155 std::shared_ptr<material>
fetch_material(
const std::string& file_name)
const;
170 std::shared_ptr<font>
fetch_font(
const std::string& font_name)
const;
178 bool add_font(
const std::string& font_name, std::shared_ptr<gui::font> fnt);
204 std::unique_ptr<atlas_page> page;
205 std::shared_ptr<material> no_texture_mat;
208 std::vector<page_item> page_list_;
A single texture holding multiple materials for efficient rendering.
virtual std::shared_ptr< material > add_material_(const material &mat, const bounds2f &location)=0
Adds a new material to this page, at the provided location.
atlas_page & operator=(const atlas_page &)=delete
Non-copiable.
atlas_page(material::filter filt)
Constructor.
std::shared_ptr< material > add_material(const std::string &file_name, const material &mat)
Creates a new material from a texture file.
std::shared_ptr< font > fetch_font(const std::string &font_name) const
Find a font in this page (nullptr if not found).
virtual ~atlas_page()=default
Destructor.
bool add_font(const std::string &font_name, std::shared_ptr< gui::font > fnt)
Creates a new font from a texture file.
virtual float get_height_() const =0
Return the height of this page (in pixels).
atlas_page & operator=(atlas_page &&)=delete
Non-movable.
atlas_page(atlas_page &&)=delete
Non-movable.
std::shared_ptr< material > fetch_material(const std::string &file_name) const
Find a material in this page (nullptr if not found).
virtual float get_width_() const =0
Return the width of this page (in pixels).
atlas_page(const atlas_page &)=delete
Non-copiable.
bool empty() const
Checks if this page is empty (contains no materials).
A class that holds multiple materials for efficient rendering.
virtual ~atlas()=default
Destructor.
std::size_t get_page_count() const
Return the number of pages in this atlas.
atlas & operator=(const atlas &)=delete
Non-copiable.
atlas(const atlas &)=delete
Non-copiable.
std::shared_ptr< material > add_material(const std::string &file_name, const material &mat)
Add a new material to the atlas.
virtual std::unique_ptr< atlas_page > create_page_()=0
Create a new page in this atlas.
bool add_font(const std::string &font_name, std::shared_ptr< gui::font > fnt)
Add a new font to the atlas.
std::shared_ptr< material > fetch_material(const std::string &file_name) const
Find a material in this atlas (nullptr if not found).
atlas & operator=(atlas &&)=delete
Non-movable.
atlas(atlas &&)=delete
Non-movable.
atlas(renderer &rdr, material::filter filt)
Constructor.
std::shared_ptr< font > fetch_font(const std::string &font_name) const
Find a font in this atlas (nullptr if not found).
A class that holds rendering data.
Abstract type for implementation specific management.