I would like to know how to resize an existing OpenGL 4.3 texture while keeping the current contents. i'm using glTexImage2D(). Do I simply re-call glTexImage2D() with nullptr for the data paramater?

  • 2
    \$\begingroup\$ Quick question: Why do you want to resize it, but keep the data? What would it fill the rest of the space up? You can always just draw a texture twice as large as it is, it will interpolate automatically \$\endgroup\$
    – Bálint
    Commented Mar 21, 2018 at 16:23
  • 1
    \$\begingroup\$ Or if you shrink it you cannot keep the data: Something must be lost. Maybe you should talk a little about what you're trying to do rather than how you're trying to do it, because this is seeming like an XY Problem to me. \$\endgroup\$ Commented Mar 21, 2018 at 20:02
  • \$\begingroup\$ I guess I used the wrong terminology. I guess I'm looking to re-sample the image with that call. \$\endgroup\$
    – Richmar1
    Commented Mar 22, 2018 at 8:54

1 Answer 1


You cannot.

You can create a new texture and copy the contents of the pixel data from the old texture into the appropriate place of the new one. But glTexImage will reallocate the storage for the texture. And not like realloc does; it works like malloc followed by freeing the old memory.

Its best to avoid this problem by making the texture as large as you will reasonably need it to be, then living within that storage.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .