GL question- redefining texture?
Basic question-
If I create a texture with glTexImage2D(), and then later want to update that texture content, is it safe to call glTexImage2D with the same texture ID (target) again? I know that using glTexSubImage2D to redefine the texture will be slightly faster, but in this case I'm concerned about memory usage not speed. Do I need to call glDeleteTexture() before resuing an ID? I'm not clear on how GL's copy of the the texture memory is freed.
thanks,
-alex
If I create a texture with glTexImage2D(), and then later want to update that texture content, is it safe to call glTexImage2D with the same texture ID (target) again? I know that using glTexSubImage2D to redefine the texture will be slightly faster, but in this case I'm concerned about memory usage not speed. Do I need to call glDeleteTexture() before resuing an ID? I'm not clear on how GL's copy of the the texture memory is freed.
thanks,
-alex
I'm pretty sure you can safely call glTexImage2D again. glGenTextures just reserves a "slot" in the texture list, all the resource management is handled internally by the GL driver.
AFAIK you should only use TexImage2D over TexSubImage2D if you want to change part of the texture that only the former gives you control over (like the dimensions).
AFAIK you should only use TexImage2D over TexSubImage2D if you want to change part of the texture that only the former gives you control over (like the dimensions).
Very belated followup:
I've now found that using glTexImage2D with the same ID and new image data (with possibly different dimensions than the old image) is NOT SAFE. You will leak memory in RSHRD/VSIZE. This happens even with the texture range extension and client storage, to eliminate any extra copies the GL is keeping around.
So: if you're not using images of the same dimension and can't use glTexSubImage2D, then you must call glDeleteTextures to ensure the GL really releases/unmaps your image data.
I've now found that using glTexImage2D with the same ID and new image data (with possibly different dimensions than the old image) is NOT SAFE. You will leak memory in RSHRD/VSIZE. This happens even with the texture range extension and client storage, to eliminate any extra copies the GL is keeping around.
So: if you're not using images of the same dimension and can't use glTexSubImage2D, then you must call glDeleteTextures to ensure the GL really releases/unmaps your image data.
arekkusu Wrote:I've now found that using glTexImage2D with the same ID and new image data (with possibly different dimensions than the old image) is NOT SAFE. You will leak memory in RSHRD/VSIZE. This happens even with the texture range extension and client storage, to eliminate any extra copies the GL is keeping around.
If this is true then it's a bug.
Mind you, who'd really be surprised...
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Texture Basic Question(s)... | WhatMeWorry | 2 | 2,893 |
Feb 27, 2007 10:06 AM Last Post: arekkusu |
|
| General Texture Question.... | WhatMeWorry | 5 | 3,677 |
Aug 5, 2005 09:38 PM Last Post: WhatMeWorry |
|

