0

I'm trying to write a class using soil to encapsulate SOIL calls. I can't however find any other means of deleting the memory if I load the image using

SOIL_load_OGL_texture    

So what's the correct way to clean up after this call?

Bartek Banachewicz
  • 38,596
  • 7
  • 91
  • 135

1 Answers1

1

It returns OGL texture identifier

/* load an image file directly as a new OpenGL texture */
GLuint tex_2d = SOIL_load_OGL_texture
    (
        "img.png",
        SOIL_LOAD_AUTO,
        SOIL_CREATE_NEW_ID,
        SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT
    );

so it should be freed using OGL functions:

glDeleteTextures( 1, &tex_2d );

I have not used this lib, but this is what I would do

marcinj
  • 48,511
  • 9
  • 79
  • 100
  • 2
    I think it's important to mention, that the returned value is the texture ID which you require to make actual use of the texture with OpenGL. So you must not delete the texture until you no longer need it for rendering. Also you should not recreate and delete textures each and every frame. – datenwolf Feb 24 '12 at 11:35