glReadPixels just returns 0s in Android

If I print ib I get a value like “[I@4373fab8” and if I print b I get a value like “[I@43740a50.”

But if I print pb from inside the loop I get 0. For every pixel. Zero. (The screen meanwhile is varying shades of blue.) I can print any variable from the loop, and all I get are 0s.

Thanks for any help.

int b[] = new int[w * (y + h)];
int bt[] = new int[w * h];
IntBuffer ib = IntBuffer.wrap(b);
ib.position(0);

gl.glReadPixels(x, 0, w, y + h, GL10.GL_RGB, GL10.GL_UNSIGNED_SHORT_BYTE, ib);

for (int i = 0, k = 0; i < h; i++, k++)
{
    for (int j = 0; j < w; j++)
    {
        int pix = b[i * w + j];
        int pb = (pix >> 16) & 0xff;
        int pr = (pix << 16) & 0x00ff0000;
        int pix1 = (pix & 0xff00ff00) | pr | pb;
        bt[(h - k - 1) * w + j] = pix1;

        if(i == 100 && j == 100)
    }
}

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.