Make it like, go faster.
This commit is contained in:
@@ -122,6 +122,8 @@ namespace JGL
|
||||
|
||||
Vector2 Font::MeasureString(const std::string &text, float ptSize) {
|
||||
|
||||
// TODO: Check if a font of that size is in the cache and if so use the info from that because this is sloooooooooooooow.
|
||||
// That'll make it go vroom vroom.
|
||||
// TODO: Work in-progress implementation unfortunately.
|
||||
// This is likely returning slightly incorrect results for likely several reasons.
|
||||
// Half-ass solution for now ~ dawsh.
|
||||
|
@@ -121,8 +121,8 @@ namespace JGL {
|
||||
//Texture parameters are restored when the texture is bound
|
||||
glBindTexture(GL_TEXTURE_2D, *cachedFont->getTexture());
|
||||
|
||||
std::vector<GLfloat> vertices;
|
||||
std::vector<GLfloat> texcoords;
|
||||
std::vector<std::array<GLfloat, 12>> vertices(text.size());
|
||||
std::vector<std::array<GLfloat, 12>> texcoords(text.size());
|
||||
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
float x2, y2, w, h;
|
||||
@@ -145,15 +145,13 @@ namespace JGL {
|
||||
x2 + w, y2
|
||||
};
|
||||
auto glyph_texcoords = glyph->getTexCoords();
|
||||
|
||||
//TODO make it like go faster because now the profiler says this is the slowest part.
|
||||
vertices.insert(vertices.end(), glyph_vertices.begin(), glyph_vertices.end());
|
||||
texcoords.insert(texcoords.end(), glyph_texcoords.begin(), glyph_texcoords.end());
|
||||
vertices[i] = glyph_vertices;
|
||||
texcoords[i] = glyph_texcoords;
|
||||
}
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(GLfloat) * 2, vertices.data());
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(GLfloat) * 2, texcoords.data());
|
||||
glDrawArrays(GL_TRIANGLES, 0, vertices.size() / 2);
|
||||
glDrawArrays(GL_TRIANGLES, 0, vertices.size() * 6);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user