FTGLPixmapFont.cpp

Go to the documentation of this file.
00001 #include    "FTGLPixmapFont.h"
00002 #include    "FTPixmapGlyph.h"
00003 
00004 
00005 FTGLPixmapFont::FTGLPixmapFont( const char* fontFilePath)
00006 :   FTFont( fontFilePath)
00007 {}
00008 
00009 
00010 FTGLPixmapFont::FTGLPixmapFont( const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
00011 :   FTFont( pBufferBytes, bufferSizeInBytes)
00012 {}
00013 
00014 
00015 FTGLPixmapFont::~FTGLPixmapFont()
00016 {}
00017 
00018 
00019 FTGlyph* FTGLPixmapFont::MakeGlyph( unsigned int g)
00020 {
00021     FT_GlyphSlot ftGlyph = face.Glyph( g, FT_LOAD_NO_HINTING);
00022 
00023     if( ftGlyph)
00024     {
00025         FTPixmapGlyph* tempGlyph = new FTPixmapGlyph( ftGlyph);
00026         return tempGlyph;
00027     }
00028 
00029     err = face.Error();
00030     return NULL;
00031 }
00032 
00033 
00034 void FTGLPixmapFont::Render( const char* string)
00035 {   
00036     glPushAttrib( GL_ENABLE_BIT | GL_PIXEL_MODE_BIT | GL_COLOR_BUFFER_BIT);
00037     glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT);
00038 
00039     glEnable(GL_BLEND);
00040     glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00041 
00042     glDisable( GL_TEXTURE_2D);
00043 
00044     GLfloat ftglColour[4];
00045     glGetFloatv( GL_CURRENT_RASTER_COLOR, ftglColour);
00046 
00047     glPixelTransferf(GL_RED_SCALE, ftglColour[0]);
00048     glPixelTransferf(GL_GREEN_SCALE, ftglColour[1]);
00049     glPixelTransferf(GL_BLUE_SCALE, ftglColour[2]);
00050     glPixelTransferf(GL_ALPHA_SCALE, ftglColour[3]);
00051 
00052     FTFont::Render( string);
00053 
00054     glPopClientAttrib();
00055     glPopAttrib();
00056 }
00057 
00058 
00059 void FTGLPixmapFont::Render( const wchar_t* string)
00060 {   
00061     glPushAttrib( GL_ENABLE_BIT | GL_PIXEL_MODE_BIT | GL_COLOR_BUFFER_BIT);
00062     glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT);
00063         
00064     glEnable(GL_BLEND);
00065     glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00066     
00067     glDisable( GL_TEXTURE_2D);
00068 
00069     GLfloat ftglColour[4];
00070     glGetFloatv( GL_CURRENT_RASTER_COLOR, ftglColour);
00071 
00072     glPixelTransferf(GL_RED_SCALE, ftglColour[0]);
00073     glPixelTransferf(GL_GREEN_SCALE, ftglColour[1]);
00074     glPixelTransferf(GL_BLUE_SCALE, ftglColour[2]);
00075     glPixelTransferf(GL_ALPHA_SCALE, ftglColour[3]);
00076 
00077     FTFont::Render( string);
00078 
00079     glPopClientAttrib();
00080     glPopAttrib();
00081 }
00082 
00083 

Generated on Wed May 30 06:16:26 2007 for FTGL by  doxygen 1.5.2