Reputation: 462
I am facing a strange issue where I end with an undefined but somehow valid texture. The mesh with this texture applied is black. The glIsTexture(textureId)
method for this texture returns 1 (!) but the texture is clearly wrong. It has undefined size.
My iOS app creates several textures in short time intervals but always on the main thread. The described situation is unusual, difficult to reproduce and it occurs only in a particular scenario when:
glDeleteTextures(1, &textureId)
, deleting a texture id = NglGenTextures(1, &textureId)
and the function returns a new texture with exactly the same id = N as the recently deleted one.This looks to me like the OpenGL driver tried to create a new texture while an old one was not completely erased. Is that possible?
Upvotes: 1
Views: 568
Reputation: 462
The problem was trivial - an unbound texture before calling glTexImage2D
and setting up the texture.
I am using a group of wrapper methods over the OpenGL library. Their purpose is reducing the number of redundant state changes of the driver. One of this wrappers was preventing binding a texture with the same ID to a texture unit if it was previously flagged as bound.
In some cases, when the same ID was being recycled the wrapper method was still "remembering" the old texture ID and preventing binding is again.
Reassuming - in this case, there were completely no issues with glDeleteTextures
followed by glGenTextures
.
Upvotes: 1