2 #ifndef Reve_GLTextNS_H
3 #define Reve_GLTextNS_H
5 // The following implementation is based on TexFont API,
6 // implementation and accompanying programs by Mark J. Kilgard.
9 /* Copyright (c) Mark J. Kilgard, 1997. */
10 /* This program is freely distributable without licensing fees and is
11 provided without guarantee or warrantee expressed or implied. This
12 program is -not- in the public domain. */
17 #include <TGLIncludes.h>
23 #define TXF_FORMAT_BYTE 0
24 #define TXF_FORMAT_BITMAP 1
27 unsigned short c; /* Potentially support 16-bit glyphs. */
33 char dummy; /* Space holder for alignment reasons. */
38 struct TexGlyphVertexInfo {
50 class TexFont : public TObject {
57 int max_width; // max glyph width (MT)
61 unsigned char *teximage;
63 TexGlyphVertexInfo *tgvi;
64 TexGlyphVertexInfo **lut;
66 int max_height() { return max_ascent + max_descent; }
70 extern char *txfErrorString(void);
72 extern TexFont *txfLoadFont(const char *filename);
74 extern void txfUnloadFont(TexFont* txf);
76 extern GLuint txfEstablishTexture(TexFont* txf, GLuint texobj,
77 GLboolean setupMipmaps);
79 extern void txfBindFontTexture(TexFont* txf);
81 extern void txfGetStringMetrics(TexFont* txf, const char *TString, int len,
82 int &width, int &max_ascent, int &max_descent);
84 extern void txfRenderGlyph(TexFont* txf, int c);
85 extern void txfRenderString(TexFont* txf, const char *TString, int len,
87 extern void txfRenderString(TexFont* txf, const char *TString, int len,
88 GLfloat maxx, GLfloat fadew,
91 extern void txfRenderGlyphZW(TexFont* txf, int c, float z, float w);
92 extern void txfRenderStringZW(TexFont* txf, const char *TString, int len,
93 float z, float w, bool keep_pos=true);
95 extern void txfRenderFancyString(TexFont* txf, char *TString, int len);
98 bool LoadDefaultFont(TString font_file);
100 extern TexFont* fgDefaultFont;
102 /**************************************************************************/
103 // Here starts MT higher-level interface
104 /**************************************************************************/
112 void _init() { align = 'l'; lineskip = 0; }
115 { lm = rm = 3; tm = 0; bm = 2; _init(); }
117 BoxSpecs(int lr, int tb)
118 { lm = rm = lr; tm = bm = tb; _init(); }
120 BoxSpecs(int l, int r, int t, int b)
121 { lm = l; rm = r; tm = t; bm = b; _init(); }
123 struct TextLineData {
124 int width, ascent, descent, hfull;
127 TextLineData(TexFont *txf, TString line);
130 extern void RnrTextBar(RnrDriver* rd, const TString& text);
132 extern void RnrTextBar(RnrDriver* rd, const TString& text,
133 BoxSpecs& bs, float zoffset=0);
135 extern void RnrTextPoly(RnrDriver* rd, const TString& text);
137 extern void RnrText(RnrDriver* rd, const TString& text,
138 int x, int y, float z,
139 const ZColor* front_col, const ZColor* back_col=0);
141 extern void RnrTextAt(RnrDriver* rd, const TString& text,
142 int x, int yrow, float z,
143 const ZColor* front_col, const ZColor* back_col=0);
146 } // namescape GLTextNS
149 #endif // Reve_GLTextNS_H