PDA

View Full Version : glDrawPixels blocks further drawing



wgj000
03-16-2007, 12:53 PM
I think glDrawPixels is causing and odd behavior. But since this is the first time I have used it I cant't be sure.

What ever I draw after using glDrawPixels doesn't appear on the screen. For instance, if I draw some polygons, then read the frame buffer, then write the read data back to the frame buffer (so that it is exactly the same as before), and then I draw some more polygons. All the polygons drawn after the glDrawPixels don't show up.

Is this what is supposed to happen?

ZbuffeR
03-16-2007, 01:37 PM
Not really.
Check depth testing, stencil testing, etc.

wgj000
03-16-2007, 02:34 PM
Oh ... depth testing ... didn't think of that. Could the Z-depth value for the pixel have been changed to 0 so that following draw commands ended up with pixels behind the raster just loaded and thus were not drawn? I bet it's something like that.

hmmm... how do I load the Z values with the color and how do I replace them... stuff to check on

thanks

wgj000
03-19-2007, 03:12 PM
OK I figured out how to read the depth component. So here is my code: (in JOGL)



gl.glReadPixels(0,0,this.getWidth(),this.getHeight (),GL.GL_DEPTH_COMPONENT,GL.GL_FLOAT,zScreenBuffer );
System.out.println("before DrawPixels "+zScreen[1000]);

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

gl.glReadPixels(0,0,this.getWidth(),this.getHeight (),GL.GL_DEPTH_COMPONENT,GL.GL_FLOAT,zScreenBuffer );
System.out.println("after DrawPixels "+zScreen[1000]);It outputs:
before DrawPixels 0.98789835
after DrawPixels 0.0

Clearly writing to the frame buffer sets the z-depth to zero. Is that what is supposed to happen? I only wanted to change the color and leave the depth buffer alone.

Zengar
03-19-2007, 05:37 PM
Use glDepthMask

arekkusu
03-19-2007, 09:21 PM
DrawPixels uses the current raster position depth value when you draw color.
DrawPixels uses the current raster postion color value when you draw depth.

wgj000
03-20-2007, 02:11 PM
Ah Zengar, you are brilliant. Using gl.glDepthMask(false); right before the glDrawPixels did the trick. My reading of the glDrawPixels command was that it would use the current depth position and combine that with the loaded color as arekkusu stated. But that does not appear to be the case on my card. (ATI Radeon 9800 Pro)