Commit 9c4d80122be123fb4a2db79ad38c6553f4f132cf

henry 2004-09-26T09:45:18

Added an assert for a 0 maximum texture size. This is tripping some people up.

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;
 }