PDA

View Full Version : How can I clear used textures from the memory??



jiangerlai
11-15-2005, 05:26 AM
I am using OpenGL to display 128*128 Bitmaps in a 3D space. Everytime I load a new Bitmap and create a texture. So the memory allocated for the programme keeps increasing until there is not enough memory and the programme stops running. Who knows how to clear used textures in the memory because I need each of them only once. Thanks

Bob
11-15-2005, 05:36 AM
Are you loading the image over and over again every time you display it? If so, why not load it once and reuse the texture?

Anyway, to answer the question asked: textures are deleted with glDeleteTexture.

jiangerlai
11-15-2005, 05:42 AM
Thank you,
The texture I use is different every time. So I have to load a new one every time.
I will try your method.

Bob
11-15-2005, 06:05 AM
In that case, you may want to look at glTexSubImage. You can use it to update a texture with new data. Calling glTexImage for each new texture will completely reallocate the texture, while glTexSubImage will just upload new data. It can be much more efficient, but it pretty much assumes all textures are of the same size.

jiangerlai
11-15-2005, 04:10 PM
Thank you very much. Both methods work well.