I have a question. If I create N texture objects and I run out of texture memory, what happens? Does the texImage2 fail? I am confused because my docs say that opengl will automatically delete older textures and there is even an API to set that delete priority.

So if it does delete an older texture object how does my app know it has to reload it? Will the subsequent bind fail?

OpenGL will never delete your textures without you doing it explicitly. That said, your docs probably meant resident textures, and the functions to prioritize and query for residency. When a texture is readily available to the renderer, it is considered resident. If it isn't, it will have to be copied, and other resident textures might have to be kicked out.

Practically, residency means textures currently in video memory (usually 32, 64 MB on the common cards), and nonresidency means system memory. When binding a nonresident texture, the OpenGL driver will have to upload it to resident memory.

That also means that you can always create new textures, to the system memory limit, but performance will suffer if textures are swapped in and out of resident memory all the time.

I am still confused. If you use glGenTexture to get a texture object name, then use glBindTexture, should you not call glTextImage if it is already bound? or does opengl just ignore the following glTexImage call if it already has a copy?

And is it safe to change the texture between draws? Do you have to delete the texture to repplace it with a new one?