State question

If I do the following in my code:

glBindTexture(GL_TEXTURE_2D, tex_obj_bind);
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?

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.

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

Just to add to Tom’s post. glTexEnv sets states for the currently active texture unit.