2
0

PolyTextMesh.cpp 821 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "PolyTextMesh.h"
  2. #include "PolyFontGlyphSheet.h"
  3. using namespace Polycode;
  4. TextMesh::TextMesh(FontGlyphSheet *font, const String &text)
  5. : Mesh(QUAD_MESH)
  6. , font(font)
  7. , text(text)
  8. {
  9. rebuild();
  10. }
  11. void TextMesh::setFont(FontGlyphSheet *font) {
  12. this->font = font;
  13. rebuild();
  14. }
  15. void TextMesh::setText(const String &text) {
  16. if (text == this->text) return;
  17. this->text = text;
  18. rebuild();
  19. }
  20. void TextMesh::rebuild() {
  21. // TODO: FIX
  22. /*
  23. if (text == "" || font == NULL) {
  24. for (std::vector<Vertex*>::iterator it = vertices.begin(); it != vertices.end(); it++) delete *it;
  25. vertices.clear();
  26. return;
  27. }
  28. int last = font->renderStringVertices(text, vertices);
  29. if (last < vertices.size()) {
  30. for (int i = last; i < vertices.size(); i++) {
  31. delete vertices[i];
  32. }
  33. vertices.resize(last);
  34. }
  35. */
  36. }