FTGLTextureFont.h

Go to the documentation of this file.
00001 #ifndef     __FTGLTextureFont__
00002 #define     __FTGLTextureFont__
00003 
00004 #include "FTFont.h"
00005 #include "FTVector.h"
00006 #include "FTGL.h"
00007 
00008 class FTTextureGlyph;
00009 
00010 
00011 /**
00012  * FTGLTextureFont is a specialisation of the FTFont class for handling
00013  * Texture mapped fonts
00014  *
00015  * @see     FTFont
00016  */
00017 class  FTGL_EXPORT FTGLTextureFont : public FTFont
00018 {
00019     public:
00020         /**
00021          * Open and read a font file. Sets Error flag.
00022          *
00023          * @param fontFilePath  font file path.
00024          */
00025         FTGLTextureFont( const char* fontFilePath);
00026         
00027         /**
00028          * Open and read a font from a buffer in memory. Sets Error flag.
00029          *
00030          * @param pBufferBytes  the in-memory buffer
00031          * @param bufferSizeInBytes  the length of the buffer in bytes
00032          */
00033         FTGLTextureFont( const unsigned char *pBufferBytes, size_t bufferSizeInBytes);
00034         
00035         /**
00036          * Destructor
00037          */
00038         virtual ~FTGLTextureFont();
00039 
00040         /**
00041             * Set the char size for the current face.
00042          *
00043          * @param size      the face size in points (1/72 inch)
00044          * @param res       the resolution of the target device.
00045          * @return          <code>true</code> if size was set correctly
00046          */
00047         virtual bool FaceSize( const unsigned int size, const unsigned int res = 72);
00048 
00049         /**
00050          * Prepare for rendering
00051          */
00052         virtual void PreRender();
00053 
00054         /**
00055          * Cleanup after rendering
00056          */
00057         virtual void PostRender();
00058         
00059     private:
00060         /**
00061          * Construct a FTTextureGlyph.
00062          *
00063          * @param glyphIndex The glyph index NOT the char code.
00064          * @return  An FTTextureGlyph or <code>null</code> on failure.
00065          */
00066         inline virtual FTGlyph* MakeGlyph( unsigned int glyphIndex);
00067                 
00068         /**
00069          * Get the size of a block of memory required to layout the glyphs
00070          *
00071          * Calculates a width and height based on the glyph sizes and the
00072          * number of glyphs. It over estimates.
00073          */
00074         inline void CalculateTextureSize();
00075 
00076         /**
00077          * Creates a 'blank' OpenGL texture object.
00078          *
00079          * The format is GL_ALPHA and the params are
00080          * GL_TEXTURE_WRAP_S = GL_CLAMP
00081          * GL_TEXTURE_WRAP_T = GL_CLAMP
00082          * GL_TEXTURE_MAG_FILTER = GL_LINEAR
00083          * GL_TEXTURE_MIN_FILTER = GL_LINEAR
00084          * Note that mipmapping is NOT used
00085          */
00086         inline GLuint CreateTexture();
00087         
00088         /**
00089          * The maximum texture dimension on this OpenGL implemetation
00090          */
00091         GLsizei maximumGLTextureSize;
00092         
00093         /**
00094          * The minimum texture width required to hold the glyphs
00095          */
00096         GLsizei textureWidth;
00097         
00098         /**
00099          * The minimum texture height required to hold the glyphs
00100          */
00101         GLsizei textureHeight;
00102         
00103         /**
00104          *An array of texture ids
00105          */
00106          FTVector<GLuint> textureIDList;
00107         
00108         /**
00109          * The max height for glyphs in the current font
00110          */
00111         int glyphHeight;
00112 
00113         /**
00114          * The max width for glyphs in the current font
00115          */
00116         int glyphWidth;
00117 
00118         /**
00119          * A value to be added to the height and width to ensure that
00120          * glyphs don't overlap in the texture
00121          */
00122         unsigned int padding;
00123         
00124         /**
00125          *
00126          */
00127          unsigned int numGlyphs;
00128         
00129         /**
00130          */
00131         unsigned int remGlyphs;
00132 
00133         /**
00134          */
00135         int xOffset;
00136 
00137         /**
00138          */
00139         int yOffset;
00140 
00141 };
00142 
00143 
00144 #endif // __FTGLTextureFont__
00145 
00146 

Generated on Tue Jul 5 14:16:15 2011 for ROOT_528-00b_version by  doxygen 1.5.1