Using glReadPixels to read pixels doesnt work on Android

Using glReadPixels to read pixels doesnt work on Android
0.0 0



I am using the following code to retrieve pixels from a ccsprite

texture~~>beginWithClear; // pink background
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0, 0, renderTextureWidth, renderTextureHeight, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
Notice the underlined line
it is there for testing purposes to check whether the bytes were successfully read.

This works fine when I test it on the windows (vs2010) but when I compile it with cygwin and run it on android the image is distorted completely as if glReadPixels did not work properly. Please see screenshots below:

Windows (works):

The screenshot below was taken from android (I took a photo with another phone - please pardon the quality):

win.png (27.7 KB)


I figured out what the problem was - it had to do with the AppDelegate.cpp. My design resolution (ratio) was badly configured.


What do you mean by badly configured? I think I have the same problem because its happening only on android and I can’t seem to find any article related to it.


Inside AppDelegate there was some funky thing i was doing with setContentScaleFactor and setDesignResolution. I dont exactly remember but I do know I replaced the contents of this file with the example from TestCpp. Also I eventually stopped using this technique to draw pixels and used the class (Mutable Texture) - you can find it at in one of the posts as an attachement.