views:

97

answers:

1

Hi I am facing a problem with delete and generate textures. I am working on a medical imaging application where texture objects are deleted and regenerated when user reloads image data. When texture objects generated the first time (at application startup) every thing works fine. Problem comes when I delete and generate textures again - image data is reloaded. For some reason the texture is not loaded and no image is visible. I used glAreTexturesResident to query texture status and the texture is not resident.

The issue is only in release build, debug build works without any problem. Please help.

Thanks Ravi Kumar

A: 

Here is the code snippet.

// generate texture GLuint texId; glGenTextures(1, &texId);

// activate texture unit and bind texture glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_3D, 1);

// set texture parameters glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

// set texture data glTexImage3D(GL_TEXTURE_3D, 0, GL_LUMINANCE, width, height, depth, 0, GL_LUMINANCE, GL_UNSIGNED_SHORT, texMap);

// code to draw rectangle ....

When a new image is loaded I delete existing texture using glDeteTextures. glDeleteTextures(1, &texId); glFlush();

Application then recreates the texture. This time no texture is rendered.

BTW I use shaders for applying textures.

Above code works in debug mode, I can reload images many times and every thing works fine. When I run application in release mode texture is not rendered.

Please help.

Ravi Kumar

Ravi Kumar