JOGL v2.1 GLJPanel component does not respect (paler coloration caused by) call to glEnable(GL_FRAMEBUFFER_SRGB) GLCanvas, in contrast does respect GL_FRAMEBUFFER_SRGB. Also in contrast, JOGL v2.0 also DOES respect GL_FRAMEBUFFER_SRGB, so something changed from v2.0 to v2.1. This issue affect both Windows 7 and Mac OS X 10.8.5. For more background, see previous discussion at http://forum.jogamp.org/GL-FRAMEBUFFER-SRGB-and-GLJPanel-tp4030329.html
In the earlier forum discussion related to this issue, we came to assume that this issue is related to GLSL flipping of an offscreen render buffer. I now think that assumption may be incorrect. I spent one day trying to address this issue. The morning was occupied in an ill-chosen attempt to set up a jogl dev environment using recent MSVC11 on Windows. After lunch I switched to Mac OS X dev environment and got much further. I tried programmatically disabling GL_FRAMEBUFFER_SRGB before the framebuffer gets flipped. And I tried skipping the flip entirely. No effect: my test program still shows both a pale square (GLCanvas) and a dark square (GLJPanel). So I also tried passing "-Djogl.gljpanel.noglsl" to the JVM. Again, the GLJPanel does not respect GL_FRAMEBUFFER_SRGB. Thus I think this issue arises somplace other than the GLSL buffer flip. So the assumption of my day's effort may be flawed. My boss will not let me spend more time on this issue so I might not be able to fix it in the near future.
Program to manually test this issue is pasted below. Desired behavior: Two pale gray squares displayed side-by-side. Observed undesired behavior: Left square (GLCanvas) is desired pale gray; right square (GLJPanel) is unwanted darker gray. ************ import java.awt.Dimension; import javax.media.opengl.GL; import javax.media.opengl.GL2GL3; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLEventListener; import javax.media.opengl.awt.GLCanvas; import javax.media.opengl.awt.GLJPanel; import javax.swing.BoxLayout; import javax.swing.JFrame; //Demonstration program to show that GL_FRAMEBUFFER_SRGB is not //respected by GLJPanel in JOGL 2.1. The two displayed boxes should //be the same brightness. The one on the right is wrongly too dark. @SuppressWarnings("serial") public class TestGLJPanelSrgb extends JFrame implements GLEventListener { public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { new TestGLJPanelSrgb(); } }); } public TestGLJPanelSrgb() { GLCanvas glPanel1 = new GLCanvas(); // correct pale brightness GLJPanel glPanel2 = new GLJPanel(); // wrong dark brightness glPanel1.setPreferredSize(new Dimension(200, 200)); glPanel2.setPreferredSize(new Dimension(200, 200)); getContentPane().setLayout(new BoxLayout( getContentPane(), BoxLayout.LINE_AXIS)); getContentPane().add(glPanel1); getContentPane().add(glPanel2); glPanel1.addGLEventListener(this); glPanel2.addGLEventListener(this); pack(); setVisible(true); } @Override public void display(GLAutoDrawable gad) { GL gl = gad.getGL(); gl.glClear(GL.GL_COLOR_BUFFER_BIT); } @Override public void dispose(GLAutoDrawable arg0) {} @Override public void init(GLAutoDrawable gad) { GL2GL3 gl2gl3 = gad.getGL().getGL2GL3(); // This next line should raise the brightness of the image gl2gl3.glEnable(GL2GL3.GL_FRAMEBUFFER_SRGB); gl2gl3.glClearColor(0.5f, 0.5f, 0.5f, 1.0f); } @Override public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4) {} }
Duplicate of Bug 842! Also see: http://jogamp.org/git/?p=jogl.git;a=blob;f=src/jogl/classes/javax/media/opengl/awt/GLJPanel.java;h=522585f16fe2c07df060f4468e582d805353ecb2;hb=HEAD#l162 I am quite sure it is, hence users need to glEnable/Disable the state manually in their GLEventListener display method. Not nice, but its working - sorry. +++ Just for completeness: Best GLJPanel solution for performance and compatibility is GLJPanel's 'setSkipGLOrientationVerticalFlip(true)', see Bug 904, and referenced git-sha1 commits (incl. unit tests). +++ *** This bug has been marked as a duplicate of bug 842 ***
(In reply to comment #3) > Duplicate of Bug 842! > > Also see: > > http://jogamp.org/git/?p=jogl.git;a=blob;f=src/jogl/classes/javax/media/ > opengl/awt/GLJPanel.java;h=522585f16fe2c07df060f4468e582d805353ecb2; > hb=HEAD#l162 > > I am quite sure it is, hence users need to glEnable/Disable the state > manually in their > GLEventListener display method. Not nice, but its working - sorry. > > +++ > Just for completeness: Best GLJPanel solution for performance > and compatibility is GLJPanel's 'setSkipGLOrientationVerticalFlip(true)', > see Bug 904, and referenced git-sha1 commits (incl. unit tests). > +++ > > *** This bug has been marked as a duplicate of bug 842 *** I disagree with the "its working" comment. I have tried both of the following: * ADD gl.glDisable(GL2GL3.GL_FRAMEBUFFER_SRGB); // at the end of display(...) * CALL setSkipGLOrientationVerticalFlip(true); // on the GLJPanel Neither together, nor individually, do either of these approaches work around the GL_FRAMEBUFFER_SRGB problem with GLJPanel. Perhaps by "its working" you mean that you have modified the test program I posted to work correctly in some way. Could you please show me the code for the workaround? I cannot figure it out on my own. In my hands GL_FRAMEBUFFER_SRGB never works with GLJPanel; I have no workaround for this issue. Therefore I suspect that this is perhaps NOT a duplicate of bug 842.
Per the discussion here and in the forum, this issue is not resolved, and the proposed workaround does not actually work around the problem. So I am reopening. I can also now add that this issue affects both Mac and Windows in JOGL version 2.1.3, and affects at least Windows (I have not tested Mac) in JOGL version 2.2.4.