What is the difference between the two functions? Any performance difference?
Thanks..
What is the difference between the two functions? Any performance difference?
Thanks..
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.)
glTexSubImage2D
directly? IIRC it was one of my books that recommended glMapBuffer
to do a DMA transfer. –
Orinasal glTexImage
- sorry for the confusion! Fixed the typo now. @Bahbar: thanks for the extra info, will look into it. I found an interesting article on streaming texture updates via PBOs songho.ca/opengl/gl_pbo.html that is worth investigating. –
Orinasal The gl functions with "sub" in the name aren't limited to power-of-2 dimensions. As gavinb points out, you need to use the non-sub variant once to set the overall dimensions, but I don't agree that calling the non-sub variant repeatedly is any slower than using "sub" for updates -- the GPU is still free to overwrite the existing texture in place as long as you are using the same texture id.
© 2022 - 2024 — McMap. All rights reserved.