aboutsummaryrefslogtreecommitdiff
path: root/src/Text.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text.cpp')
-rw-r--r--src/Text.cpp37
1 files changed, 18 insertions, 19 deletions
diff --git a/src/Text.cpp b/src/Text.cpp
index e311f14..d58473d 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -298,8 +298,7 @@ namespace QuickMedia
vertices_index = 1;
}
- usize vertexOffset = vertices[vertices_index].getVertexCount();
- vertices[vertices_index].resize(vertices[vertices_index].getVertexCount() + 4 * textElement.text.size); // TODO: Precalculate
+ //vertices[vertices_index].resize(vertices[vertices_index].getVertexCount() + 4 * textElement.text.size); // TODO: Precalculate
textElement.position = glyphPos;
for(size_t i = 0; i < textElement.text.size; ++i)
{
@@ -310,16 +309,16 @@ namespace QuickMedia
prevCodePoint = codePoint;
glyphPos.x += kerning;
- int vertexStart = vertexOffset + i * 4;
+ int vertexStart = vertices[vertices_index].getVertexCount();
switch(codePoint)
{
case ' ':
{
- vertices[vertices_index][vertexStart + 0] = { sf::Vector2f(glyphPos.x, glyphPos.y - vspace), sf::Color::Transparent, sf::Vector2f() };
- vertices[vertices_index][vertexStart + 1] = { sf::Vector2f(glyphPos.x + hspace, glyphPos.y - vspace), sf::Color::Transparent, sf::Vector2f() };
- vertices[vertices_index][vertexStart + 2] = { sf::Vector2f(glyphPos.x + hspace, glyphPos.y), sf::Color::Transparent, sf::Vector2f() };
- vertices[vertices_index][vertexStart + 3] = { sf::Vector2f(glyphPos.x, glyphPos.y), sf::Color::Transparent, sf::Vector2f() };
+ vertices[vertices_index].append({ sf::Vector2f(glyphPos.x, glyphPos.y - vspace), sf::Color::Transparent, sf::Vector2f() });
+ vertices[vertices_index].append({ sf::Vector2f(glyphPos.x + hspace, glyphPos.y - vspace), sf::Color::Transparent, sf::Vector2f() });
+ vertices[vertices_index].append({ sf::Vector2f(glyphPos.x + hspace, glyphPos.y), sf::Color::Transparent, sf::Vector2f() });
+ vertices[vertices_index].append({ sf::Vector2f(glyphPos.x, glyphPos.y), sf::Color::Transparent, sf::Vector2f() });
glyphPos.x += hspace;
vertices_linear.push_back({vertices_index, vertexStart, 0, codePoint});
continue;
@@ -327,20 +326,20 @@ namespace QuickMedia
case '\t':
{
const float char_width = hspace * TAB_WIDTH;
- vertices[vertices_index][vertexStart + 0] = { sf::Vector2f(glyphPos.x, glyphPos.y - vspace), sf::Color::Transparent, sf::Vector2f() };
- vertices[vertices_index][vertexStart + 1] = { sf::Vector2f(glyphPos.x + char_width, glyphPos.y - vspace), sf::Color::Transparent, sf::Vector2f() };
- vertices[vertices_index][vertexStart + 2] = { sf::Vector2f(glyphPos.x + char_width, glyphPos.y), sf::Color::Transparent, sf::Vector2f() };
- vertices[vertices_index][vertexStart + 3] = { sf::Vector2f(glyphPos.x, glyphPos.y), sf::Color::Transparent, sf::Vector2f() };
+ vertices[vertices_index].append({ sf::Vector2f(glyphPos.x, glyphPos.y - vspace), sf::Color::Transparent, sf::Vector2f() });
+ vertices[vertices_index].append({ sf::Vector2f(glyphPos.x + char_width, glyphPos.y - vspace), sf::Color::Transparent, sf::Vector2f() });
+ vertices[vertices_index].append({ sf::Vector2f(glyphPos.x + char_width, glyphPos.y), sf::Color::Transparent, sf::Vector2f() });
+ vertices[vertices_index].append({ sf::Vector2f(glyphPos.x, glyphPos.y), sf::Color::Transparent, sf::Vector2f() });
glyphPos.x += char_width;
vertices_linear.push_back({vertices_index, vertexStart, 0, codePoint});
continue;
}
case '\n':
{
- vertices[vertices_index][vertexStart + 0] = { sf::Vector2f(glyphPos.x, glyphPos.y - vspace), sf::Color::Transparent, sf::Vector2f() };
- vertices[vertices_index][vertexStart + 1] = { sf::Vector2f(glyphPos.x, glyphPos.y - vspace), sf::Color::Transparent, sf::Vector2f() };
- vertices[vertices_index][vertexStart + 2] = { sf::Vector2f(glyphPos.x, glyphPos.y), sf::Color::Transparent, sf::Vector2f() };
- vertices[vertices_index][vertexStart + 3] = { sf::Vector2f(glyphPos.x, glyphPos.y), sf::Color::Transparent, sf::Vector2f() };
+ vertices[vertices_index].append({ sf::Vector2f(glyphPos.x, glyphPos.y - vspace), sf::Color::Transparent, sf::Vector2f() });
+ vertices[vertices_index].append({ sf::Vector2f(glyphPos.x, glyphPos.y - vspace), sf::Color::Transparent, sf::Vector2f() });
+ vertices[vertices_index].append({ sf::Vector2f(glyphPos.x, glyphPos.y), sf::Color::Transparent, sf::Vector2f() });
+ vertices[vertices_index].append({ sf::Vector2f(glyphPos.x, glyphPos.y), sf::Color::Transparent, sf::Vector2f() });
glyphPos.x = 0.0f;
glyphPos.y += floor(vspace + lineSpacing);
vertices_linear.push_back({vertices_index, vertexStart, 0, codePoint});
@@ -362,10 +361,10 @@ namespace QuickMedia
sf::Color fontColor = (textElement.type == TextElement::Type::TEXT ? color : urlColor);
- vertices[vertices_index][vertexStart + 0] = { vertexTopLeft, fontColor, textureTopLeft };
- vertices[vertices_index][vertexStart + 1] = { vertexTopRight, fontColor, textureTopRight };
- vertices[vertices_index][vertexStart + 2] = { vertexBottomRight, fontColor, textureBottomRight };
- vertices[vertices_index][vertexStart + 3] = { vertexBottomLeft, fontColor, textureBottomLeft };
+ vertices[vertices_index].append({ vertexTopLeft, fontColor, textureTopLeft });
+ vertices[vertices_index].append({ vertexTopRight, fontColor, textureTopRight });
+ vertices[vertices_index].append({ vertexBottomRight, fontColor, textureBottomRight });
+ vertices[vertices_index].append({ vertexBottomLeft, fontColor, textureBottomLeft });
glyphPos.x += glyph.advance + characterSpacing;
vertices_linear.push_back({vertices_index, vertexStart, 0, codePoint});