From cf64ce9a1312de5e9a76bb3f43105a4eac59eb15 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 2 Jan 2022 01:32:02 +0000 Subject: Use Cache system to persist font rendering for Text --- ui/font.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'ui/font.cpp') diff --git a/ui/font.cpp b/ui/font.cpp index 5596f20..712818d 100644 --- a/ui/font.cpp +++ b/ui/font.cpp @@ -1,13 +1,16 @@ #include "font.h" #include +#include #include #include #include FT_FREETYPE_H +#include "glArrays.h" #include #include #include #include #include +#include #include #include // IWYU pragma: no_forward_declare FT_LibraryRec_ @@ -56,7 +59,9 @@ using Face = glRef; -Font::Font(const char * const p, unsigned s) : path {p}, size {getTextureSize(s)} +Cache Font::cachedFontRenderings; + +Font::Font(std::filesystem::path p, unsigned s) : path {std::move(p)}, size {getTextureSize(s)} { generateChars(BASIC_CHARS); } @@ -115,7 +120,6 @@ Font::getTextureWithSpace(unsigned int adv) const } auto & texture = fontTextures.emplace_back(); - glGenTextures(1, &texture.texture); glBindTexture(GL_TEXTURE_2D, texture.texture); glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, static_cast(size.x), static_cast(size.y), 0, GL_RED, GL_UNSIGNED_BYTE, nullptr); -- cgit v1.2.3