Renderer.h 1013 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef RENDERER_H
  2. #define RENDERER_H
  3. #include "gaming-core/math/Vector.h"
  4. #include "gaming-core/rendering/FileTexture.h"
  5. #include "gaming-core/rendering/VertexBuffer.h"
  6. #include "gaming-core/utils/Buffer.h"
  7. #include "gaming-core/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. void drawString(const Vector2& pos, const char* text, int limit = -1);
  22. Vector2 getStringSize(const char* text, int limit = -1);
  23. void drawRectangle(const Vector2& pos, const Vector2& size, Color4 c);
  24. int charsInSpace(float width);
  25. private:
  26. void setupStringRead(const char* s, int limit);
  27. void setupString(const Vector2& pos, const char* s, int limit);
  28. bool hasStringData() const;
  29. char32_t readUnicode();
  30. bool readColor(char32_t c);
  31. void addChar(char32_t c);
  32. void update();
  33. };
  34. #endif