Does glTexImage2D copy the texture data?

Sorry if this is a bit of an odd question, but I’ve not worked with Textures much so I need to double check.

When calling glTexImage2D and providing a pointer to the pixel data, is the data from that array actually copied elsewhere in memory or just pointed to? According to the behavior when the pixel value is given NULL (allocating texture memory based on the width, height and format), I would think it’s copied but I just want to be sure.


Yes, it is copied. You can safely free/delete the pixel data immediately after glTexImage2D returns.

Thanks for the quick and easy answer. Glad I checked… would hate to be sitting on two copies of the gfx in memory for no reason.

Take care,