Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving Pixels From a Previously Bound Texture - OpenGL

In OpenGL is it possible to retrieve the pixel array from a previously created texture given only the texture ID?

like image 759
Landon Avatar asked Dec 05 '25 17:12

Landon


1 Answers

Yes.
bind it again and call glGetTexImage()
If you don't want to mess with the texture which is currently bound, you can bind it to a different texture unit. A texture unit is a container which hold a bound texture. you can have one texture bound to every texture unit. OpenGL 2.1 requires that an implementation will have atleast 2 texture units. The default texture unit which you regularly use is unit 0. to switch the current texture unit call glActiveTexture():

glActiveTexture(GL_TEXTURE1);
glBindTexture(texid);
glGetTexImage(...);
glActiveTexture(GL_TEXTURE0); // don't forget to switch it back
like image 164
shoosh Avatar answered Dec 10 '25 02:12

shoosh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!