Reputation: 395
I use this code to switch between images with mipmaps or not:
if ( tex->hasMipMaps ) {
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR );
}
else {
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
}
however this happens:
the table is rendered without mipmap,but when I change the register texture code to :
// if ( tex->hasMipMaps ) {
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR );
//}
//else {
// glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
// glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
//}
here is the result:
the mipmap works,but my font texture is kind missing,is there a way to render both textures that with mipmaps such as models and some textures without mipmaps such as font,particles?
do I need to call glTexParameteri to switch some states?
Upvotes: 2
Views: 676
Reputation: 52123
Texture objects without a complete set of mipmaps will (generally) render white as you have seen.
You'll have to enable/disable mipmapping on a per-mesh level (assuming one texture per mesh) if some of your textures don't have mipmaps.
Upvotes: 1