Added an assert for a 0 maximum texture size. This is tripping some people up.
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
diff --git a/include/FTGLTextureFont.h b/include/FTGLTextureFont.h
index f057514..2065e1e 100755
--- a/include/FTGLTextureFont.h
+++ b/include/FTGLTextureFont.h
@@ -93,7 +93,7 @@ class FTGL_EXPORT FTGLTextureFont : public FTFont
/**
* The maximum texture dimension on this OpenGL implemetation
*/
- GLsizei maxTextSize;
+ GLsizei maximumGLTextureSize;
/**
* The minimum texture width required to hold the glyphs
diff --git a/src/FTGLTextureFont.cpp b/src/FTGLTextureFont.cpp
index 03fa272..357593e 100755
--- a/src/FTGLTextureFont.cpp
+++ b/src/FTGLTextureFont.cpp
@@ -20,7 +20,7 @@ inline GLuint NextPowerOf2( GLuint in)
FTGLTextureFont::FTGLTextureFont( const char* fontname)
: FTFont( fontname),
- maxTextSize(0),
+ maximumGLTextureSize(0),
textureWidth(0),
textureHeight(0),
glyphHeight(0),
@@ -35,7 +35,7 @@ FTGLTextureFont::FTGLTextureFont( const char* fontname)
FTGLTextureFont::FTGLTextureFont( const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
: FTFont( pBufferBytes, bufferSizeInBytes),
- maxTextSize(0),
+ maximumGLTextureSize(0),
textureWidth(0),
textureHeight(0),
glyphHeight(0),
@@ -96,21 +96,19 @@ FTGlyph* FTGLTextureFont::MakeGlyph( unsigned int glyphIndex)
void FTGLTextureFont::CalculateTextureSize()
{
- if( !maxTextSize)
+ if( !maximumGLTextureSize)
{
- glGetIntegerv( GL_MAX_TEXTURE_SIZE, (GLint*)&maxTextSize);
+ glGetIntegerv( GL_MAX_TEXTURE_SIZE, (GLint*)&maximumGLTextureSize);
+ assert(maximumGLTextureSize); // If you hit this then you have an invalid OpenGL context.
}
textureWidth = NextPowerOf2( (remGlyphs * glyphWidth) + ( padding * 2));
- if( textureWidth > maxTextSize)
- {
- textureWidth = maxTextSize;
- }
+ textureWidth = textureWidth > maximumGLTextureSize ? maximumGLTextureSize : textureWidth;
int h = static_cast<int>( (textureWidth - ( padding * 2)) / glyphWidth);
textureHeight = NextPowerOf2( (( numGlyphs / h) + 1) * glyphHeight);
- textureHeight = textureHeight > maxTextSize ? maxTextSize : textureHeight;
+ textureHeight = textureHeight > maximumGLTextureSize ? maximumGLTextureSize : textureHeight;
}