build glyph bitmap position into its VBO coordinates
This commit is contained in:
parent
f75cd9d4ad
commit
98a27bd20b
@ -73,8 +73,8 @@ namespace jes
|
||||
|
||||
int width = face->glyph->bitmap.width;
|
||||
int height = face->glyph->bitmap.rows;
|
||||
m_left = face->glyph->bitmap_left;
|
||||
m_top = face->glyph->bitmap_top;
|
||||
int left = face->glyph->bitmap_left;
|
||||
int top = face->glyph->bitmap_top;
|
||||
m_advance = round_up_26_6(face->glyph->advance.x);
|
||||
uint8_t * texture = new uint8_t[width * height];
|
||||
for (int i = 0; i < height; i++)
|
||||
@ -95,15 +95,13 @@ namespace jes
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, texture);
|
||||
delete[] texture;
|
||||
|
||||
float w = width - 1;
|
||||
float h = height - 1;
|
||||
float s = 1.0 / (width * 2);
|
||||
float t = 1.0 / (height * 2);
|
||||
GLfloat box[4][4] = {
|
||||
{0, 0, s, t},
|
||||
{w, 0, 1 - s, t},
|
||||
{0, h, s, 1 - t},
|
||||
{w, h, 1 - s, 1 - t},
|
||||
{(GLfloat)left, (GLfloat)(top - height), s, t},
|
||||
{(GLfloat)(left + width - 1), (GLfloat)(top - height), 1 - s, t},
|
||||
{(GLfloat)left, (GLfloat)(top - 1), s, 1 - t},
|
||||
{(GLfloat)(left + width - 1), (GLfloat)(top - 1), 1 - s, 1 - t},
|
||||
};
|
||||
glGenBuffers(1, &m_vbo_id);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_vbo_id);
|
||||
|
@ -18,8 +18,6 @@ namespace jes
|
||||
Glyph();
|
||||
~Glyph();
|
||||
bool load(FT_Face face, FT_ULong char_code);
|
||||
int get_top() { return m_top; }
|
||||
int get_left() { return m_left; }
|
||||
int get_advance() { return m_advance; }
|
||||
void render()
|
||||
{
|
||||
@ -31,8 +29,6 @@ namespace jes
|
||||
}
|
||||
protected:
|
||||
bool m_loaded;
|
||||
int m_top;
|
||||
int m_left;
|
||||
int m_advance;
|
||||
GLuint m_texture_id;
|
||||
GLuint m_vbo_id;
|
||||
|
Loading…
x
Reference in New Issue
Block a user