Open Source Tomb Raider Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FontTRLE.h 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*!
  2. * \file include/system/FontTRLE.h
  3. * \brief Tomb Raider Level Editor Font loader
  4. *
  5. * \author xythobuz
  6. */
  7. #ifndef _FONT_TRLE_H_
  8. #define _FONT_TRLE_H_
  9. #include <vector>
  10. #include <glm/vec2.hpp>
  11. #include "system/Shader.h"
  12. /*!
  13. * \brief Tomb Raider Level Editor Font loader
  14. */
  15. class FontTRLE {
  16. public:
  17. static void shutdown();
  18. static int initialize(std::string font);
  19. static unsigned int widthText(float scale, std::string s);
  20. static unsigned int heightText(float scale, unsigned int maxWidth, std::string s);
  21. static void drawText(unsigned int x, unsigned int y, float scale,
  22. const unsigned char color[4], std::string s);
  23. static void drawTextWrapped(unsigned int x, unsigned int y, float scale,
  24. const unsigned char color[4], unsigned int maxWidth, std::string s);
  25. private:
  26. static void setDefaultOffsets();
  27. static void loadLPS(std::string f);
  28. static void writeChar(unsigned int index, unsigned int xDraw, unsigned int yDraw, float scale,
  29. std::vector<glm::vec2>& vertices, std::vector<glm::vec2>& uvs);
  30. static bool mFontInit;
  31. static unsigned int mFontTexture;
  32. // 106 entries: (x, y, w, h, offset)
  33. static int offsets[106][5];
  34. static int defaultOffsets[106][5];
  35. static ShaderBuffer vertexBuffer;
  36. static ShaderBuffer uvBuffer;
  37. };
  38. #endif