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 2 of 2

Thread: Binding different targets to same unit?

  1. #1
    Junior Member Regular Contributor
    Join Date
    Mar 2009
    Location
    Seattle, WA
    Posts
    217

    Binding different targets to same unit?

    Can I bind and use two textures on the same texture unit if they have different targets? For example, is it correct to do this?:
    glActiveTexture(GL_TEXTURE0 + 5);
    glBindTexture(GL_TEXTURE_2D, diffusemap);
    glBindTexture(GL_TEXTURE_3D, envmap);

    And then use both of them in the shader?

    In other words, does each texture unit support one texture, or one texture per target?

  2. #2
    Senior Member OpenGL Lord
    Join Date
    May 2009
    Posts
    6,050
    Can I bind and use two textures on the same texture unit if they have different targets?
    Unfortunately yes. But you shouldn't bother because:

    And then use both of them in the shader?
    No, you cannot. You can bind them, but you cannot use them. That's why it's unfortunately that the API allows you to bind textures with different targets to the same texture unit.

    If you try to do so (by setting two different samplers to the same texture unit), you will get a GL_INVALID_OPERATION error at rendering time.

Posting Permissions

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