Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I update part of a texture?

Tags:

opengl

It seems as though glTexSubImage2D requires a pointer to the full texture buffer. How does one make partial updates to a texture by only providing a pointer to the update region rather than the whole buffer?

For example if I want to overlay a second image onto an existing texture, rather than copy the image data onto my texture buffer then call glTexSubImage2D, I just get opengl to update the texture without having to copy data between RAM locations.

like image 301
gamedynamix Avatar asked Jun 01 '11 07:06

gamedynamix


1 Answers

Where do you get the notion that glTexSubImage2D requires a pointer to the full texture buffer ?

From the documentation linked above, it seems to me that the last parameter is a pointer to the buffer containing your new data only. The other parameters are what you use to specify which texture object to update (just an OpenGL identifier, no pointer to the original data required) and the offset and size to copy your new data to.

TL;DR: glTexSubImage2D takes a pointer to your new data and does exactly what you think it should in your example :)

like image 172
Nicolas Lefebvre Avatar answered Oct 19 '22 10:10

Nicolas Lefebvre