Hash :
019af0d2
Author :
Date :
2001-07-26T05:11:34
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
#include "gl.h"
#include "FTGLTextureFont.h"
#include "FTGlyphContainer.h"
#include "FTGL.h"
inline UInt32 NextPowerOf2( UInt32 in)
{
in -= 1;
in |= in >> 16;
in |= in >> 8;
in |= in >> 4;
in |= in >> 2;
in |= in >> 1;
return in + 1;
}
FTGLTextureFont::FTGLTextureFont()
: glTextureID(0),
textMem(0)
{
glGetIntegerv( GL_MAX_TEXTURE_SIZE, &maxTextSize);
glGenTextures( 1, &glTextureID);
}
FTGLTextureFont::~FTGLTextureFont()
{
glDeleteTextures( 1, &glTextureID);
delete [] texMem;
}
bool FTGLTextureFont::CreateTexture()
{
// calc the area required for this font
int glyphHeight = ftFace->size->metrics-> + padding;
int glyphWidth = ftFace->size->metrics-> + padding;
// calc the smallest texture size to fit the glyphs
// this is bit naff!!
for(int s = 64; s < maxTextSize; s = s * s)
{
int size = s -padding - padding;
horizGlyphs = static_cast<int>( size / glyphWidth);
vertGlyphs = static_cast<int>( numGlyphs / horizGlyphs);
if( vertGlyphs * glyphHeight < size)
break;
}
vertGlyphs = static_cast<int>( ( textureSize - padding) / glyphHeight);
horizGlyphs = static_cast<int>( ( textureSize - padding) / glyphWidth);
// build the texture.
textMem = unsigned char[ s * s]; // GL_ALPHA texture;
}
bool FTGLTextureFont::MakeGlyphList()
{
FT_Face* ftFace = face.Face();
CreateTexture();
int currentTextX = padding;
int currentTextY = padding;
currGlyph = 0;
for( int y = 0; y < horizGlyphs; ++y)
{
for( int x = 0; x < vertGlyphs; ++x)
{
}
}
}