Hello Guest

glIsTexture == resides in gpu?

  • 4 Replies
  • 6892 Views
*

Offline @

  • *
  • 41
glIsTexture == resides in gpu?
« on: October 03, 2013, 17:22:00 »
I need a way to check if a texture was loaded into the GPU (if that is possible). I have found "glIsTexture", but javadoc says nothing about. Is my assumption right?

*

Offline quew8

  • *****
  • 569
  • Because Square Eyes Look More Real
Re: glIsTexture == resides in gpu?
« Reply #1 on: October 03, 2013, 18:37:55 »
I am 99% sure that the glTexImageXD calls are blocking which means that they will not return until the texture is loaded into memory. If the function has returned, the texture is in the GPU.

*

Offline @

  • *
  • 41
Re: glIsTexture == resides in gpu?
« Reply #2 on: October 03, 2013, 21:40:17 »
I am 99% sure that the glTexImageXD calls are blocking which means that they will not return until the texture is loaded into memory. If the function has returned, the texture is in the GPU.

But what if, by any chance, the programmer unbinds (or deletes) the texture from gpu? Is there any way to test this?

*

Offline Cornix

  • *****
  • 488
Re: glIsTexture == resides in gpu?
« Reply #3 on: October 03, 2013, 22:18:11 »
You can check if a texture has been deleted by calling glIsTexture(name).
http://www.opengl.org/sdk/docs/man/xhtml/glIsTexture.xml

If you know the dimension of the texture you can use glGet(dimension) to get the name of the currently bound texture.
http://www.opengl.org/sdk/docs/man/xhtml/glGet.xml

For example your method might look like this:
Code: [Select]
public boolean isTexture2DBound(int textureName) {
return GL11.glIsTexture(textureName) && GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D) == textureName;
}
Which only works for GL_TEXTURE_2D textures. But you should be able to implement support for other kinds of textures yourself.

*

Offline @

  • *
  • 41
Re: glIsTexture == resides in gpu?
« Reply #4 on: October 04, 2013, 07:36:27 »
Thanks, that was exactly what i needed.