Main Page | Class Hierarchy | Data Structures | File List | Data Fields | Globals

FTPolyGlyph.cpp

Go to the documentation of this file.
00001 #include "FTPolyGlyph.h"
00002 #include "FTVectoriser.h"
00003 
00004 
00005 FTPolyGlyph::FTPolyGlyph( FT_GlyphSlot glyph, bool useDisplayList)
00006 :   FTGlyph( glyph),
00007     glList(0)
00008 {
00009     if( ft_glyph_format_outline != glyph->format)
00010     {
00011         err = 0x14; // Invalid_Outline
00012         return;
00013     }
00014 
00015     FTVectoriser vectoriser( glyph);
00016 
00017     if(( vectoriser.ContourCount() < 1) || ( vectoriser.PointCount() < 3))
00018     {
00019         return;
00020     }
00021     
00022     unsigned int horizontalTextureScale = glyph->face->size->metrics.x_ppem * 64;
00023     unsigned int verticalTextureScale = glyph->face->size->metrics.y_ppem * 64;        
00024         
00025     vectoriser.MakeMesh( 1.0);
00026     
00027     if( useDisplayList)
00028     {
00029         glList = glGenLists( 1);
00030         glNewList( glList, GL_COMPILE);
00031     }
00032 
00033     const FTMesh* mesh = vectoriser.GetMesh();
00034     for( unsigned int index = 0; index < mesh->TesselationCount(); ++index)
00035     {
00036         const FTTesselation* subMesh = mesh->Tesselation( index);
00037         unsigned int polyonType = subMesh->PolygonType();
00038 
00039         glBegin( polyonType);
00040             for( unsigned int pointIndex = 0; pointIndex < subMesh->PointCount(); ++pointIndex)
00041             {
00042                 FTPoint point = subMesh->Point(pointIndex);
00043                 
00044                 glTexCoord2f( point.X() / horizontalTextureScale,
00045                               point.Y() / verticalTextureScale);
00046                 
00047                 glVertex3f( point.X() / 64.0f,
00048                             point.Y() / 64.0f,
00049                             0.0f);
00050             }
00051         glEnd();
00052     }
00053 
00054     if(useDisplayList)
00055     {
00056         glEndList();
00057     }
00058 }
00059 
00060 
00061 FTPolyGlyph::~FTPolyGlyph()
00062 {
00063     glDeleteLists( glList, 1);
00064 }
00065 
00066 
00067 const FTPoint& FTPolyGlyph::Render( const FTPoint& pen)
00068 {
00069     glTranslatef(  pen.X(),  pen.Y(), 0.0f);
00070 
00071     if( glList)
00072     {
00073         glCallList( glList);    
00074     }
00075     
00076     return advance;
00077 }

Generated on Sun Dec 5 22:24:06 2004 for FTGL by doxygen 1.3.6