PDA

View Full Version : glTexParameters and multiple textures



wprice99
06-27-2004, 05:13 AM
Do glTexParameter() calls affect the currently bound texture only, or are they global to the current texture unit?

So, for example, can I assign GL_TEXTURE_MAG_FILTER to GL_NEAREST for texture A, and to GL_MIPMAP_NEAREST_LINEAR for texture B?

e.g.

glBindTexture(GL_TEXTURE_2D, textureA);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, ...)
...
glBindTexture(GL_TEXTURE_2D, textureB);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_MIPMAP_NEAREST_LINEAR);
glTexImage2D(GL_TEXTURE_2D, ...)
...then, when rendering, just

glBindTexture(GL_TEXTURE_2D, textureA);
... draw with nearest filtering ...
glBindTexture(GL_TEXTURE_2D, textureB);
... draw with mipmap nearest filtering ...Or would I have to call glTexParameter() before rendering the texture with the appropriate values?

e.g.

glBindTexture(GL_TEXTURE_2D, textureA);
glTexImage2D(GL_TEXTURE_2D, ...)
...
glBindTexture(GL_TEXTURE_2D, textureB);
glTexImage2D(GL_TEXTURE_2D, ...)
...then, when rendering, just

glBindTexture(GL_TEXTURE_2D, textureA);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
... draw with nearest filtering ...
glBindTexture(GL_TEXTURE_2D, textureB);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_MIPMAP_NEAREST_LINEAR);
... draw with mipmap nearest filtering ...

knackered
06-27-2004, 06:16 AM
glTexParameter calls change parameters of the currently bound texture object (and are therefore carried around with that object no matter what), while glTexEnv calls change parameters of the currently active texture stage.
So your example code is correct.