Getting pixels from a previously mapped texture - OpenGL

In OpenGL, is it possible to get an array of pixels from a previously created texture specified only with a texture identifier?

+3
source share
1 answer

Yes. bind
it again and call. glGetTexImage()
If you do not want to bind to the texture that is currently mapped, you can bind it to another texture unit. A texture block is a container that contains an associated texture. you can have one texture attached to each texture unit. OpenGL 2.1 requires that an implementation have at least 2 texture units. The standard texture unit that you regularly use is the unit 0. To switch the current call to the texture unit glActiveTexture():

glActiveTexture(GL_TEXTURE1);
glBindTexture(texid);
glGetTexImage(...);
glActiveTexture(GL_TEXTURE0); // don't forget to switch it back
+2
source

Source: https://habr.com/ru/post/1704606/


All Articles