I know that a texture object can be changed a number of times, by just replacing a new texture name viz:
//initially glBindTexture(GL_TEXTURE_2D , tex_name_1); //next line glBindTexture(GL_TEXTURE_2D , tex_name_2);
Also, if the texture unit is to be unbound we do
glActiveTexture(<tex unit num>) glBindTexture(GL_TEXTURE_2D , 0); //unbinds
But now I want to confirm if we can really change the target type of a valid texture id
//initially..let suppose it is bounded to GL_TEXTURE0 glBindTexture(GL_TEXTURE_2D , tex_name); //unbind glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D , 0); //disable GL_TEXTURE_2D glDisable(GL_TEXTURE_2D); //let say now I want to define a new target glEnable(GL_TEXTURE_3D); //assume GL_TEXTURE0 is still active //then do glBindTexture(GL_TEXTURE_3D , tex_name);
Is this possible???
Currently I am doing above but when I bind my texture to 3D
it throws error GL_INVALID_OPERATION.
Then I did following just before binding tex_name to GL_TEXTURE_3D
glDeleteTextures(..) glGenTextures(.. , &tex_name)
followed by binding tex_name to 3D and it worked …
Does this mean that once a target is specified for a texture id , it retains forever even after disable that target type ???
Note: The above lines are called in a loop and I do not want to delete and generate texture names everytime. As debugging shows, if I do above in a loop , the texture id values change and since it is of GLuint type, it has some limits.