naive vFlip
This commit is contained in:
parent
c69c17899e
commit
48c64c9326
1 changed files with 12 additions and 1 deletions
|
@ -700,7 +700,7 @@ class Font {
|
|||
|
||||
}
|
||||
|
||||
void draw(float x, float y, float z, const std::string & text){
|
||||
void draw(float x, float y, float z, const std::string & text, bool vFlip = false){
|
||||
float originalX = x;
|
||||
|
||||
glBindVertexArray(vao);
|
||||
|
@ -745,16 +745,27 @@ class Font {
|
|||
float u1 = (float)(glyph.bearingX + glyph.width + d) / emSize;
|
||||
float v1 = (float)(glyph.bearingY + d) / emSize;
|
||||
|
||||
|
||||
float x0 = x + u0 * worldSize;
|
||||
float y0 = y + v0 * worldSize;
|
||||
float x1 = x + u1 * worldSize;
|
||||
float y1 = y + v1 * worldSize;
|
||||
|
||||
if(vFlip){
|
||||
float _v = v0;
|
||||
v0 = v1;
|
||||
v1 = _v;
|
||||
|
||||
y0 = y - v0 * worldSize;
|
||||
y1 = y - v1 * worldSize;
|
||||
}
|
||||
|
||||
int32_t base = static_cast <int32_t>(vertices.size());
|
||||
vertices.push_back(BufferVertex{x0, y0, u0, v0, glyph.bufferIndex});
|
||||
vertices.push_back(BufferVertex{x1, y0, u1, v0, glyph.bufferIndex});
|
||||
vertices.push_back(BufferVertex{x1, y1, u1, v1, glyph.bufferIndex});
|
||||
vertices.push_back(BufferVertex{x0, y1, u0, v1, glyph.bufferIndex});
|
||||
|
||||
indices.insert(indices.end(), {base, base + 1, base + 2, base + 2, base + 3, base});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue