Removed the <vector> include and some debug code. Changed the render code to use glDisplayList. There was NO performance improvement but it will make it the same as FTPolyGlyph. Now uses glTranslate for the pen pos, again to make it the same as FTPolyGlyph. Changes because of the changes tp FTPOINT in FTVectoriser.
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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
diff --git a/src/FTVectorGlyph.cpp b/src/FTVectorGlyph.cpp
index abfdd2e..3de78a4 100755
--- a/src/FTVectorGlyph.cpp
+++ b/src/FTVectorGlyph.cpp
@@ -30,13 +30,33 @@ FTVectorGlyph::FTVectorGlyph( FT_Glyph glyph, int gi)
}
numPoints = vectoriser->points();
- data = new float[ numPoints * 2];
+ data = new float[ numPoints * 3];
vectoriser->Output( data);
advance = glyph->advance.x >> 16; // this is 6 in the freetype docs!!!!!!
}
delete vectoriser;
+
+ if ( ( numContours < 1) || ( numPoints < 1))
+ return;
+
+ glList = glGenLists(1);
+ int d = 0;
+
+ glNewList( glList, GL_COMPILE);
+ for( int c = 0; c < numContours; ++c)
+ {
+ glBegin( GL_LINE_LOOP);
+ for( int p = 0; p < ( contourLength[c]); ++p)
+ {
+ glVertex2f( data[d], data[d + 1]);
+ d += 3;
+ }
+ glEnd();
+ }
+ glEndList();
+
}
}
@@ -49,35 +69,9 @@ FTVectorGlyph::~FTVectorGlyph()
float FTVectorGlyph::Render( FT_Vector& pen)
{
- int d = 0;
-
- for( int c = 0; c < numContours; ++c)
- {
-// switch(c)
-// {
-// case 0:
-// glColor3f( 1.0, 0.0, 0.0);
-// break;
-// case 1:
-// glColor3f( 0.0, 1.0, 0.0);
-// break;
-// case 2:
-// glColor3f( 0.0, 0.0, 1.0);
-// break;
-// case 3:
-// glColor3f( 1.0, 1.0, 0.0);
-// break;
-// }
-
- glBegin( GL_LINE_LOOP);
- for( int p = 0; p < ( contourLength[c] * 2); p += 2)
- {
- glVertex2f( data[d] + pen.x, data[d + 1] + pen.y);
-
- d += 2;
- }
- glEnd();
- }
+ glTranslatef( pen.x, pen.y, 0);
+ glCallList( glList);
+ glTranslatef( -pen.x, -pen.y, 0);
return advance;
}
diff --git a/src/FTVectorGlyph.h b/src/FTVectorGlyph.h
index 8cc440d..381f957 100755
--- a/src/FTVectorGlyph.h
+++ b/src/FTVectorGlyph.h
@@ -1,8 +1,6 @@
#ifndef __FTVectorGlyph__
#define __FTVectorGlyph__
-#include <vector>
-
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H
@@ -30,6 +28,7 @@ class FTVectorGlyph : public FTGlyph
int numContours;
int * contourLength;
float* data;
+ int glList;
};