Hi all! I was wondering if texture parameters where stored in texture unit (glActiveTexture) or “texture name”?
For example, If I have:
// gen texture
// change texture unit and bind
// set a parameter to the texture
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
// change texture unit and bind the same texture
int param = -1;
glGetTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, ¶m);
Is param will be GL_NEAREST?
The implicit question is: “Are texture parameters attached to texture unit or texture image?”
Thanks in advance!
They’re stored in the texture itself (or in a sampler object if one is bound).
In OpenGL 4.5, you can use glTextureParameter() (note “Texture” rather than “Tex”) to set the parameters of a specific texture referenced by name, which need not be bound to any texture unit.
Related, if you’re not using OpenGL 4.5 (or can’t assume the GPU drivers have it) yet, you can still get at this through the EXT_direct_state_access or ARB_direct_state_access extensions. The EXT version has been out there since 2008, so there’s a good chance your drivers may support it. For more details, see Direct State Access in the OpenGL wiki.
Thanks for you answers!
I know there is glTextureParameter() (and didn’t know about extensions, thanks for this!) but I’m limited to strict OpenGL 2.1 (something I should have said, sorry).
My question was: Regarding the previous code, is param will be GL_NEAREST?
You mean texture referenced by name?
So param will be GL_NEAREST right?
This page is pretty clear:
Things managed using glGen/glBind/glDelete are OpenGL Objects.
So textures are OpenGL Objects.
Texture unit are simply used to glBind textures in it and have no parameters.
This would mean, in my code, that param will be GL_NEAREST.
int param = -1;
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, ¶m);
This would mean, in my code, that param will be GL_NEAREST.[/QUOTE]
i think you are mixing something up
param will be -1, because you are trying to set a texture parameter: the address of variable “param”
that should give you an GLerror, did you check that anywhere ?
to get information about an GL object (like a texture), you call glGet…(), in this case:
to set texture parameters, you call:
[QUOTE=john_connor;1284227]i think you are mixing something up
param will be -1, because you are trying to set a texture parameter[/QUOTE]
Sorry, sorry, I meant glGetTexParameter(). I fixed the code. This code is hand written and not tested, I’m just trying to understand texture parameters relations with texture unit.