Clean text rendering in editor.
This commit is contained in:
parent
290b64e230
commit
f16dd7c0d9
45 changed files with 59 additions and 60 deletions
|
@ -27,8 +27,6 @@
|
|||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
OpenGlTextPainter::OpenGlTextPainter()
|
||||
{
|
||||
|
||||
|
@ -118,7 +116,7 @@ void OpenGlTextPainter::paint(SceneText* text, DrawingContext* context)
|
|||
auto texture = mFontTextures[c].get();
|
||||
|
||||
float xpos = x + texture->getGlyph()->getBearingX();
|
||||
float ypos = y - (texture->getGlyph()->getHeight() - texture->getGlyph()->getBearingY());
|
||||
float ypos = y - (int(texture->getGlyph()->getHeight()) - texture->getGlyph()->getBearingY());
|
||||
|
||||
float w = texture->getGlyph()->getWidth();
|
||||
float h = texture->getGlyph()->getHeight();
|
||||
|
@ -131,7 +129,6 @@ void OpenGlTextPainter::paint(SceneText* text, DrawingContext* context)
|
|||
{ xpos + w, ypos, 1.0f, 1.0f },
|
||||
{ xpos + w, ypos + h, 1.0f, 0.0f }
|
||||
};
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, texture->getHandle());
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, mVertexBuffer);
|
||||
|
@ -140,12 +137,11 @@ void OpenGlTextPainter::paint(SceneText* text, DrawingContext* context)
|
|||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
|
||||
x += (texture->getGlyph()->getAdvanceX() >> 6); // bitshift by 6 to get value in pixels (2^6 = 64)
|
||||
auto offset = (texture->getGlyph()->getAdvanceX() >> 6); // bitshift by 6 to get value in pixels (2^6 = 64)
|
||||
x += offset;
|
||||
}
|
||||
|
||||
line_offset += line_delta;
|
||||
}
|
||||
|
||||
glBindVertexArray(0);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue