Advertisement

Freeing Texture Memory

Started by April 17, 2001 05:53 PM
5 comments, last by SGreth 23 years, 7 months ago
Ok, so I have OGL stuff a texture into memory which I access via the ID that OGL gives me, how do I ''free'' that memory or ''let go'' of it? Or does OGL just manage texture memory for me and release textures on the fly if I ask it to load some up and there isn''t enough memory left.... Thanks, ~S''Greth
"The difference between insanity and genius is measured only by success."~Bruce Feirstein
glDeleteTextures() I think frees the texture from the video memory
Celeron ][ 566 @ 850256MB PC-100 CAS2 RAMDFI PA-61 Mainboard (250MB memory bandwidth sucks, it should be 500MB)ATI Radeon 32MB DDR LEWindows 98SE
Advertisement
After you glDeleteTexture it, then make sure to free/delete it. How would OpenGL know that you did or didn''t want to free, so how can it do it automatically?

"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
Resist Windows XP''s Invasive Production Activation Technology!
http://druidgames.cjb.net/
Cool, thanks for the glDeleteTextures() (should have just randomly started guessing in the MSDN ). Oh, I free the texture memory (in regular system ram) right after I dump it to the card, so no worries there...thanks everybody.

~S''Greth
"The difference between insanity and genius is measured only by success."~Bruce Feirstein
I have a couple of questions that are related to this:

After you have used glTexImage2D to create a texture from the data you read in from a .bitmap or .tga, is it necessary to keep that texture data in main memory (non-video). If I delete the data and just keep the texture object name, and use glBindTexture to refer to that, will GL complain that it needs that other data to draw the texture?

I would like to know:

(1) After which command does the texture reside in the video card''s RAM (glTexImage2D?)

(2) What commands do you use to get the minimum and maximum mem addresses of the video card RAM so that you can check the limits before you load a texture, and unload other textures if the texture RAM is full.

Paulcoz.
After you do glTexImage2D() you do not need to keep the data in memory. You''re free to do whatever you want with the buffer.

Different implementations of the drivers can handle this matter differently. Most of the time, however, the driver will create a buffer of its own in the system memory, copy the image you passed it with glTexImage2D() into that buffer, and then use this buffer as needed. If you upload more textures then the video memory could handle the driver will swap the data back and forth. The least recently used texture will be swapped out of the video memory if a new texture needs to be used. Again, it''s all done using the driver''s internal memory buffer, so you do not need to keep your buffer.

If you want to change the priority of the textures look up glPrioritizeTextures() function.
Advertisement
You mean to say I don''t need to do any texture management whatsoever? The last program I wrote (non-OpenGL) had to check the upper limits of the video ram to see if the texture would fit, then worked out which textures to dump (least used) if it didn''t. You mean to say in OpenGL I don''t have to do that at all?

Sounds too easy.
Paulcoz.

This topic is closed to new replies.

Advertisement