AWTGLCanvas, glReadPixels : transform issue

Started by coasternuts, January 11, 2009, 20:48:44

Previous topic - Next topic

coasternuts

I have an application by which I can take a screen shot.  My application utilizes an AWTGLCanvas and glReadPixels to render and to take the screenshot.  The image at all times on the screen is perfect.  I can take a screen shot and it looks nice at any and all times, except when I resize the window.  Once I resize the window, my screen shot is sheared but my graphics are always pretty and nice, never sheared.  Sometimes it works, sometimes the sheared snapshot also looses color, and sometimes it crashes the JVM(see below).  It's never consistent but seems to depend on where I size my window to.

My screen shot is done during the rendering phase at the end.  Which can bee seen from this stack trace.

j  org.lwjgl.opengl.GL11.nglReadPixels(IIIIIILjava/nio/Buffer;IJ)V+0
j  org.lwjgl.opengl.GL11.glReadPixels(IIIIIILjava/nio/ByteBuffer;)V+58
j  lwjglutils.GLImageUtil.screenShot(II)Ljava/awt/image/BufferedImage;+29
j  lwjglutils.GLImageUtil.screenShot(Ljava/awt/Component;IILjava/lang/String;)Z+12
j  GLCharts.GLCanvas.renderData()V+296
j  GLCharts.GLCanvas.render()V+45
j  GLCharts.GLCanvas.paintGL()V+56
j  org.lwjgl.opengl.AWTGLCanvas.paint(Ljava/awt/Graphics;)V+158

Just so happens this stack trace is from the JVM crashing on me in one instance. 
My render loop is always rendering.  But the snapshot only happens once when the UI is clicked to flag a snapshot while rendering.  The only thing I can think of is that it's reading pixels at a time in the middle of the rendering loop but I issue a call to glFinish before and after the snapshot, but still the behavior is the same.

Specs:

lwjgl-2.0rc1
Windows XP using nVidia GeForce 8300

I have attached two files iwm.png and iwm_xformed.png to show you the good and the "bad" xformed one.
If anyone has any ideas I am all ears because I'm stumped.