Problems reading pixel alpha

Well it goes like this

gl.glClearColor(0,0,0,0);
gl.glClear(GL.GL_COLOR_BUFFER_BIT );
gl.glReadPixels(0,0,this.getWidth(),this.getHeight(),GL.GL_RGBA,GL.GL_UNSIGNED_INT_8_8_8_8,screenBuffer);

and all the alpha values in screenBuffer are 255… WHY???

or I try this instead of clearing:

for(int a=0;a<compositeScreen.length;a++){
screen[a]=0; //screenBuffer wraps screen
}
gl.glDrawPixels(this.getWidth(),this.getHeight(),GL.GL_RGBA,GL.GL_UNSIGNED_INT_8_8_8_8,screenBuffer);
gl.glReadPixels(0,0,this.getWidth(),this.getHeight(),GL.GL_RGBA,GL.GL_UNSIGNED_INT_8_8_8_8,screenBuffer);

and the alphas are still 255… ARGGGGGGGG!!!

Is that what I am supposed to get?

Please tell me that my new expensive Nvidia GeForce 7800 GS with the latest drivers is all right and that I am just missing the gl.glReadTheActualFreakingAlphas(true) function.

try this:


gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
buffer = BufferUtil.newByteBuffer(renderPanel.getWidth()* renderPanel.getHeight() * 4);
gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, 1);
gl.glReadPixels(0, 0, renderPanel.getWidth(), renderPanel	.getHeight(), GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, buffer);

where renderpanel ist you glcanvas or gljpanel…

after that every fourth byte should contain your alpha value

I tried that first actually. I also tried reading it as shorts and ints. I tried reading it signed and unsigned. I also tried reading just the alpha value. In every case the alpha value was the max for that data type.

Just to be sure I ran your code anyway and I get 0,0,0,255,0,0,0,255,0,0,0,255 … etc…

BTW, on a slightly different topic, some nickle knowledge that someone might find useful. On my card at least, this command:

gl.glDrawPixels(this.getWidth(),this.getHeight(),GL.GL_RGBA,GL.GL_UNSIGNED_INT_8_8_8_8,baseScreenBuffer);

is about 2300 times faster than this command:

gl.glDrawPixels(this.getWidth(),this.getHeight(),GL.GL_RGBA,GL.GL_SHORT,baseScreenBuffer);

I don’t see how to explain that huge difference. The total bytes in the second command is only double that of the first.

Do you read it with a glcontext current on your thread? Did you try it with the DebugGL installed?