I have created a GLCanvas with various patterns of red and blue all over it. Purely as an exercise I attempted to read a square of pixels from a position which I chose to be 0, 100. And the width and height of the square are 100. I then cleared the canvas to white (that part worked) and drew the saved square into a different location on the canvas (which I chose to be 0, 200). The result was that I ended up with a white background (as expected) and the black square (at the correct size of 100, 100) and at the correct location of 0, 200. The square came out at the right position and size but it should not have been black - it should have contained whatever colours were at the original location before the screen clear. Any code that could make this method do what I want would be highly appreciated.
Sorry about the poor indentation as it got messed up somewhere in translation from one machine to another.
public void movedisplay(GLDrawable drawable)
GL gl = drawable.getGL();
byte pixels = new byte;
gl.glReadPixels(0,100, 100, 100, GL.GL_COLOR_INDEX, GL.GL_BYTE, pixels);
gl.glClearColor( 1.0f, 1.1f, 1.0f, 1.0f ); gl.glClear (GL.GL_COLOR_BUFFER_BIT);
gl.glDrawPixels(100,100, GL.GL_COLOR_INDEX, GL.GL_BYTE, pixels);