mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-04-10 06:14:07 +08:00
perf: optimize text rendering performance
This commit is contained in:
@@ -8,7 +8,7 @@ constexpr int MAX_UI_NUM = 1;
|
||||
constexpr int CHUCK_SIZE = 16;
|
||||
constexpr int DISTANCE = 8;
|
||||
constexpr int MAX_BLOCK_STATUS = 1;
|
||||
|
||||
constexpr int MAX_CHARACTER = 128;
|
||||
constexpr float FOV = 70.0f;
|
||||
|
||||
constexpr float VERTICES_POS[6][6][3] = {
|
||||
|
||||
@@ -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