PDA

View Full Version : How to sample the same texture using different filter mode?



serg920814
04-04-2005, 10:54 PM
Hello, I'm quite new to opengl, and I would like to know is there a way to sample the same texture using different filter mode. I'm currently using glTexParameteri to specify filter mode. But it seems like that filter mode is property of a texture, not a sampler, thus this piece of code does not behave like I'd expect:
glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_2D, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

seems like the last call to glTexParameteri overwrites filter mode for the GL_TEXTURE0_ARB texture stage.

Thanks,
Sergey.

Relic
04-05-2005, 05:57 AM
glTexParameter is per texture object state.
You need to specify it once on texture object initialization and following glBindTexture calls will set it automatically.

In your case, as usual, OpenGL's state machine keeps the last glTexParameter change at your texture object 1. Following rendering will use that mode for that object.

What you want needs two distinct texture objects with the same texture image but different texture parameters.