From 48c64c93261a9979c66737011b6aa3bcd2e9d7d8 Mon Sep 17 00:00:00 2001 From: themancalledjakob Date: Wed, 12 Apr 2023 15:48:33 +0200 Subject: [PATCH] naive vFlip --- src/gpufont/font.hpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/gpufont/font.hpp b/src/gpufont/font.hpp index c170e0a..538651d 100644 --- a/src/gpufont/font.hpp +++ b/src/gpufont/font.hpp @@ -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 (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}); }