Can I free the memory allocated for an image after calling glTexImage2D?

The glTexImage2D function takes a pointer to image data. Now, after I called glGenTextures, glBindTexture, and then glTexImage2D

use texture in OpenGl. Can I free the memory allocated for ptr image data? or opengl Copy data from a pointer that stores it inside the GPU after calling glTexImage2D or uses my image data for texture?

+6
source share
2 answers

Yes, you can delete your information pointer as soon as you provide it with glTexImage2D, it will simply copy it somewhere closer to the map (for example, in the memory of the graphics card) and will use it from there.

int *p = getImagePixels(); glTexImage2D(GL_TEXTURE..., p); delete [] p; 
+11
source

Check out this similar question to discuss the release of glTexImage2D. It would seem you can, however.

+1
source

All Articles