Reputation: 1551
I have a FBO that has a texture array of size 4 that is attached to its color attachment point. Similarly there is another texture array of size 4 attached to the depth attachment point.
After I render to this FBO, I want to read from the 2nd layer of the texture array into a CPU buffer. How do I do this?
I know, if there was no texture array bound to this FBO, I would have simply done:
glReadBuffer(GL_COLOR_ATTACHMENT0);
glReadPixels(...
But how do I do in case of 2D array bound to FBO? Can we tweak glReadPixels to read a particular layer?
Upvotes: 1
Views: 477
Reputation: 1551
So I finally figured : you have to use glGetTexImage(). On a side note, note that unless you are not using compressed textures, do not query its size using glGetTexLevelParameteriv. ( I was doing that and I kept getting invalid operation errors, and I thought I was not calling glGetTexImage() correctly!).
Upvotes: 2