glIsTexture == resides in gpu?

Started by @, October 03, 2013, 17:22:00

Previous topic - Next topic

@

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?

quew8

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.

@

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?

Cornix

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.

@

Thanks, that was exactly what i needed.