read pixels.

Started by DanDanger, March 29, 2005, 20:28:24

Previous topic - Next topic

DanDanger

Hello all!

Im trying to read the RGBA values from the frame buffer using glReadPixels(), however the alpha values are always turning out to be 255 (actually -1 because java doesn thave unsigned bytes). The color values are just fine but the alpha is always full. I was wondering, does lwjgl set up  opengl to use the alpha channel on the frame buffer when you select a 32 bit screen? I presume it does. Has anyone tried anything like this before?

Here is the code snipper im using:

       GL11.glDisable(GL11.GL_LIGHTING);
       GL11.glDisable(GL11.GL_ALPHA_TEST);
       GL11.glDisable(GL11.GL_BLEND);
       GL11.glDisable(GL11.GL_DEPTH_TEST);

// I draw my 64x64 sprite with a simple quad and a texture set
// and then call

      GL11.glFlush();
      GL11.glFinish();

ByteBuffer buf = BufferUtils.createByteBuffer(64*64*4);
       GL11.glReadPixels(0,0,64,64,GL11.GL_RGBA,GL11.GL_UNSIGNED_BYTE, buf );
GL11.glFinish();

Then when I read the byte buffer every forth element is 255 (-1 when viewed in debugger)

Any thoughts on this anyone, any help would be appreciated as this is just driving me nuts.