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

Thread: Determine the texture target from the GLuint

Hybrid View

  1. #1
    Member Regular Contributor
    Join Date
    Jan 2012
    Location
    Germany
    Posts
    325

    Question Determine the texture target from the GLuint

    Hello,


    if I just have the GLuint from a texture object, I can check whether it is in fact a texture (glIsTexture()) but I can't check what target it has, right? I can try to bind it to GL_TEXTURE_2D, GL_TEXTURE_3D etc.. and test which call generated errors and which succeeded. Bound to the right target I can query all kinds of parameters (glGetTexParameter*).
    So my question is, have I overlooked a function that can tell me the kind of texture / the target if all I have is a GLuint from which I only know that it is a texture (result from glIsTexture) ?

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,129
    I don't think there is one - oddly enough - but should be trivial to implement. I guess you'll have to store the info on the application level.

  3. #3
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    This is a hole due to the nature of the API. Remember: DSA doesn't exist. So if you have a texture object, the only way you could ever use it to even query something from it would be to bind it to the context. And glBindTexture will fail if you bind it to the wrong target. So clearly, if you bound it, you must know what target you used. Especially since glGetTexParameter takes the target as a parameter...

    Of course, that in itself tells you one way to do it: try to bind it to every target and see what works and what doesn't.

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,129
    Could be a valid addition to the API though.

    Not that I would use it, but since the GL in some way has to keep track of the target as soon as you first bind the texture object, a glGetTextureTarget(GLuint) which returns either the target or preferably 0 (i.e. GL_NONE) if not bound yet (or generated an error) could be implemented rather easily, I suspect. Being able to query if a name refers to a texture and not being able to query the target if already bound is simply inconsistent.

    I don't quite get how DSA helps here since for any DSA style texture functions (at least from what I remember from GL_EXT_direct_state_access) you need to provide the target as well. Did I miss something?

  5. #5
    Member Regular Contributor
    Join Date
    Jan 2012
    Location
    Germany
    Posts
    325
    Storing the target in the application is what I do in my apps (I wouldn't query it each time I want to bind a texture even if that would be possible...).
    Trying to bind it to each target and see what fails and what works is what I do now in a special use case where I can't store the target (more of a debugging use case). I hoped I would just have missed a way to do it more elegantly.
    What is the best way to suggest something like glGetTextureTarget(GLuint)? This forum or the Khronos Bugzilla? Some other way?

  6. #6
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,129
    I would suggest the appropriate sub-forum but I don't think there is much evidence for anything in there having an actual effect. It would be nice to know in general if anyone relevant to any significant implementation listens to us here in the forum.

    On the the other hand, there are active fellow board members here which have actively contributed to extensions, namely Groovounet and aqnuep, both for AMD. Maybe those guys have anything to say on this which could give us some insight as to why such a function doesn't exist in the first place.

    I can't speak to the Khronos bug tracker and if feature requests are possible and actually evaluated. IIRC, Alfonse has commented on Khronos' bug tracking/fixing behavior in the past, but I might be wrong.

Posting Permissions

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