GLuint FTTextureFontImpl::CreateTexture()
{
	CalculateTextureSize();

    int totalMemory = textureWidth * textureHeight;
    unsigned char* textureMemory = new unsigned char[totalMemory];
    memset(textureMemory, 0, totalMemory);
	
    GLuint textID;
    glGenTextures(1, (GLuint*)&textID);

    ftglBindTexture(textID);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, textureWidth, textureHeight,
                 0, GL_ALPHA, GL_UNSIGNED_BYTE, textureMemory);
	
	printf("texture dimensions: %d %d\n", textureWidth, textureHeight);
	
    delete [] textureMemory;

    return textID;
}
void FTPolygonGlyphImpl::DoRender(const FTPoint& pen)
{
    const FTMesh *mesh = vectoriser->GetMesh();

    for (unsigned int t = 0; t < mesh->TesselationCount(); ++t)
    {
        const FTTesselation* subMesh = mesh->Tesselation(t);
        unsigned int polygonType = subMesh->PolygonType();

        ftglBindTexture(0);
        
        ftglBegin(polygonType);
        for(unsigned int i = 0; i < subMesh->PointCount(); ++i)
        {
            FTPoint point = subMesh->Point(i);
            ftglColor4f(1.0f, 1.0f, 1.0f, 1.0f);
            ftglTexCoord2f(point.Xf() / hscale, point.Yf() / vscale);
            ftglVertex3f(pen.Xf() + point.Xf() / 64.0f, pen.Yf() + point.Yf() / 64.0f, 0.0f);
        }
        ftglEnd();
    }
}