Difference between glTexSubImage and glTexImage function in OpenGL

Edwin picture Edwin · Mar 9, 2010 · Viewed 14k times · Source

What is the difference between the two functions? Any performance difference?

Thanks..

Answer

gavinb picture gavinb · Mar 9, 2010

You create a texture using glTexImage, and then update its contents with glTexSubImage. When you update the texture, you can update the entire texture, or just a sub-rectangle of it.

It is far more efficient to create the one texture and update it than to create it and delete it repeatedly, so in that sense if you have a texture you want to update, always use glTexSubImage (after the initial creation).

Other techniques may be applicable for texture updates. For example, see this article on texture streaming for further information.

(Originally, this post suggested using glMapBuffer for texture updates - see discussion below.)