Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields

text.h

00001 
00007 /***************************************************************************
00008                           text.h  -  description
00009                              -------------------
00010     begin                : Mon Jul 7 2003
00011     copyright            : (C) 2003 by Gabor Torok
00012     email                : cctorok@yahoo.com
00013  ***************************************************************************/
00014 
00015 /***************************************************************************
00016  *                                                                         *
00017  *   This program is free software; you can redistribute it and/or modify  *
00018  *   it under the terms of the GNU General Public License as published by  *
00019  *   the Free Software Foundation; either version 2 of the License, or     *
00020  *   (at your option) any later version.                                   *
00021  *                                                                         *
00022  ***************************************************************************/
00023 
00024 #ifndef TEXT_H
00025 #define TEXT_H
00026 
00027 #include "constants.h"
00028 
00033 #define TXF_FORMAT_BYTE         0
00034 #define TXF_FORMAT_BITMAP       1
00035 
00036 struct TexGlyphInfo {
00037   unsigned short c;       /* Potentially support 16-bit glyphs. */
00038   unsigned char width;
00039   unsigned char height;
00040   signed char xoffset;
00041   signed char yoffset;
00042   signed char advance;
00043   char dummy;           /* Space holder for alignment reasons. */
00044   short x;
00045   short y;
00046 };
00047 
00048 struct TexGlyphVertexInfo {
00049   GLfloat t0[2];
00050   GLshort v0[2];
00051   GLfloat t1[2];
00052   GLshort v1[2];
00053   GLfloat t2[2];
00054   GLshort v2[2];
00055   GLfloat t3[2];
00056   GLshort v3[2];
00057   GLfloat advance;
00058 };
00059 
00060 struct TexFont {
00061   GLuint texobj;
00062   int tex_width;
00063   int tex_height;
00064   int max_ascent;
00065   int max_descent;
00066   int num_glyphs;
00067   int min_glyph;
00068   int range;
00069   unsigned char *teximage;
00070   TexGlyphInfo *tgi;
00071   TexGlyphVertexInfo *tgvi;
00072   TexGlyphVertexInfo **lut;
00073 };
00074 
00075 enum {
00076   MONO, TOP_BOTTOM, LEFT_RIGHT, FOUR
00077 };
00078 
00079 /* byte swap a 32-bit value */
00080 #define SWAPL(x, n) { \
00081                  n = ((char *) (x))[0];\
00082                  ((char *) (x))[0] = ((char *) (x))[3];\
00083                  ((char *) (x))[3] = n;\
00084                  n = ((char *) (x))[1];\
00085                  ((char *) (x))[1] = ((char *) (x))[2];\
00086                  ((char *) (x))[2] = n; }
00087 
00088 /* byte swap a short */
00089 #define SWAPS(x, n) { \
00090                  n = ((char *) (x))[0];\
00091                  ((char *) (x))[0] = ((char *) (x))[1];\
00092                  ((char *) (x))[1] = n; }
00093         
00094 class TexturedText  {
00095 private:
00096 
00097 char *lastError;
00098 int useLuminanceAlpha;
00099 char filename[300];
00100 TexFont *txf;
00101 
00102 public:
00103         TexturedText();
00104         ~TexturedText();
00105 
00106 
00107     inline char *txfErrorString() { return lastError; }
00108 
00109 
00110     TexFont *txfLoadFont(char *filename);
00111 
00112     void txfUnloadFont();
00113 
00114     GLuint txfEstablishTexture(GLuint texobj,
00115                                GLboolean setupMipmaps);
00116 
00117     void txfBindFontTexture();
00118 
00119     void txfGetStringMetrics(char *string,                
00120                              int len,
00121                              int *width,
00122                              int *max_ascent,
00123                              int *max_descent);
00124 
00125     void txfRenderGlyph(int c);
00126 
00127     void txfRenderString(char *string,
00128                          int len);
00129 
00130     void txfRenderFancyString(char *string,
00131                               int len);
00132 
00133 private:
00134     TexGlyphVertexInfo *getTCVI(int c);
00135     int txfInFont(int c);
00136 };
00137 
00138 #endif

Generated on Thu Jun 16 21:50:43 2005 for scourge by  doxygen 1.4.0