Changing, reload or unbinding textures

Hello there,

got several quads to paint. For each, it´s own texture image is stored in an vector. How many quads are to paint is given by the size of this image vector.


for (int i=0; i < images.size(); ++i)
    	textures[i] = bindTexture(images[i], GL_TEXTURE_2D);

In my newbee understanding, now the images are transformed in textures and are thrown into the graphic card´s buffer. Am i right?

How to delete or replace one of this texture choosen by index i, like


textures.removeAt[i];
texture[i] = bindTexture(new_or_changed_Image, GL_TEXTURE_2D);

since

GLuint* textures

is used and typicall stl methods are not available?

I don´t want to
glDeleteTextures(all, textures)
and
bindTextures(images[i], GL_TEXTURE_2D)
again, when just repainting the scene, without anything changed in images[]??

Some ideas? Thanks for you hints in advance.


for (int i=0; i < images.size(); ++i)
    	textures[i] = bindTexture(images[i], GL_TEXTURE_2D);

What is this? What does bindTexture do? It does not look like the regular glBindTexture function.

To load and use a 2D texture in opengl you need to:

  1. Load image data into system memory
  2. Generate a texture name with glGenTextures
  3. Bind the texture name with gBindTexture
  4. call glTexImage2D with the right parameters depending on the image nature to load image data into video memory
  5. Set wrapping and filtering mode with glTexParameter

Finally just bind the texture before drawing it onto a quad.

Look at opengl man pages for more information about all these functions.

bindTexture
comes from QT.

I´m already able to map the textures and show them.
The delete one texture afterwards issue is more important.

But thanks for your reply.

To replace texture data, just bind the texture and call glTexImage2D with the new data.

bindTexture, at least the opengl one, just binds a texture name to a specific target, GL_TEXTURE_2D here. It does not delete or replace anything, just put a particular texture in use.

Calling glDeleteTextures will delete specified texture names, then the allowed video memory will be set free by the driver and the texture name free to reuse.

“Calling glDeleteTextures will delete specified texture names,…”

Same in QT - and this was the problem.

I´ve used bindTexture together with glDeleteTextures, so the QT and the OpenGL functions together. Obviously this is going to crash.

So i replaced glDeleteTextures with QT´s deleteTexture and done.

Thanks again!