glTexImage2D function takes a pointer to the Image data. Now after I have called glGenTextures, glBindTexture, and then glTexImage2D
to use texture in OpenGl. Can I free the memory allocated to the Image data ptr? or does opengl Copies the data from the pointer keeps it inside GPU after call to glTexImage2D or it uses my Image data for texture?
Yes, you're safe to delete your information pointer once you provide it to glTexImage2D, it will just copy it to somewhere closer to the card (such as graphics card memory) and use it from there.
int *p = getImagePixels();
glTexImage2D(GL_TEXTURE..., p);
delete [] p;
Check out this similar question for a discussion on freeing glTexImage2D. It would seem that you can, though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With