I just ran into this problem myself, and although it’s a pretty old thread OP’s code will still result in an access violation with the latest build of oF so I thought that I’d point out how to fix this.
Unlike the implementation of ofFbo::readToPixels for regular OpenGL, the one for ES does not allocate memory for the ofPixel object internally, so you have to make sure that you do that yourself before calling readToPixels.
Worth noting is that pulling something like a million RGBA pixels from video memory in this way on an iPhone 4 is terribly slow compared to doing it on a Mac/PC with even very modest hardware, so unless you don’t mind it taking a bit (haven’t measured it but would estimate it to almost half a second for that many on the iPhone 4) I would suggest looking for another solution, or grabbing a smaller number of pixels if possible, by binding the FBO and calling glReadPixels.
Hi, just ran into this issue myself on iOS. Eventually got it to work like so (a bit of a hack, and not fast, but works):
ofFbo sourceFbo; // we want to copy the texture from this fbo texture
ofTexture targetTex; // we want to copy the fbo data into this texture
ofPixels p; // a pixel object to transfer the data
Draw something into the Fbo here …
// allocate empty pixels of the right type (OF does not do this for us like in OSX)
// Prepare our target texture with these pixels (although they are still empty, they are of the proper size and type)
// Copy the fbo data into our pixels.
// paste the pixels into the texture …