diff options
Diffstat (limited to 'ui/font.cpp')
| -rw-r--r-- | ui/font.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/ui/font.cpp b/ui/font.cpp index ebd29d0..9c3d770 100644 --- a/ui/font.cpp +++ b/ui/font.cpp @@ -4,7 +4,6 @@ #include <format> #include <ft2build.h> #include FT_FREETYPE_H -#include "gl_traits.h" #include <glRef.h> #include <maths.h> #include <optional> @@ -93,8 +92,7 @@ Font::generateChars(const utf8_string_view chars) const const auto textureIdx = getTextureWithSpace(glyph->bitmap.width); auto & texture = fontTextures[textureIdx]; - glTexSubImage2D(GL_TEXTURE_2D, 0, static_cast<GLint>(texture.used), 0, - static_cast<GLsizei>(glyph->bitmap.width), static_cast<GLsizei>(glyph->bitmap.rows), GL_RED, + texture.texture.subImage({texture.used, 0}, {glyph->bitmap.width, glyph->bitmap.rows}, GL_RED, GL_UNSIGNED_BYTE, glyph->bitmap.buffer); const auto & cd = charsData @@ -116,18 +114,15 @@ Font::getTextureWithSpace(unsigned int adv) const return (ft.used + adv) < size.x; }); itr != fontTextures.end()) { - glBindTexture(GL_TEXTURE_2D, itr->texture); return static_cast<std::size_t>(itr - fontTextures.begin()); } auto & texture = fontTextures.emplace_back(); - glBindTexture(GL_TEXTURE_2D, texture.texture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, static_cast<GLsizei>(size.x), static_cast<GLsizei>(size.y), 0, GL_RED, - GL_UNSIGNED_BYTE, nullptr); - glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + texture.texture.storage(1, GL_R8, size); + texture.texture.parameter(GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + texture.texture.parameter(GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + texture.texture.parameter(GL_TEXTURE_MIN_FILTER, GL_LINEAR); + texture.texture.parameter(GL_TEXTURE_MAG_FILTER, GL_LINEAR); return fontTextures.size() - 1; } |
