Original Post
I've been trying to figure out how to unload my textures after I no longer need them, but I can't seem to figure out how. This is how I generate an individual texture: where texture is temporary storage for the texture data while it was being loaded and generated. after free(texture); the texture data does not exist locally anymore... I think opengl stores it internally at that point -- so I can only access individual textures through their texture ids (texnum). Is there any way to delete a texture from within opengl knowing only its texture id?
glBindTexture(GL_TEXTURE_2D, texnum);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexImage2D(GL_TEXTURE_2D, 0, 4, infoheader.biWidth, infoheader.biHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture);
gluBuild2DMipmaps(GL_TEXTURE_2D, 4, infoheader.biWidth, infoheader.biHeight, GL_RGBA, GL_UNSIGNED_BYTE, texture);
free(texture);