Commit ce828a7d64477ccf2d4ad1882a3a6bce61fffaa5

henry 2004-08-23T07:18:23

Got rid fo the GL_TEXTURE_2D_BINDING_EXT call in FTTextureGlyph and replaced it with a static member.

diff --git a/include/FTTextureGlyph.h b/include/FTTextureGlyph.h
index 389e6f7..bff82c9 100755
--- a/include/FTTextureGlyph.h
+++ b/include/FTTextureGlyph.h
@@ -48,6 +48,12 @@ class FTGL_EXPORT FTTextureGlyph : public FTGlyph
          */
         virtual float Render( const FTPoint& pen);
         
+        /**
+         * Reset the currently active texture to zero to get into a known state before
+         * drawing a string. This is to get round possible threading issues.
+         */
+        static void FTTextureGlyph::ResetActiveTexture(){ activeTextureID = 0;}
+        
     private:
         /**
          * The width of the glyph 'image'
@@ -77,11 +83,10 @@ class FTGL_EXPORT FTTextureGlyph : public FTGlyph
         /**
          * The texture index of the currently active texture
          *
-         * We call glGetIntegerv( GL_TEXTURE_2D_BINDING, activeTextureID);
-         * to get the currently active texture to try to reduce the number
-         * of texture bind operations
+         * We keep track of the currently active texture to try to reduce the number
+         * of texture bind operations.
          */
-        GLint activeTextureID;
+        static GLint activeTextureID;
         
 };
 
diff --git a/src/FTGLTextureFont.cpp b/src/FTGLTextureFont.cpp
index aa6b645..03fa272 100755
--- a/src/FTGLTextureFont.cpp
+++ b/src/FTGLTextureFont.cpp
@@ -157,6 +157,8 @@ void FTGLTextureFont::Render( const char* string)
     
     glEnable(GL_BLEND);
     glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // GL_ONE
+
+    FTTextureGlyph::ResetActiveTexture();
     
     FTFont::Render( string);
 
@@ -171,6 +173,8 @@ void FTGLTextureFont::Render( const wchar_t* string)
     glEnable(GL_BLEND);
     glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // GL_ONE
     
+    FTTextureGlyph::ResetActiveTexture();
+    
     FTFont::Render( string);
     
     glPopAttrib();
diff --git a/src/FTTextureGlyph.cpp b/src/FTTextureGlyph.cpp
index 5529a89..2739378 100755
--- a/src/FTTextureGlyph.cpp
+++ b/src/FTTextureGlyph.cpp
@@ -1,12 +1,13 @@
 #include    "FTTextureGlyph.h"
 
-
+GLint FTTextureGlyph::activeTextureID = 0;
+ 
 FTTextureGlyph::FTTextureGlyph( FT_GlyphSlot glyph, int id, int xOffset, int yOffset, GLsizei width, GLsizei height)
 :   FTGlyph( glyph),
     destWidth(0),
     destHeight(0),
-    glTextureID(id),
-    activeTextureID(0)
+    glTextureID(id)//,
+//    activeTextureID(0)
 {
     err = FT_Render_Glyph( glyph, FT_RENDER_MODE_NORMAL);
     if( err || glyph->format != ft_glyph_format_bitmap)
@@ -57,10 +58,10 @@ FTTextureGlyph::~FTTextureGlyph()
 
 float FTTextureGlyph::Render( const FTPoint& pen)
 {
-    glGetIntegerv( GL_TEXTURE_2D_BINDING_EXT, &activeTextureID);
     if( activeTextureID != glTextureID)
     {
         glBindTexture( GL_TEXTURE_2D, (GLuint)glTextureID);
+        activeTextureID = glTextureID;
     }
     
     glTranslatef(  pen.x,  pen.y, 0);