Got rid of the static and moved the glBegin/glEnd pairs
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
diff --git a/include/FTTextureGlyph.h b/include/FTTextureGlyph.h
index 6de75cc..5ae34a8 100755
--- a/include/FTTextureGlyph.h
+++ b/include/FTTextureGlyph.h
@@ -50,12 +50,11 @@ class FTGL_EXPORT FTTextureGlyph : public FTGlyph
/**
* The texture index of the currently active texture
*
- * Because a a full set of glyphs may not fit on one glyph we need
- * to keep track of the current active texture to try to reduce the
- * number of texture bind operations
+ * We call glGetIntegerv( GL_TEXTURE_2D_BINDING, activeTextureID);
+ * to get the currently active texture to try to reduce the number
+ * of texture bind operations
*/
- // Replace this with glGetIntegerv( GL_TEXTURE_2D_BINDING, activeTextureID);
- static int activeTextureID;
+ GLint activeTextureID;
private:
/**
diff --git a/src/FTTextureGlyph.cpp b/src/FTTextureGlyph.cpp
index 8e17b9e..e874dbb 100755
--- a/src/FTTextureGlyph.cpp
+++ b/src/FTTextureGlyph.cpp
@@ -2,8 +2,6 @@
#include "FTGL.h"
-int FTTextureGlyph::activeTextureID = 0;
-
FTTextureGlyph::FTTextureGlyph( FT_Glyph glyph, int id, unsigned char* data, int stride, int height, float u, float v)
: FTGlyph(),
destWidth(0),
@@ -72,20 +70,20 @@ FTTextureGlyph::~FTTextureGlyph()
float FTTextureGlyph::Render( const FT_Vector& pen)
{
- // This could be really ugly!!
+ glGetIntegerv( GL_TEXTURE_2D_BINDING_EXT, &activeTextureID);
if( activeTextureID != glTextureID)
{
- glEnd();
glBindTexture( GL_TEXTURE_2D, (GLuint)glTextureID);
- activeTextureID = glTextureID;
- glBegin( GL_QUADS);
}
+ glBegin( GL_QUADS);
glTexCoord2f( uv[0].x, uv[0].y); glVertex2f( pen.x + pos.x, pen.y + pos.y);
glTexCoord2f( uv[1].x, uv[0].y); glVertex2f( pen.x + destWidth + pos.x, pen.y + pos.y);
glTexCoord2f( uv[1].x, uv[1].y); glVertex2f( pen.x + destWidth + pos.x, pen.y + pos.y - destHeight);
glTexCoord2f( uv[0].x, uv[1].y); glVertex2f( pen.x + pos.x, pen.y + pos.y - destHeight);
+ glEnd();
return advance;
+
}