Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: State question

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2001
    Posts
    11

    State question

    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?

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Feb 2002
    Location
    Bonn, Germany
    Posts
    1,652

    Re: State question

    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.

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Oct 2000
    Location
    Belgium
    Posts
    857

    Re: State question

    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

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    3,115

    Re: State question

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •