Removed unnecessary translates in the glyph rendering code.
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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
diff --git a/demo/FTGLDemo.cpp b/demo/FTGLDemo.cpp
index 75b9718..e17bc24 100644
--- a/demo/FTGLDemo.cpp
+++ b/demo/FTGLDemo.cpp
@@ -150,9 +150,9 @@ void renderFontmetrics()
// Draw the bounding box
glDisable( GL_LIGHTING);
glDisable( GL_TEXTURE_2D);
- glEnable( GL_LINE_SMOOTH);
- glEnable(GL_BLEND);
- glBlendFunc( GL_SRC_ALPHA, GL_ONE); // GL_ONE_MINUS_SRC_ALPHA
+ glEnable( GL_LINE_SMOOTH);
+ glEnable(GL_BLEND);
+ glBlendFunc( GL_SRC_ALPHA, GL_ONE); // GL_ONE_MINUS_SRC_ALPHA
glColor3f( 0.0, 1.0, 0.0);
// Draw the front face
@@ -286,9 +286,15 @@ void do_display (void)
// you will need to explicitly call glRasterPos3f (or its ilk) to lock
// in a changed current color.
- fonts[current_font]->Render( myString);
+ glPushMatrix();
+ fonts[current_font]->Render( myString);
+ glPopMatrix();
+
+ glPushMatrix();
renderFontmetrics();
- renderFontInfo();
+ glPopMatrix();
+
+ renderFontInfo();
}
diff --git a/src/FTBitmapGlyph.cpp b/src/FTBitmapGlyph.cpp
index 5db33f1..d823b95 100755
--- a/src/FTBitmapGlyph.cpp
+++ b/src/FTBitmapGlyph.cpp
@@ -52,15 +52,15 @@ FTBitmapGlyph::~FTBitmapGlyph()
float FTBitmapGlyph::Render( const FTPoint& pen)
{
+ glBitmap( 0, 0, 0.0, 0.0, pen.x + pos.x, pen.y - pos.y, (const GLubyte*)0 );
+
if( data)
{
- glBitmap( 0, 0, 0.0, 0.0, pen.x + pos.x, pen.y - pos.y, (const GLubyte*)0 );
-
glPixelStorei( GL_UNPACK_ROW_LENGTH, destPitch * 8);
glBitmap( destWidth, destHeight, 0.0f, 0.0, 0.0, 0.0, (const GLubyte*)data);
-
- glBitmap( 0, 0, 0.0, 0.0, -pen.x - pos.x, -pen.y + pos.y, (const GLubyte*)0 );
}
+ glBitmap( 0, 0, 0.0, 0.0, -pos.x, pos.y, (const GLubyte*)0 );
+
return advance;
}
diff --git a/src/FTExtrdGlyph.cpp b/src/FTExtrdGlyph.cpp
index 0b120e6..bb1bcfe 100644
--- a/src/FTExtrdGlyph.cpp
+++ b/src/FTExtrdGlyph.cpp
@@ -107,11 +107,11 @@ FTExtrdGlyph::~FTExtrdGlyph()
float FTExtrdGlyph::Render( const FTPoint& pen)
{
+ glTranslatef( pen.x, pen.y, 0);
+
if( glList)
{
- glTranslatef( pen.x, pen.y, 0);
- glCallList( glList);
- glTranslatef( -pen.x, -pen.y, 0);
+ glCallList( glList);
}
return advance;
diff --git a/src/FTFont.cpp b/src/FTFont.cpp
index d0fa34b..b0beb5f 100755
--- a/src/FTFont.cpp
+++ b/src/FTFont.cpp
@@ -256,8 +256,8 @@ void FTFont::DoRender( const unsigned int chr, const unsigned int nextChr)
FTPoint kernAdvance = glyphList->Render( chr, nextChr, pen);
- pen.x += kernAdvance.x;
- pen.y += kernAdvance.y;
+ pen.x = kernAdvance.x;
+ pen.y = kernAdvance.y;
}
diff --git a/src/FTOutlineGlyph.cpp b/src/FTOutlineGlyph.cpp
index 340c780..bab9779 100644
--- a/src/FTOutlineGlyph.cpp
+++ b/src/FTOutlineGlyph.cpp
@@ -45,11 +45,11 @@ FTOutlineGlyph::~FTOutlineGlyph()
float FTOutlineGlyph::Render( const FTPoint& pen)
{
+ glTranslatef( pen.x, pen.y, 0);
+
if( glList)
{
- glTranslatef( pen.x, pen.y, 0);
- glCallList( glList);
- glTranslatef( -pen.x, -pen.y, 0);
+ glCallList( glList);
}
return advance;
diff --git a/src/FTPixmapGlyph.cpp b/src/FTPixmapGlyph.cpp
index 5b565b5..708bb39 100755
--- a/src/FTPixmapGlyph.cpp
+++ b/src/FTPixmapGlyph.cpp
@@ -86,18 +86,15 @@ FTPixmapGlyph::~FTPixmapGlyph()
float FTPixmapGlyph::Render( const FTPoint& pen)
{
+ glBitmap( 0, 0, 0.0f, 0.0f, pen.x + pos.x, pen.y - pos.y, (const GLubyte*)0);
+
if( data)
{
- // Move the glyph origin
- glBitmap( 0, 0, 0.0f, 0.0f, pen.x + pos.x, pen.y - pos.y, (const GLubyte*)0);
-
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0);
-
glDrawPixels( destWidth, destHeight, GL_RGBA, GL_UNSIGNED_BYTE, (const GLvoid*)data);
-
- // Restore the glyph origin
- glBitmap( 0, 0, 0.0f, 0.0f, -pen.x - pos.x, -pen.y + pos.y, (const GLubyte*)0);
}
+
+ glBitmap( 0, 0, 0.0f, 0.0f, -pos.x, pos.y, (const GLubyte*)0);
return advance;
}
diff --git a/src/FTPolyGlyph.cpp b/src/FTPolyGlyph.cpp
index 7e0d695..058f480 100644
--- a/src/FTPolyGlyph.cpp
+++ b/src/FTPolyGlyph.cpp
@@ -51,11 +51,11 @@ FTPolyGlyph::~FTPolyGlyph()
float FTPolyGlyph::Render( const FTPoint& pen)
{
+ glTranslatef( pen.x, pen.y, 0);
+
if( glList)
{
- glTranslatef( pen.x, pen.y, 0);
glCallList( glList);
- glTranslatef( -pen.x, -pen.y, 0);
}
return advance;
diff --git a/src/FTTextureGlyph.cpp b/src/FTTextureGlyph.cpp
index 4b29268..5529a89 100755
--- a/src/FTTextureGlyph.cpp
+++ b/src/FTTextureGlyph.cpp
@@ -63,18 +63,20 @@ float FTTextureGlyph::Render( const FTPoint& pen)
glBindTexture( GL_TEXTURE_2D, (GLuint)glTextureID);
}
+ glTranslatef( pen.x, pen.y, 0);
+
glBegin( GL_QUADS);
glTexCoord2f( uv[0].x, uv[0].y);
- glVertex2f( pen.x + pos.x, pen.y + pos.y);
+ glVertex2f( pos.x, pos.y);
glTexCoord2f( uv[0].x, uv[1].y);
- glVertex2f( pen.x + pos.x, pen.y + pos.y - destHeight);
+ glVertex2f( pos.x, pos.y - destHeight);
glTexCoord2f( uv[1].x, uv[1].y);
- glVertex2f( pen.x + destWidth + pos.x, pen.y + pos.y - destHeight);
+ glVertex2f( destWidth + pos.x, pos.y - destHeight);
glTexCoord2f( uv[1].x, uv[0].y);
- glVertex2f( pen.x + destWidth + pos.x, pen.y + pos.y);
+ glVertex2f( destWidth + pos.x, pos.y);
glEnd();
return advance;