Renderer.h 974 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #ifndef RENDERER_H
  2. #define RENDERER_H
  3. #include "math/Vector.h"
  4. #include "rendering/FileTexture.h"
  5. #include "rendering/VertexBuffer.h"
  6. #include "utils/Buffer.h"
  7. #include "utils/Color.h"
  8. class Renderer final {
  9. VertexBuffer vertexBuffer;
  10. Buffer buffer;
  11. FileTexture font;
  12. Color4 color;
  13. const char* text;
  14. int index;
  15. int maxIndex;
  16. float x;
  17. float y;
  18. int vertices;
  19. public:
  20. Renderer();
  21. bool init();
  22. void renderString(const Vector2& pos, const char* text, int limit = -1);
  23. Vector2 getStringSize(const char* text, int limit = -1);
  24. void renderRectangle(const Vector2& pos, const Vector2& size, Color4 c);
  25. int charsInSpace(float width);
  26. private:
  27. void setupStringRead(const char* s, int limit);
  28. void setupString(const Vector2& pos, const char* s, int limit);
  29. bool hasStringData() const;
  30. char32_t readUnicode();
  31. bool readColor(char32_t c);
  32. void addChar(char32_t c);
  33. void update();
  34. };
  35. #endif