Landon
Landon

Reputation: 15696

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?

Upvotes: 3

Views: 1112

Answers (1)

shoosh
shoosh

Reputation: 79003

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

Upvotes: 2

Related Questions