Hi
My game can load and display textures now which is very nice. However I'm a little bit unsure how to properly unload these again to free memory?
The following seems not to be enough because I can still bind the texture and display it so I suppose it has not really been freed:
public void deleteTexture(String path) {
// textures is a TreeMap with Strings as keys
// and texture objects as values.
// a texture object saves its id generated by OpenGL
// which I request here trough getter
int id = textures.get(path).getId();
IntBuffer intBuffer = IntBuffer.wrap(new int[] { id });
GL11.glDeleteTextures(intBuffer);
textures.remove(path);
}
If you cleared the NIO Buffer you've used to load and upload the texture your done with it.
With glDeleteTextures the texture is removed from the graphiccards RAM and need to be loaded again.
If iam wrong, please correct me :)
But why can I still bind and render the texture then? ???
It may that you have bind the texture while attempting to delete it. Then the delete process will fail i think.
I found this within the OGL Documentation.
QuoteIf a texture that is
currently bound is deleted, the binding reverts to 0 (the
default texture).
Try to unbound the texture first and delete it then. Should work.
Thanks everything works fine right now.