diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-01-02 01:32:02 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-01-02 01:32:02 +0000 |
commit | cf64ce9a1312de5e9a76bb3f43105a4eac59eb15 (patch) | |
tree | 7ddf3d3bfc7a7add7a8eacde3862206cd2fd5ec4 /ui/font.h | |
parent | Cache allows multiple key parts (diff) | |
download | ilt-cf64ce9a1312de5e9a76bb3f43105a4eac59eb15.tar.bz2 ilt-cf64ce9a1312de5e9a76bb3f43105a4eac59eb15.tar.xz ilt-cf64ce9a1312de5e9a76bb3f43105a4eac59eb15.zip |
Use Cache system to persist font rendering for Text
Diffstat (limited to 'ui/font.h')
-rw-r--r-- | ui/font.h | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -3,17 +3,21 @@ #include <GL/glew.h> #include <array> +#include <cache.h> #include <cstddef> #include <cstdint> +#include <filesystem> +#include <glArrays.h> #include <glm/glm.hpp> #include <map> -#include <string> #include <string_view> #include <vector> class Font { public: - Font(const char * const path, unsigned int height); + static Cache<Font, std::filesystem::path, unsigned int> cachedFontRenderings; + + Font(std::filesystem::path path, unsigned int height); using Quad = std::array<glm::vec4, 4>; using Quads = std::vector<Quad>; @@ -28,7 +32,7 @@ public: long advance; }; struct FontTexture { - GLuint texture; + glTexture texture; unsigned int used; }; @@ -39,7 +43,7 @@ protected: const CharData getChar(char) const; std::size_t getTextureWithSpace(unsigned int adv) const; - std::string path; + std::filesystem::path path; glm::uvec3 size; mutable std::map<uint32_t, CharData> charsData; mutable std::vector<FontTexture> fontTextures; |