#### Archived

This topic is now archived and is closed to further replies.

# Textures - how to free texture memory

This topic is 5879 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

##### Share on other sites
After you call glTexImage2D (or some other function) you can delocate the memory that was holding the image data. To delete the texture created by glTexImage2D use glDeleteTexture.

[Resist Windows XP''s Invasive Production Activation Technology!]

##### Share on other sites
Thanks 4 help "Null and Void"!!

What do you think is better?

1. load ALL textures (eg. 40) at the beginning of the program execution and just immediately delete all those arrays after image loading which hold the image data (*m_rgb in my case) and just use those textures till the end of the program without using glDeleteTexure. Just swapping them whenever needed without deleting them OR

2. load the only textures I currently need (eg. 10), immediately delete those ten arrays *m_rgb after image loading and then use glDeleteTexture whenever I want to get rid of any of those ten textures? and repeat the cycle again and again? I think this is how it happens in real games! doesn't it?

Edited by - sandrew on January 14, 2002 10:36:00 PM

Edited by - sandrew on January 14, 2002 10:38:29 PM

##### Share on other sites
Load all the textures you''ll be needing in the short future (or now) at one time. When you''re done with them get rid of them. For example: you may want to keep a ''font texture'' in memory at all times for quick usage (so load it at the beginning and delete it at the end), but you will only need the ''brick 25'' texture during one level (so load it when the level begins, and delete it after the level is over).

[Resist Windows XP''s Invasive Production Activation Technology!]

##### Share on other sites
OK!! thanks!!

but.. do u think that if dont use glDeleteTexture then the texture will hold as much memory as the array into which I loaded the image data which then I deleted?

BTW: there is almost no documentation about glDeleteTexture function. Only 9 pages found on GOOGLE! is it standard OpenGL? or some kind of an exension that I need?

I get an error :
error C2065: 'glDeleteTexture' : undeclared identifier

What is the 1st parameter of glDeleteTexture? I am not sure!

Edited by - sandrew on January 14, 2002 11:05:59 PM

##### Share on other sites
Sorry, my fault, it''s glDeleteTextures (I left off the ''s''). Yes, the correctly spelled version is standard. Yes, the texture takes up approximately as much memory as your array did until you call glDeleteTextures (except that it may be video memory, system memory, AGP, whatever). You use it like this:
  GLuint SomeTexture;/* Load Texture Here...*/glDeleteTextures(1, &SomeTexture);

To delete more than one texture:
  GLuint SomeTexture[3];/* Load Three Textures Here...*/glDeleteTextures(3, SomeTexture);

[Resist Windows XP''s Invasive Production Activation Technology!]