Changed FTGLTextureFont to use FTVector for texture id list.
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
diff --git a/include/FTGLTextureFont.h b/include/FTGLTextureFont.h
index ef95226..f057514 100755
--- a/include/FTGLTextureFont.h
+++ b/include/FTGLTextureFont.h
@@ -2,6 +2,7 @@
#define __FTGLTextureFont__
#include "FTFont.h"
+#include "FTVector.h"
#include "FTGL.h"
class FTTextureGlyph;
@@ -107,14 +108,9 @@ class FTGL_EXPORT FTGLTextureFont : public FTFont
/**
*An array of texture ids
*/
- GLuint glTextureID[128];
+ FTVector<GLuint> textureIDList;
/**
- * The number of textures required to hold the glyphs
- */
- unsigned int numTextures;
-
- /**
* The max height for glyphs in the current font
*/
int glyphHeight;
diff --git a/src/FTGLTextureFont.cpp b/src/FTGLTextureFont.cpp
index fe7335e..aa6b645 100755
--- a/src/FTGLTextureFont.cpp
+++ b/src/FTGLTextureFont.cpp
@@ -23,7 +23,6 @@ FTGLTextureFont::FTGLTextureFont( const char* fontname)
maxTextSize(0),
textureWidth(0),
textureHeight(0),
- numTextures(0),
glyphHeight(0),
glyphWidth(0),
padding(3),
@@ -39,7 +38,6 @@ FTGLTextureFont::FTGLTextureFont( const unsigned char *pBufferBytes, size_t buff
maxTextSize(0),
textureWidth(0),
textureHeight(0),
- numTextures(0),
glyphHeight(0),
glyphWidth(0),
padding(3),
@@ -52,7 +50,7 @@ FTGLTextureFont::FTGLTextureFont( const unsigned char *pBufferBytes, size_t buff
FTGLTextureFont::~FTGLTextureFont()
{
- glDeleteTextures( numTextures, (const GLuint*)glTextureID);
+ glDeleteTextures( textureIDList.size(), (const GLuint*)&textureIDList[0]);
}
@@ -65,11 +63,10 @@ FTGlyph* FTGLTextureFont::MakeGlyph( unsigned int glyphIndex)
glyphHeight = static_cast<int>( charSize.Height());
glyphWidth = static_cast<int>( charSize.Width());
- if( numTextures == 0)
+ if( textureIDList.empty())
{
- glTextureID[0] = CreateTexture();
+ textureIDList.push_back( CreateTexture());
xOffset = yOffset = padding;
- ++numTextures;
}
if( xOffset > ( textureWidth - glyphWidth))
@@ -79,13 +76,12 @@ FTGlyph* FTGLTextureFont::MakeGlyph( unsigned int glyphIndex)
if( yOffset > ( textureHeight - glyphHeight))
{
- glTextureID[numTextures] = CreateTexture();
- ++numTextures;
+ textureIDList.push_back( CreateTexture());
yOffset = padding;
}
}
- FTTextureGlyph* tempGlyph = new FTTextureGlyph( ftGlyph, glTextureID[numTextures - 1],
+ FTTextureGlyph* tempGlyph = new FTTextureGlyph( ftGlyph, textureIDList[textureIDList.size() - 1],
xOffset, yOffset, textureWidth, textureHeight);
xOffset += static_cast<int>( tempGlyph->BBox().upperX - tempGlyph->BBox().lowerX + padding);
@@ -145,10 +141,9 @@ GLuint FTGLTextureFont::CreateTexture()
bool FTGLTextureFont::FaceSize( const unsigned int size, const unsigned int res)
{
- if( numTextures)
+ if( !textureIDList.empty())
{
- glDeleteTextures( numTextures, (const GLuint*)glTextureID);
- numTextures = 0;
+ glDeleteTextures( textureIDList.size(), (const GLuint*)&textureIDList[0]);
remGlyphs = numGlyphs = face.GlyphCount();
}