Added texture co-ordinate generation.
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
diff --git a/src/FTExtrdGlyph.cpp b/src/FTExtrdGlyph.cpp
index bb1bcfe..c2c5bd7 100644
--- a/src/FTExtrdGlyph.cpp
+++ b/src/FTExtrdGlyph.cpp
@@ -30,6 +30,8 @@ FTExtrdGlyph::FTExtrdGlyph( FT_GlyphSlot glyph, float d)
vectoriser.MakeMesh( 1.0);
glNormal3d(0.0, 0.0, 1.0);
+ unsigned int textureCoordRange = glyph->face->units_per_EM;
+
const FTMesh* mesh = vectoriser.GetMesh();
for( tesselationIndex = 0; tesselationIndex < mesh->TesselationCount(); ++tesselationIndex)
{
@@ -39,6 +41,9 @@ FTExtrdGlyph::FTExtrdGlyph( FT_GlyphSlot glyph, float d)
glBegin( polyonType);
for( unsigned int pointIndex = 0; pointIndex < subMesh->PointCount(); ++pointIndex)
{
+ glTexCoord2f( subMesh->Point(pointIndex).x / textureCoordRange,
+ subMesh->Point(pointIndex).y / textureCoordRange);
+
glVertex3f( subMesh->Point( pointIndex).x / 64.0f,
subMesh->Point( pointIndex).y / 64.0f,
0.0f);
@@ -58,6 +63,9 @@ FTExtrdGlyph::FTExtrdGlyph( FT_GlyphSlot glyph, float d)
glBegin( polyonType);
for( unsigned int pointIndex = 0; pointIndex < subMesh->PointCount(); ++pointIndex)
{
+ glTexCoord2f( subMesh->Point(pointIndex).x / textureCoordRange,
+ subMesh->Point(pointIndex).y / textureCoordRange);
+
glVertex3f( subMesh->Point( pointIndex).x / 64.0f,
subMesh->Point( pointIndex).y / 64.0f,
-depth);
@@ -83,11 +91,17 @@ FTExtrdGlyph::FTExtrdGlyph( FT_GlyphSlot glyph, float d)
if( contourFlag & ft_outline_reverse_fill)
{
+ glTexCoord2f( contour->Point(index).x / textureCoordRange,
+ contour->Point(index).y / textureCoordRange);
+
glVertex3f( contour->Point(index).x / 64.0f, contour->Point(index).y / 64.0f, 0.0f);
glVertex3f( contour->Point(index).x / 64.0f, contour->Point(index).y / 64.0f, -depth);
}
else
{
+ glTexCoord2f( contour->Point(index).x / textureCoordRange,
+ contour->Point(index).y / textureCoordRange);
+
glVertex3f( contour->Point(index).x / 64.0f, contour->Point(index).y / 64.0f, -depth);
glVertex3f( contour->Point(index).x / 64.0f, contour->Point(index).y / 64.0f, 0.0f);
}
diff --git a/src/FTPolyGlyph.cpp b/src/FTPolyGlyph.cpp
index 058f480..4deef59 100644
--- a/src/FTPolyGlyph.cpp
+++ b/src/FTPolyGlyph.cpp
@@ -18,6 +18,8 @@ FTPolyGlyph::FTPolyGlyph( FT_GlyphSlot glyph)
{
return;
}
+
+ unsigned int textureCoordRange = glyph->face->units_per_EM;
vectoriser.MakeMesh( 1.0);
@@ -31,10 +33,13 @@ FTPolyGlyph::FTPolyGlyph( FT_GlyphSlot glyph)
unsigned int polyonType = subMesh->PolygonType();
glBegin( polyonType);
- for( unsigned int x = 0; x < subMesh->PointCount(); ++x)
+ for( unsigned int pointIndex = 0; pointIndex < subMesh->PointCount(); ++pointIndex)
{
- glVertex3f( subMesh->Point(x).x / 64.0f,
- subMesh->Point(x).y / 64.0f,
+ glTexCoord2f( subMesh->Point(pointIndex).x / textureCoordRange,
+ subMesh->Point(pointIndex).y / textureCoordRange);
+
+ glVertex3f( subMesh->Point(pointIndex).x / 64.0f,
+ subMesh->Point(pointIndex).y / 64.0f,
0.0f);
}
glEnd();