Jump to content
  • Advertisement
Sign in to follow this  
hdagelic

OpenGL unload textures from memory ??

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I'm using glteximage2d to load textures when I need them. This function saves images to video ram so I don't know if i should unload them manually when they are no longer needed so that they don't take up the entire video ram. What's more, I cant't even find the function that frees one texture from video memory. Do I have to unload them or is this taken care of by opengl? What happens if my program runs for 5 hours and loads little by little a 1000 textures and they are 5GB big all together and i have only 256 MB of vdeo ram?

Share this post


Link to post
Share on other sites
Advertisement
First of all, GL driver performs memory management. If you upload too many textures, some of them will be non-resident to VRAM.
If some textures doesn't needed anymore, you should delete them with glDeleteTextures() call.

Share this post


Link to post
Share on other sites
thanks :) But what if I only called glgentextures but not yet glteximage2d. What I mean, does gldeletetextures frees vram that was taken by glteximage2d call, or frees the reserved id from glgentextures call or both?

Share this post


Link to post
Share on other sites
ok, I think that "chapter 9" does it, thank you. But I have one more tricky question: if my program loads textures to VRAM via glteximage2d and keeps some of them there for the entire time the system is running so it would paint the scene more quickly, how would that influence other programs using opengl? Would they run out of vram and crash, overwrite my textures, or would my textures be swapped to RAM?

Share this post


Link to post
Share on other sites
glGenTextures by itself does little, it gets you an unused name to refer to the texture object.
Calling glIsTexture right now would return false. As it has not been bound yet.
The first time you call glBindTexture with this name, it creates a default texture of the specified type for the name provided.
Calling glTexImage*() will define the texture data.
The idea is that glGenTextures|glBindTexture|glTexImage* when called for the first time work together to create|define the texture, so think of them as one when initializing. When calling glDeleteTextures, youre saying you no longer want to keep the result of glGenTextures|glBindTexture|glTexImage* around anymore for whatever reason.

Share this post


Link to post
Share on other sites
You can run many GL programs at the same time. The driver manages textures. It can even use the swap file if space is running out.
However, it is a good idea to call glGetError to see if you get GL_OUT_OF_MEMORY

Share this post


Link to post
Share on other sites
Quote:
Original post by keltar
glAreTexturesResident() may be used to ensure that textures placed in VRAM


When I did a test with this function, it's useless because it always returns TRUE even if you upload a ridiculous amount of textures. So don't depend on this function.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!