Updated for changes in *Glyph classes. Added unicode render function. Updated comments
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
diff --git a/include/FTGLBitmapFont.h b/include/FTGLBitmapFont.h
index e92a510..cf827af 100755
--- a/include/FTGLBitmapFont.h
+++ b/include/FTGLBitmapFont.h
@@ -6,22 +6,53 @@
class FTBitmapGlyph;
+/**
+ * FTGLBitmapFont is a specialisation of the FTFont class for handling
+ * Bitmap fonts
+ *
+ * @see FTFont
+ */
class FTGLBitmapFont : public FTFont
{
public:
- // methods
+ /**
+ * Constructor
+ */
FTGLBitmapFont();
+
+ /**
+ * Destructor
+ */
~FTGLBitmapFont();
+ /**
+ * Renders a string of characters
+ *
+ * @param string 'C' style string to be output.
+ */
void render( const char* string);
+ /**
+ * Renders a string of characters
+ *
+ * @param string 'C' style string to be output.
+ */
+ void render( const wchar_t* string);
+
// attributes
private:
- // methods
+ /**
+ * Constructs the internal glyph cache.
+ *
+ * This a list of glyphs processed for openGL rendering NOT
+ * freetype glyphs
+ */
bool MakeGlyphList();
- // attributes
+ /**
+ * Temp variable for a FTBitmapGlyph
+ */
FTBitmapGlyph* tempGlyph;
};
diff --git a/include/FTGLOutlineFont.h b/include/FTGLOutlineFont.h
index 9c77bfc..f586b6f 100755
--- a/include/FTGLOutlineFont.h
+++ b/include/FTGLOutlineFont.h
@@ -8,6 +8,12 @@
class FTVectorGlyph;
+/**
+ * FTGLOutlineFont is a specialisation of the FTFont class for handling
+ * Vector Outline fonts
+ *
+ * @see FTFont
+ */
class FTGLOutlineFont : public FTFont
{
public:
@@ -16,6 +22,7 @@ class FTGLOutlineFont : public FTFont
~FTGLOutlineFont();
void render( const char* string);
+ void render( const wchar_t* string);
// attributes
diff --git a/include/FTGLPixmapFont.h b/include/FTGLPixmapFont.h
index 2cd5766..d0422bd 100755
--- a/include/FTGLPixmapFont.h
+++ b/include/FTGLPixmapFont.h
@@ -6,6 +6,12 @@
class FTPixmapGlyph;
+/**
+ * FTGLPixmapFont is a specialisation of the FTFont class for handling
+ * Pixmap (Grey Scale) fonts
+ *
+ * @see FTFont
+ */
class FTGLPixmapFont : public FTFont
{
public:
@@ -14,6 +20,7 @@ class FTGLPixmapFont : public FTFont
~FTGLPixmapFont();
void render( const char* string);
+ void render( const wchar_t* string);
private:
diff --git a/include/FTGLPolygonFont.h b/include/FTGLPolygonFont.h
index fc12078..27c41ce 100755
--- a/include/FTGLPolygonFont.h
+++ b/include/FTGLPolygonFont.h
@@ -8,6 +8,12 @@
class FTPolyGlyph;
+/**
+ * FTGLPolygonFont is a specialisation of the FTFont class for handling
+ * tesselated Polygon Mesh fonts
+ *
+ * @see FTFont
+ */
class FTGLPolygonFont : public FTFont
{
public:
diff --git a/include/FTGLTextureFont.h b/include/FTGLTextureFont.h
index c221db0..81e296b 100755
--- a/include/FTGLTextureFont.h
+++ b/include/FTGLTextureFont.h
@@ -6,7 +6,13 @@
class FTTextureGlyph;
-class FTGLTextureFont : public FTFont
+/**
+ * FTGLTextureFont is a specialisation of the FTFont class for handling
+ * Texture mapped fonts
+ *
+ * @see FTFont
+ */
+class FTGLTextureFont : public FTFont
{
public:
// methods
@@ -17,6 +23,7 @@ class FTGLTextureFont : public FTFont
virtual int TextureHeight() const { return textureHeight;}
virtual void render( const char* string);
+ virtual void render( const wchar_t* string);
private:
diff --git a/src/FTGLBitmapFont.cpp b/src/FTGLBitmapFont.cpp
index e301c9c..c85e18c 100755
--- a/src/FTGLBitmapFont.cpp
+++ b/src/FTGLBitmapFont.cpp
@@ -25,7 +25,7 @@ bool FTGLBitmapFont::MakeGlyphList()
if( ftGlyph)
{
- tempGlyph = new FTBitmapGlyph( *ftGlyph, c);
+ tempGlyph = new FTBitmapGlyph( *ftGlyph);
glyphList->Add( tempGlyph);
}
else
@@ -52,3 +52,19 @@ void FTGLBitmapFont::render( const char* string)
glPopClientAttrib();
}
+
+
+void FTGLBitmapFont::render( const wchar_t* string)
+{
+ glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT);
+
+ // doing this every frame is a bad?
+ glPixelStorei( GL_UNPACK_LSB_FIRST, GL_FALSE);
+ glPixelStorei( GL_UNPACK_ROW_LENGTH, 0);
+ glPixelStorei( GL_UNPACK_ALIGNMENT, 1);
+
+ FTFont::render( string);
+
+ glPopClientAttrib();
+
+}
diff --git a/src/FTGLOutlineFont.cpp b/src/FTGLOutlineFont.cpp
index 092ba9c..bfe7122 100755
--- a/src/FTGLOutlineFont.cpp
+++ b/src/FTGLOutlineFont.cpp
@@ -23,7 +23,7 @@ bool FTGLOutlineFont::MakeGlyphList()
if( ftGlyph)
{
- tempGlyph = new FTVectorGlyph( *ftGlyph, n);
+ tempGlyph = new FTVectorGlyph( *ftGlyph);
glyphList->Add( tempGlyph);
}
else
@@ -50,3 +50,19 @@ void FTGLOutlineFont::render( const char* string)
glPopAttrib();
}
+
+
+void FTGLOutlineFont::render( const wchar_t* string)
+{
+ glPushAttrib( GL_ENABLE_BIT | GL_HINT_BIT | GL_LINE_BIT | GL_PIXEL_MODE_BIT);
+
+ glEnable( GL_LINE_SMOOTH);
+ glHint( GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
+ glEnable(GL_BLEND);
+ glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // GL_ONE
+
+ FTFont::render( string);
+
+ glPopAttrib();
+
+}
diff --git a/src/FTGLPixmapFont.cpp b/src/FTGLPixmapFont.cpp
index f564132..e00d1f9 100755
--- a/src/FTGLPixmapFont.cpp
+++ b/src/FTGLPixmapFont.cpp
@@ -25,7 +25,7 @@ bool FTGLPixmapFont::MakeGlyphList()
if( ftGlyph)
{
- tempGlyph = new FTPixmapGlyph( *ftGlyph, c);
+ tempGlyph = new FTPixmapGlyph( *ftGlyph);
glyphList->Add( tempGlyph);
}
else
@@ -50,3 +50,17 @@ void FTGLPixmapFont::render( const char* string)
glPopAttrib();
}
+
+
+void FTGLPixmapFont::render( const wchar_t* string)
+{
+ glPushAttrib( GL_ENABLE_BIT | GL_PIXEL_MODE_BIT);
+
+ glEnable(GL_BLEND);
+ glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ FTFont::render( string);
+
+ glPopAttrib();
+
+}
diff --git a/src/FTGLPolygonFont.cpp b/src/FTGLPolygonFont.cpp
index b1cd35d..7cbb1ed 100755
--- a/src/FTGLPolygonFont.cpp
+++ b/src/FTGLPolygonFont.cpp
@@ -22,7 +22,7 @@ bool FTGLPolygonFont::MakeGlyphList()
if( ftGlyph)
{
- tempGlyph = new FTPolyGlyph( *ftGlyph, n);
+ tempGlyph = new FTPolyGlyph( *ftGlyph);
glyphList->Add( tempGlyph);
}
else
diff --git a/src/FTGLTextureFont.cpp b/src/FTGLTextureFont.cpp
index c7e1c4c..af0c152 100755
--- a/src/FTGLTextureFont.cpp
+++ b/src/FTGLTextureFont.cpp
@@ -122,7 +122,7 @@ unsigned int FTGLTextureFont::FillGlyphs( unsigned int glyphStart, int id, int w
currTextU = (float)currentTextX / (float)width;
- tempGlyph = new FTTextureGlyph( *ftGlyph, n, id, data, width, height, currTextU, currTextV);
+ tempGlyph = new FTTextureGlyph( *ftGlyph, id, data, width, height, currTextU, currTextV);
glyphList->Add( tempGlyph);
currentTextX += glyphWidth;
@@ -189,3 +189,21 @@ void FTGLTextureFont::render( const char* string)
glPopAttrib();
}
+
+
+void FTGLTextureFont::render( const wchar_t* string)
+{
+ glPushAttrib( GL_ENABLE_BIT | GL_HINT_BIT | GL_LINE_BIT | GL_PIXEL_MODE_BIT);
+
+ glEnable(GL_BLEND);
+ glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // GL_ONE
+
+ glBindTexture( GL_TEXTURE_2D, (GLuint)FTTextureGlyph::activeTextureID);
+
+ // QUADS are faster!? Less function call overhead?
+ glBegin( GL_QUADS);
+ FTFont::render( string);
+ glEnd();
+
+ glPopAttrib();
+}