Sign in to follow this  

setting filtering: per texture unit or per texture?

This topic is 4375 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

as in, If i set the filtering to, say, nearest. does this stick with the texture objet (whenever I bind that texture, filtering is st to nearest) or with the active texture unit, no matter what texture I load, until I change this? TIA

Share this post


Link to post
Share on other sites
Quote:
Original post by Code-R
as in, If i set the filtering to, say, nearest. does this stick with the texture objet (whenever I bind that texture, filtering is st to nearest) or with the active texture unit, no matter what texture I load, until I change this?
TIA
glTexParameter* sets parameters which are per texture object.
glTexEnv* sets environment state which is per texture unit.

So to answer your question, it is per texture object.

Share this post


Link to post
Share on other sites
Hi

glTexParameter* is for all textures unit unless the texture overrides it in the bind definition.
(see http://pyopengl.sourceforge.net/documentation/manual/glTexParameter.3G.html
"When the GL_ARB_multitexture extension is supported, glTexParameter specifies the texture parameters for the active texture unit" )
The state is persistent. If you define it one time for a unit and don't call it again in your app, it will last until the end. So all your textures will be affected by it.
It's better to define it only when you need to to avoid state changes.

Hope it could help

Jeckle
www.kjapi.com

Share this post


Link to post
Share on other sites
Quote:
Original post by jeckleDev
Hi

glTexParameter* is for all textures unit unless the texture overrides it in the bind definition.
(see http://pyopengl.sourceforge.net/documentation/manual/glTexParameter.3G.html
"When the GL_ARB_multitexture extension is supported, glTexParameter specifies the texture parameters for the active texture unit" )
The state is persistent. If you define it one time for a unit and don't call it again in your app, it will last until the end. So all your textures will be affected by it.
It's better to define it only when you need to to avoid state changes.

Hope it could help

Jeckle
www.kjapi.com


No, the previous guys are right. glTexParameter sets the parameter only for the currently bound texture object, not the whole unit. You can test it youself simply by doing something like this:

glBindTexture(GL_TEXTURE_2D,texobj1);
glTexParameter*(...,GL_MAG_FILTER,GL_LINEAR);
glBindTexture(GL_TEXTURE_2D,texobj2);
glTexParameter*(...,GL_MAG_FILTER,GL_NEAREST);

glBindTexture(GL_TEXTURE_2D,texobj1);
RenderObject();//Object is rendered with linear filtering
glBindTexture(GL_TEXTURE_2D,texobj2);
RenderObject();//Object is rendered with NEAREST

You will see that, during rendering, filtering will change depending on whether texobj1 or texobj2 is bound, without having to call TexParameterf each time you want to change it. So no, the parameters are not persistent all over the unit, they are saved for each individual texture object. The quote you mentioned obviously means that, when multitexturing is used and multiple texture objects are bound(one for each unit), glTexParameter changes the parameters of the texture object that is currently binded in the active unit.

Share this post


Link to post
Share on other sites
<CORRECTION>
TexParam is Texture OBJECT property.
TexGen/TexEnv are Texture UNIT properties.
See OpenGL specifications (on www.opengl.org).

[Edited by - Ingenu on December 5, 2005 6:06:57 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Ingenu
All glTex* (Env, Param, Gen) are per TEXTURE OBJECT.
See OpenGL specifications (on www.opengl.org).

No, glTexParameter is per texture object, but glTexEnv and glTexGen is per texture unit. As you said, see the specification.

Share this post


Link to post
Share on other sites
Quote:
Original post by Brother Bob
Quote:
Original post by Ingenu
All glTex* (Env, Param, Gen) are per TEXTURE OBJECT.
See OpenGL specifications (on www.opengl.org).

No, glTexParameter is per texture object, but glTexEnv and glTexGen is per texture unit. As you said, see the specification.


Correct. There's some unnecessary misinformation in this thread, we should at least check the specs or test it ourselves before we post something we're unsure about. There's no reason to confuse beginners who read this thread.
Even the original question could be solved if the OP read the manual or did a little test to see if the params are saved per unit or per texture.

Share this post


Link to post
Share on other sites
Quote:
Original post by Brother Bob
Quote:
Original post by Ingenu
All glTex* (Env, Param, Gen) are per TEXTURE OBJECT.
See OpenGL specifications (on www.opengl.org).

No, glTexParameter is per texture object, but glTexEnv and glTexGen is per texture unit. As you said, see the specification.


You're RIGHT !
I can't believe I missed that in the specs, although I now know exactly why I did this mistake :(

For the Record I did quick check what I was saying, I read the attribute linked to Param, Gen & Env which are all "texture" and concluded wrongly that they were per texture object...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hi

explanations about what i said :

Are you assuming that everytime you create a bind you call glTexParameter* to define the filtering behavior ?

// init app : let's define filter behavior for all textures in stage 0
glActiveTextureARB(GL_TEXTURE0);
glTexParameter*(...,GL_MAG_FILTER,GL_LINEAR);
glActiveTextureARB(GL_TEXTURE1);
glTexParameter*(...,GL_MAG_FILTER,GL_NEAREST);

// texture creation
// no filter overrides there ....
glBindTexture(GL_TEXTURE_2D,texobj1);

// let's draw multitextured object ( same texture for both unit)
glActiveTextureARB(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D,texobj1);
glActiveTextureARB(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D,texobj1);
RenderObject();
//Object is rendered with linear filtering on texture stage 0
//and nerest filtering on texture stage 1

So the sentence : "If you define it one time for a unit and don't call it again in your app, it will last until the end" is correct.

binding filtering to textures object is not very flexible.
Since you loose all control on the filtering "per unit" for multitexturing.

I agree also to not confuse beginners here. We are all have been beginners, and did have to deal with "what-is-right-or-wrong" dilemn :)

Jeckle - kjAPI Team

Share this post


Link to post
Share on other sites

This topic is 4375 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this