00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifdef HAVE_GL
00011
00012 #ifndef _utexfont_hpp_
00013 #define _utexfont_hpp_
00014
00015 #include <GL/gl.h>
00016 #include <ubit/ubrick.hpp>
00017 #include <ubit/unatgraph.hpp>
00018 namespace ubit {
00019
00020 #define UTXF_FORMAT_BYTE 0
00021 #define UTXF_FORMAT_BITMAP 1
00022
00023
00024
00025 struct UTexGlyphInfo {
00026 unsigned short c;
00027 unsigned char width;
00028 unsigned char height;
00029 signed char xoffset;
00030 signed char yoffset;
00031 signed char advance;
00032 char dummy;
00033 short x;
00034 short y;
00035 };
00036
00037
00038
00039 struct UTexGlyphVertexInfo {
00040 GLfloat t0[2];
00041 GLshort v0[2];
00042 GLfloat t1[2];
00043 GLshort v1[2];
00044 GLfloat t2[2];
00045 GLshort v2[2];
00046 GLfloat t3[2];
00047 GLshort v3[2];
00048 GLfloat advance;
00049 };
00050
00051
00052
00053 struct UTexFont {
00054 GLuint texobj;
00055 int tex_width;
00056 int tex_height;
00057 int max_ascent;
00058 int max_descent;
00059 int num_glyphs;
00060 int min_glyph;
00061 int range;
00062 unsigned char* teximage;
00063 UTexGlyphInfo* tgi;
00064 UTexGlyphVertexInfo *tgvi;
00065 UTexGlyphVertexInfo **lut;
00066 };
00067
00068
00069
00070 UTexFont* utxfLoadFont(Display*, Font fid);
00071
00072 void utxfUnloadFont(UTexFont*);
00073
00074 GLuint utxfEstablishTexture(UTexFont*, GLuint texobj, GLboolean setupMipmaps);
00075
00076 void utxfBindFontTexture(UTexFont*);
00077
00078 void utxfRenderString(UTexFont*, const char* string, int len);
00079
00080 void utxfGetStringMetrics(UTexFont*, const char* string, int len,
00081 int* pwidth, int* pmax_ascent, int* pmax_descent);
00082
00083 }
00084
00085 #endif
00086 #endif
00087