Changing texture filtering on the fly?

How can I change texture filtering on the fly? Do I actually got to re-load my textures and change the filtering at that moment?.

Also, I have another question (regarding tex filtering as well).

I found this code:

witch (filt) {
case POINT:/* point sampling of nearest neighbor /
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
break;
case BILINEAR:/
bilinear interpolation /
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
break;
case TRILINEAR:/
trilinear interpolation on pyramid */
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_LINEAR);
break;
}

Is it ok?, or theres something wrong with the settings?. I need linear, bilinear and trilinear filtering.

Although what I care most right now, is how to change the filtering on the fly.

Thanks in advance.

The code is perfectly fine. You can change the minifacation/magnification settings (almost) any time you like. They will stay until you change them again.

The only thing you have to keep in mind is that GL_MIPMAP needs all mipmap levels defined. So you can only activate trilinear filtering when your texture actually has mipmaps.

No, there is no need to reload a texture.
Be sure to call glBindTexture before making those GL calls because the settings are part of the texture object.

Those are the definitions for POINT, BILINEAR. I’m not sure about trilinear because it could be
GL_LINEAR_MIPMAP_LINEAR, GL_NEAREST_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_NEAREST

Hi, thanks!

I’ll try this out.

By the way I do really need actual trilinear, how can I get to know which is it?.. I cant find any paper about it.

thanks.

GL_LINEAR_MIPMAP_LINEAR is what is called trilinear filtering.

GL_NEAREST_MIPMAP_NEAREST is nearest neighbor filtering using the best matching mipmap.

GL_LINEAR_MIPMAP_NEAREST is linear filtering on the best matching mipmap.

GL_NEAREST_MIPMAP_LINEAR is nearest neighbor filtering on the linear interpolation of the nearest two mipmaps.

I thought that trilinier and anisotropy is the same. If it’s right you should use extension

Anisotropy is an additional functionality which reduces the blur introduced by trilinear filtering when looking at a surface at a steep angle. See Wikipedia - Anisotropic filtering for more information.