I'm loading a font from a TGA texture. I generate the mipmap using the gluBuild2DMipmaps()
function.
When the font has a certain size, it looks very good. But when it gets smaller, it gets darker and darker whenever it reaches a new mipmap level.
This is how I create the texture:
void TgaLoader::bindTexture(unsigned int* texture)
{
tImageTGA *pBitMap = m_tgaImage;
if(pBitMap == 0)
{
return;
}
glGenTextures(1, texture);
glBindTexture(GL_TEXTURE_2D, *texture);
gluBuild2DMipmaps(GL_TEXTURE_2D,
pBitMap->channels,
pBitMap->size_x,
pBitMap->size_y,
textureType,
GL_UNSIGNED_BYTE,
pBitMap->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
This makes the text look like this (it should be white):
Barely visible.
If I change the GL_TEXTURE_MIN_FILTER
to basically ignore mipmaps (using GL_LINEAR
for example), it looks like this:
I've tried different filter options and also tried using glGenerateMipmap()
instead of gluBuild2DMipmaps()
, but I always end up with the same result.
What's wrong with the code?