00001
00002 #ifndef RC_TEXT_H
00003 #define RC_TEXT_H
00004
00005 typedef struct {
00006
00007 vec2f vertex;
00008 vec2f texcoord;
00009 u8 color[4];
00010
00011 } AChar_t;
00012
00013 typedef struct {
00014
00015 AChar_t c[4];
00016
00017 } SChar_t;
00018
00019
00038 class Text {
00039
00040 public:
00041 Text();
00042
00043 ~Text();
00044
00045 void setFont(
00046 const char *filename,
00047 bool mono_spaced
00048 );
00049
00050 void setXY(
00051 u32 pixel_x,
00052 u32 pixel_y
00053 );
00054
00055 void setMetrics(
00056 i32 glyph_spacing,
00057 i32 line_spacing,
00058 u32 max_width,
00059 u32 max_lines
00060 );
00061
00062 u32 getGlyphHeight() const;
00063
00064 i32 getVerticalSpacing() const;
00065
00066 void print(
00067 char *str
00068 );
00069
00070 void print(
00071 char *str,
00072 u32 nx,
00073 u32 ny
00074 );
00075
00076 char *printLine(
00077 char *str,
00078 u32 line
00079 );
00080
00081 u32 printLines(
00082 char *str,
00083 u32 from_line,
00084 u32 to_line
00085 );
00086
00087 char *nextLineSplit(
00088 char *str
00089 );
00090
00091 void resetEffects();
00092
00093 private:
00094
00095 void output();
00096
00097 void postWord(
00098 char *str,
00099 u32 word_len,
00100 i32 x,
00101 i32 line,
00102 u8 color[8]
00103 );
00104
00105 char *printLine(
00106 char *str,
00107 u32 line,
00108 bool ignore_output
00109 );
00110
00111 public:
00112
00113 i32 lineSpacing;
00114 i32 glyphSpacing;
00115 u32 maxWidth;
00116 u32 maxLines;
00117
00118
00119 private:
00120 Geometry *mesh;
00121 Texture *fontTexture;
00122 VertexArray *glyphVA;
00123 ShaderProgram *textShader;
00124
00125 vec2f texcoords_fr[256];
00126 vec2f texcoords_to[256];
00127 u8 advanceBase[256];
00128
00129 u32 glyphHeight;
00130 i32 startX;
00131 i32 startY;
00132
00133 i32 resX, resY;
00134 vec2f onePixel;
00135
00136 u32 n_chars;
00137 u32 maxChars;
00138 SChar_t *chars;
00139 u16 *indices;
00140
00141 u8 color[8];
00142 u32 style;
00143
00144 };
00145
00146
00147
00148 #endif
00149
00150