diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-04-21 13:51:07 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-04-21 13:51:07 +0200 |
commit | 3240fa7024ca762c8fdd7efeed1705fdea0b2b09 (patch) | |
tree | 71087292d91d8aca7b29321277fd96c24a579d03 /src | |
parent | 3ac1120fd40b84507c51f867559bd05adff4eecf (diff) |
Use vertex buffer to render text
Diffstat (limited to 'src')
-rw-r--r-- | src/Text.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Text.cpp b/src/Text.cpp index 2abc276..5668cf8 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -49,6 +49,10 @@ namespace QuickMedia vertices[0].setPrimitiveType(sf::PrimitiveType::Triangles); vertices[1].setPrimitiveType(sf::PrimitiveType::Triangles); vertices[2].setPrimitiveType(sf::PrimitiveType::Triangles); + for(int i = 0; i < 3; ++i) { + vertex_buffers[i] = sf::VertexBuffer(sf::PrimitiveType::Triangles, sf::VertexBuffer::Static); + vertex_buffers[i].create(0); + } setString(std::move(_str)); } @@ -585,6 +589,10 @@ namespace QuickMedia } boundingBox.height = num_lines * line_height; + for(int i = 0; i < 3; ++i) { + vertex_buffers[i].update(&vertices[i][0], vertices[i].getVertexCount(), 0); + } + //url_ranges.clear(); if(!editable) vertices_linear.clear(); @@ -899,14 +907,14 @@ namespace QuickMedia sf::RenderStates states; states.transform.translate(pos); states.texture = &font->getTexture(characterSize); - target.draw(vertices[i], states); + target.draw(vertex_buffers[i], states); } if(vertices[2].getVertexCount() > 0) { sf::RenderStates states; states.transform.translate(pos); states.texture = TextureLoader::get_texture("images/emoji.png"); - target.draw(vertices[2], states); + target.draw(vertex_buffers[2], states); } if(!editable) return true; |