PDA

View Full Version : State question



frink
03-05-2002, 06:06 AM
If I do the following in my code:

glBindTexture(GL_TEXTURE_2D, tex_obj_bind);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, tex_map_x_size,tex_map_y_size, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, map);

and then I go on and change the wrap states and the min and mag filter states and
load some more textures, and then I bind this texture again and draw some polygons
with it, will I have to set back the wrap state and the min and mag filter state? In other words, are ANY states saved when the texture is loaded or is the current state
of the system used when primitives are drawn?

zeckensack
03-05-2002, 06:15 AM
Glspec 1.3, section 3.8:

While a texture object is bound, GL operations on the target to which it is
bound affect the bound object, and queries of the target to which it is bound return
state from the bound object. If texture mapping of the dimensionality of the target
to which a texture object is bound is enabled, the state of the bound texture object
directs the texturing operation.

Hint: your target in this case is GL_TEXTURE_2D

In other words, everything you do to your texture state is saved in your currently bound texture object and will be restored when you bind it again.

Tom Nuydens
03-05-2002, 06:18 AM
All glTexParameter*() state is saved in the currently bound texture object, so you can change the wrap and filtering modes for each texture individually. Note that this is not the case for glTexEnv*() settings.

-- Tom

Bob
03-05-2002, 10:21 AM
Just to add to Tom's post. glTexEnv sets states for the currently active texture unit.