text.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #include <ft2build.h>
  2. #include FT_FREETYPE_H
  3. typedef struct {
  4. FT_Face fontFace;
  5. char* charSet;
  6. unsigned char* texture;
  7. unsigned char* codeIndex;
  8. short charLen;
  9. short indexLen;
  10. unsigned short* offsets; // texture offsets
  11. unsigned char* kerning;
  12. unsigned char* valign; // vertical offset for gutters
  13. unsigned short* charWidths; // quad widths
  14. short maxWidth, maxHeight;
  15. short padding;
  16. GLuint textureID;
  17. short texWidth;
  18. short texHeight;
  19. } TextRes;
  20. typedef struct {
  21. float x,y,z;
  22. float u,v;
  23. unsigned int rgba;
  24. } TextVertex;
  25. typedef struct {
  26. TextVertex* vertices;
  27. int vertexCnt;
  28. char* text;
  29. int textLen;
  30. GLuint vao; // need to move vao to font? global?
  31. GLuint vbo;
  32. TextRes* font;
  33. } TextRenderInfo;
  34. // this function is rather expensive. it rebinds textures.
  35. TextRes* LoadFont(char* path, int size, char* chars);
  36. TextRenderInfo* prepareText(TextRes* font, const char* str, int len, unsigned int* colors);
  37. void FreeFont(TextRes* res);
  38. void updateText(TextRenderInfo* tri, const char* str, int len, unsigned int* colors);