Back to index

extremetuxracer  0.5beta
FTOutlineGlyph.cpp
Go to the documentation of this file.
00001 #include    "FTOutlineGlyph.h"
00002 #include    "FTVectoriser.h"
00003 
00004 
00005 FTOutlineGlyph::FTOutlineGlyph( FT_GlyphSlot glyph, bool useDisplayList, GLfloat _width)
00006 :   FTGlyph( glyph),
00007     glList(0),
00008     width(_width)
00009 {
00010     if( ft_glyph_format_outline != glyph->format)
00011     {
00012         err = 0x14; // Invalid_Outline
00013         return;
00014     }
00015 
00016     FTVectoriser vectoriser( glyph);
00017 
00018     size_t numContours = vectoriser.ContourCount();
00019     if ( ( numContours < 1) || ( vectoriser.PointCount() < 3))
00020     {
00021         return;
00022     }
00023 
00024     if(useDisplayList)
00025     {
00026         glList = glGenLists(1);
00027         glNewList( glList, GL_COMPILE);
00028     }
00029     
00030     if(numContours>0) {
00031         glLineWidth(width);
00032     }
00033     
00034     for( unsigned int c = 0; c < numContours; ++c)
00035     {
00036         const FTContour* contour = vectoriser.Contour(c);
00037         
00038         glBegin( GL_LINE_LOOP);
00039             for( unsigned int pointIndex = 0; pointIndex < contour->PointCount(); ++pointIndex)
00040             {
00041                 FTPoint point = contour->Point(pointIndex);
00042                 glVertex2f( point.X() / 64.0f, point.Y() / 64.0f);
00043             }
00044         glEnd();
00045     }
00046 
00047     if(useDisplayList)
00048     {
00049         glEndList();
00050     }
00051 }
00052 
00053 FTOutlineGlyph::~FTOutlineGlyph()
00054 {
00055     glDeleteLists( glList, 1);
00056 }
00057 
00058 
00059 const FTPoint& FTOutlineGlyph::Render( const FTPoint& pen)
00060 {
00061     glTranslatef( pen.X(), pen.Y(), 0.0f);
00062 
00063     if( glList)
00064     {
00065         glCallList( glList);
00066     }
00067     
00068     return advance;
00069 }