utexfont.hpp

00001 
00002 /* Copyright (c) Mark J. Kilgard, 1997. */
00003 
00004 /* This program is freely distributable without licensing fees  and is
00005    provided without guarantee or warrantee expressed or  implied. This
00006    program is -not- in the public domain.
00007  */
00008 //NB: we added a "u" prefix to avoid name collisions.
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;      // Potentially support 16-bit glyphs.
00027   unsigned char width;
00028   unsigned char height;
00029   signed char xoffset;
00030   signed char yoffset;
00031   signed char advance;
00032   char dummy;           // Space holder for alignment reasons.
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 /* ==================================================== ======== ======= */

Generated on Mon Jan 29 00:20:40 2007 for Ubit by  doxygen 1.4.7