The problem is that you render to the back buffer, but your glReadPixels()
call reads from the front buffer. If you render to a double buffered surface (which you almost always want when using OpenGL), your rendering goes to the back buffer by default. You have this call in your code:
gl.glReadBuffer(GL_FRONT);
This tells the following glReadPixels()
call to read from the front buffer, which is the buffer you are not drawing to.
You should be able to simply remove the glReadBuffer()
call, as GL_BACK
is the default read buffer for a double buffered default rendering surface.