LWJGL Forum

Programming => OpenGL => Topic started by: @ on October 03, 2013, 17:22:00

Title: glIsTexture == resides in gpu?
Post by: @ 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?
Title: Re: glIsTexture == resides in gpu?
Post by: quew8 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.
Title: Re: glIsTexture == resides in gpu?
Post by: @ on October 03, 2013, 21:40:17
Quote from: quew8 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.

But what if, by any chance, the programmer unbinds (or deletes) the texture from gpu? Is there any way to test this?
Title: Re: glIsTexture == resides in gpu?
Post by: Cornix 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:
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.
Title: Re: glIsTexture == resides in gpu?
Post by: @ on October 04, 2013, 07:36:27
Thanks, that was exactly what i needed.