Commit 2a980faa949ae0227e12e3249cce064fd006e1fe

henry 2004-08-22T05:50:33

Removed unnecessary translates in the glyph rendering code.

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;