What is the difference between the two functions? Any performance difference?
Thanks..
glTexSubImage2D redefines a contiguous subregion of an existing two-dimensional texture image. The texels referenced by data replace the portion of the existing texture array with x indices xoffset and xoffset + width - 1 , inclusive, and y indices yoffset and yoffset + height - 1 , inclusive.
glteximage2d is the function that actually moves the texture data across to the gpu. you will need to create the texture object first using glGenTextures() and then bind it using glBindTexture(). there is a good example of this process in the opengl redbook example. you can then use this texture with a VBO.
GL_DEPTH_COMPONENT is used for PixelFormat, and GL_DEPTH_COMPONENT16 is used for Framebuffer/Renderbuffer Object. glRenderbufferStorage can use GL_DEPTH_COMPONENT16.
A Buffer Texture is a one-dimensional Texture whose storage comes from a Buffer Object. They are used to allow a shader to access a large table of memory that is managed by a buffer object.
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.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With