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.

Thanks,
Jeremiah

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,
Jeremiah

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.