Created attachment 362 [details] Test code Overview: On Mac OS X, the use of the accumulation buffer flips the resulting image vertically. This behavior happens both for pBuffer and GLCanvas. Steps to Reproduce: See bottom of post and attached file. Build Date & Platform: JOGL v2.0-RC9, MacBook Pro 6.1, GeForce GT 300M, Mac OS X 10.6.8, Java 6u33 Additional Builds and Platforms: The vertical flip does not occur on any Windows machine so far. Also, another Mac (Mac OS X 10.7, Oracle Java 7u5) doesn't have the problem. ------------------- /** * Copyright 2011 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ import java.awt.image.BufferedImage; import javax.media.opengl.GL2; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLException; import javax.media.opengl.GLPbuffer; import javax.media.opengl.GLProfile; import com.jogamp.opengl.util.awt.Screenshot; public class FlippedImageTest implements GLEventListener { GLPbuffer glPBuffer = null; public FlippedImageTest() { GLProfile glp = GLProfile.get(GLProfile.GL2); GLCapabilities caps = new GLCapabilities(glp); GLDrawableFactory glFactory = GLDrawableFactory.getFactory(glp); caps.setAccumRedBits(16); caps.setAccumGreenBits(16); caps.setAccumBlueBits(16); caps.setStencilBits(8); caps.setDoubleBuffered(true); caps.setHardwareAccelerated(true); try { glPBuffer = glFactory.createGLPbuffer(null, caps, null, 4, 4, null); } catch (GLException exc) { } glPBuffer.addGLEventListener(this); } /** * @param args */ public static void main(String[] args) { FlippedImageTest demo = new FlippedImageTest(); demo.glPBuffer.display(); demo.glPBuffer.createContext(null).makeCurrent(); BufferedImage image = Screenshot.readToBufferedImage(4, 4); int above = image.getRGB(0, 0); int below = image.getRGB(0, 3); if (above == 0xff00ff00 && below == 0xffff0000) { System.out.println("image right side up"); } else if (above == 0xffff0000 && below == 0xff00ff00) { System.out.println("image is flipped"); } else { System.out.println("error in test"); } } public void display(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); // red below gl.glColor3f(1, 0, 0); gl.glRectf(-1, -1, 1, 0); // green above gl.glColor3f(0, 1, 0); gl.glRectf(-1, 0, 1, 1); gl.glFinish(); gl.glAccum(GL2.GL_ACCUM, 1.0f); gl.glAccum(GL2.GL_RETURN, 1.0f); gl.glEnd(); gl.glFlush(); } public void init(GLAutoDrawable drawable) { } public void reshape(GLAutoDrawable glDrawable, int x, int y, int w, int h) { } public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) { } public void dispose(GLAutoDrawable drawable) { } }
Going from JOGL RC9 to RC10, the problem seems to be fixed on the machine that previously displayed the flipped result.
See Comment 1 .. reporter validated the erroneous behavior is gone in RC10. Even though the root cause is unknown, we close this one. Maybe it's regarding the fixed GLCaps & alpha: <http://jogamp.org/git/?p=jogl.git;a=commit;h=4a08de4511a627c3d87d6a33debbd561962c0312>
Upon further inspection, I just discovered that this bug still is valid. The faulty worksforme came from another improvement to our product prevented this bug from being triggered.
probably a selected software renderer ? same happens on windows w/ offscreen - bitmap. not really a bug .. if so.
Hi Sven, Thanks for the feedback. We're currently not choosing between software and hardware anti-aliasing explicitly, so that could be the case. One thing I do wonder is whether the result should be correctly oriented, independent of the selected renderer?
See: <http://jogamp.org/git/?p=jogl.git;a=commit;h=d3033e42faa909f6c1055f5ba3c7925766a3e583> Added 2 unit tests, mostly your code (NEWT / AWT), works - closed. Note-1: Unit tests use the new API for generating offscreen-auto-drawable. Note-2: On my machine all hw renderer were picked. So if you see y-flipped results, it might be the sw renderer .. and it's not us who causes the bug. +++ OSX 10.7.5, Java6 (latest) .++++ UITestCase.setUp: com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageAWT - test01AccumStencilPBuffer GL_RENDERER: NVIDIA GeForce 320M OpenGL Engine GL_VERSION: 2.1 NVIDIA-7.32.12 below: 0xff0000 above: 0xff00 Image right side up XXX GLCaps[rgba 0x8/8/8/8, opaque, accum-rgba 32/32/32/32, dp/st/ms: 24/8/0, dbl, mono , hw, GLProfile[GL2/GL2.hw], offscr[pbuffer [r2t 0, r2tr 0, float 0]]] XXX 2.1 (Compatibility profile, arb, FBO, hardware) - 2.1 NVIDIA-7.32.12 ++++ UITestCase.tearDown: com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageAWT - test01AccumStencilPBuffer SLOCK [T Thread-4-UserApp-TestBug605FlippedImageAWT @ 1349491975782 ms --- localhost/127.0.0.1:59999 - Unlock ok