summaryrefslogtreecommitdiff
path: root/ui/font.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-01-02 01:32:02 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2022-01-02 01:32:02 +0000
commitcf64ce9a1312de5e9a76bb3f43105a4eac59eb15 (patch)
tree7ddf3d3bfc7a7add7a8eacde3862206cd2fd5ec4 /ui/font.h
parentCache allows multiple key parts (diff)
downloadilt-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.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/ui/font.h b/ui/font.h
index c9d834a..4b44ee3 100644
--- a/ui/font.h
+++ b/ui/font.h
@@ -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;