Jump to content
  • Advertisement


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


Freeing generated textures

This topic is 6513 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

Hi all, how can i free a texture once it has been created ? i use the standard ''glGenTextures and glbindtexture'' Once my texture is bound, i assume i would use that reference to free it correct ? My game is multi-level, like all other games i guess, and when one level ends, i need to load new textures. So my guess would be to delete the textures i no longer need and create/load new ones. Is there a GL call to free those texture or do i simply point them to nil ? much appreciated, thanks, Gunner.

Share this post

Link to post
Share on other sites


The glDeleteTextures function deletes named textures.

void glDeleteTextures(
const GLuint * textures



The number of textures to be deleted.


An array of textures to be deleted.


The glDeleteTextures function deletes n textures named by the elements of the array textures. After a texture is deleted, it has no contents or dimensionality, and its name is free for reuse (for example, by glGenTextures). The glDeleteTextures function ignores zeros and names that do not correspond to existing textures.

If a texture that is currently bound is deleted, the binding reverts to zero (the default texture).

You cannot include calls to glDeleteTextures in display lists.

Note The glDeleteTextures function is only available in OpenGL version 1.1 or later.

Share this post

Link to post
Share on other sites
Thanks, that''s exactly what i was looking for.

I generate my texture like so:

glGenTextures(1, @Texture[0]);
glBindTexture(GL_Texture_2D, Texture[0]);

soo to delete i would use ? :

glBindTexture(GL_Texture_2D, Texture[0]);

It''s delphi but OpenGL is very simillar from language to language.


Share this post

Link to post
Share on other sites
"glBindTexture(GL_Texture_2D, Texture[0]);

Nope. One, you dont need the first line, second, where you have gl_texture_2d is actually where you need to specify how many textures you want deleted from the array ''Texture''.

So you should have, if you only wanted to delete Texture[0]:


if you wanted to delete Texture[0] and Texture[1] then:


Im not sure if the array Texture needs to be represented as a pointer :/ so try


Share this post

Link to post
Share on other sites
Code form one of my progs.

GLuint texture = 0;

... ...

bool GenerateTexture(){
return false;

... ...

texture = 0;

Hope that helps.

Share this post

Link to post
Share on other sites

  • 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!