Reputation: 755
In my application i am using around 7 to 8 textures. i am doing multiple texturing as well. when i delete all the textures using glDeleteTexture cmd and checking using glIsTexture command then getting GL_True for some textures. I want to know at which conditions glDeleteTexture() function fails to delete the texture?
EDIT: Ok, i debug my code , and now i come to know there are mainly two problems: at one stage in my application, i have a 3d model and on different touch inputs i am changing the textures on it. so at every touch input i am calling the following code
glDeleteTextures(1, &tex1);
switch(case)
{
case 1:
tex1 = CreateTexture("xyz.pvr");
break;
case 2:
tex1 = CreateTexture("abc.pvr");
...
...
where CreateTexture is given below
UploadImage(file);
GLuint name;
glEnable(GL_TEXTURE_2D);
glGenTextures(1, &name);
glBindTexture(GL_TEXTURE_2D, name);
glTexEnvf( GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_DECAL);
glTexParameterf(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
GLfloat fLargest;
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &fLargest);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, fLargest);
glTexImage2D(GL_TEXTURE_2D, level, format, w, h, 0, format, type, data);
UnloadImage();
This code is giving me some leakage at every touch input. Secondly in the end i have to free all textures and load different data.So i am deleting all the textures using following comands
glDeleteTextures(1, &tex1);
glDeleteTextures(1, &tex2);
glDeleteTextures(1, &tex3);
glDeleteTextures(1, &tex4);
glDeleteTextures(1, &tex5);
glDeleteTextures(1, &tex6)
and then checking either its deleted or not using
glIsTexture(tex1);
glIsTexture(tex2);
glIsTexture(tex3);
glIsTexture(tex4);
glIsTexture(tex5);
glIsTexture(tex6);
but getting true for some textures.
Upvotes: 0
Views: 481
Reputation: 399763
You should investigate that yourself, by adding code to track the returned error from OpenGL. Perhaps you're doing the delete at a bad place in your code, while the texture is still in use, or something. Call glGetError()
after the OpenGL calls you wish to investigate, and log the result.
Upvotes: 1