Cleanup
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 2m23s

This commit is contained in:
2024-07-12 01:47:49 -04:00
parent eb3e037c96
commit ae327b96a5
5 changed files with 36 additions and 13 deletions

View File

@@ -1,4 +1,5 @@
#include <JGL/FontCache.h>
#include <iostream>
using namespace JGL;
@@ -21,6 +22,9 @@ CachedGlyph::CachedGlyph(GLuint texture_id, char c, float x2offset, float y2offs
this->advanceY = advanceY;
}
//TODO
//Because most things shown would be english characters. We can cut down on the iteration time significantly
//by putting each english character at the beginning of the list in order of how often they usually occur in text.
void JGL::CachedFont::appendGlyph(JGL::CachedGlyph* glyph) {
glyphs.push_back(glyph);
}
@@ -72,8 +76,8 @@ void CachedFont::eraseGlyph(GLuint texture_id) {
glyphs.erase(glyphs.begin() + i);
}
std::vector<CachedGlyph*>* CachedFont::getGlyphs() {
return &glyphs;
std::vector<CachedGlyph*> CachedFont::getGlyphs() {
return glyphs;
}
void FontCache::appendFont(CachedFont* font) {
@@ -88,7 +92,7 @@ void FontCache::newFont(unsigned int font_size, unsigned int font_index) {
void FontCache::eraseFont(CachedFont* font) {
for (int i = 0; i < cachedFonts.size(); i++) {
if (cachedFonts[i] == font) {
for (auto& g: *cachedFonts[i]->getGlyphs())
for (auto& g: cachedFonts[i]->getGlyphs())
cachedFonts[i]->eraseGlyph(g);
delete cachedFonts[i];
@@ -101,11 +105,10 @@ void FontCache::purgeCache() {
//Remove every font from the cache.
for (const auto& font : cachedFonts)
eraseFont(font);
cachedFonts = {};
}
std::vector<CachedFont*>* FontCache::getFonts() {
return &cachedFonts;
std::vector<CachedFont*> FontCache::getFonts() {
return cachedFonts;
}
CachedFont* FontCache::getFont(unsigned int font_size, unsigned int font_index) {