mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-06-18 00:27:02 +08:00
perf: optimize text rendering performance
This commit is contained in:
@@ -9,7 +9,8 @@
|
||||
#include <unordered_map>
|
||||
|
||||
struct Character {
|
||||
GLuint texture_id;
|
||||
glm::vec2 uv_min;
|
||||
glm::vec2 uv_max;
|
||||
glm::ivec2 size;
|
||||
glm::ivec2 bearing;
|
||||
GLuint advance;
|
||||
@@ -20,12 +21,16 @@ public:
|
||||
Font();
|
||||
~Font();
|
||||
|
||||
static void render_text(GLuint program, GLuint vbo, const std::string& text, float x, float y, float scale, const glm::vec3& color);
|
||||
static void render_text(GLuint program, const std::string& text, float x, float y, float scale, const glm::vec3& color);
|
||||
|
||||
private:
|
||||
FT_Library m_ft;
|
||||
FT_Face m_face;
|
||||
|
||||
float m_texture_width = 64;
|
||||
float m_texture_height = 64;
|
||||
|
||||
GLuint m_text_texture;
|
||||
std::unordered_map<char8_t, Character> m_characters;
|
||||
|
||||
void load_character(char8_t c);
|
||||
|
||||
Reference in New Issue
Block a user