Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/rendering/StarFontTextureGroup.hpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-06-20 14:33:09 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-06-20 14:33:09 +1000
commit6352e8e3196f78388b6c771073f9e03eaa612673 (patch)
treee23772f79a7fbc41bc9108951e9e136857484bf4 /source/rendering/StarFontTextureGroup.hpp
parent6741a057e5639280d85d0f88ba26f000baa58f61 (diff)
everything everywhere
all at once
Diffstat (limited to 'source/rendering/StarFontTextureGroup.hpp')
-rw-r--r--source/rendering/StarFontTextureGroup.hpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/source/rendering/StarFontTextureGroup.hpp b/source/rendering/StarFontTextureGroup.hpp
new file mode 100644
index 0000000..d933f1e
--- /dev/null
+++ b/source/rendering/StarFontTextureGroup.hpp
@@ -0,0 +1,40 @@
+#ifndef STAR_FONT_TEXTURE_GROUP_HPP
+#define STAR_FONT_TEXTURE_GROUP_HPP
+
+#include "StarColor.hpp"
+#include "StarFont.hpp"
+#include "StarRenderer.hpp"
+
+namespace Star {
+
+STAR_CLASS(FontTextureGroup);
+
+class FontTextureGroup {
+public:
+ FontTextureGroup(FontPtr font, TextureGroupPtr textureGroup);
+
+ TexturePtr glyphTexture(String::Char, unsigned fontSize);
+ TexturePtr glyphTexture(String::Char, unsigned fontSize, String const& processingDirectives);
+
+ unsigned glyphWidth(String::Char c, unsigned fontSize);
+
+ // Removes glyphs that haven't been used in more than the given time in
+ // milliseconds
+ void cleanup(int64_t timeout);
+
+private:
+ typedef tuple<String::Char, unsigned, String> GlyphDescriptor;
+
+ struct GlyphTexture {
+ TexturePtr texture;
+ int64_t time;
+ };
+
+ FontPtr m_font;
+ TextureGroupPtr m_textureGroup;
+ HashMap<GlyphDescriptor, GlyphTexture> m_glyphs;
+};
+
+}
+
+#endif