Retrieving Pixels From a Previously Bound Texture - OpenGL
Question
In OpenGL is it possible to retrieve the pixel array from a previously created texture given only the texture ID?
Solution
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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow