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: which texture is loaded

Hybrid View

  1. #1
    Intern Contributor
    Join Date
    Oct 2012
    Posts
    50

    which texture is loaded

    hi

    i have a sampler in my shader called mytex

    uniform sampler3D mytex;

    iLocation is the location of mytex .

    glUniform1i(iLocation,0);

    so a texture whose texture id is 0 is sampled using mytex in the shader.

    my problem is that the code is fairly large and spread out in multiple files and i am having trouble locating which loaded texture is set to texture id 0. is there a way i can find this (in a reverse lookup sort of way at the point where i bind glUniform1i(iLocation,0))?

    THANKS

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    985
    Quote Originally Posted by driver View Post
    so a texture whose texture id is 0 is sampled using mytex in the shader.
    No, not "a texture whose texture id is 0". The 3D texture object which is bound to texture unit 0. Texture ID and texture unit index are two different things.

    Also, if you have such troubles you should revise the design of your application.

    If what you want to know is the ID of the 3D texture that is bound to texture unit 0, you can query that using glGetIntegerv with a pname of GL_TEXTURE_BINDING_3D. However, using glGet* is a bad pattern and might hit your performance compared to if you would track it on your own.

    Also, don't forget that there could be more textures bound to the same texture unit, one per texture target. I.e. you can have a 2D and a 3D texture both bound to texture unit 0 (how useless is that btw) and practically the sampler uniform declaration in the GLSL code decides which one will be actually used (i.e. in your case obviously the 3D texture binding point).
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

Tags for this Thread

Posting Permissions

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