Login  Register

GL_FRAMEBUFFER_SRGB and GLJPanel

Posted by cmbruns on Oct 22, 2013; 8:24pm
URL: https://forum.jogamp.org/GL-FRAMEBUFFER-SRGB-and-GLJPanel-tp4030329.html

I just upgraded from jogl version 2.0 (2.0-b58-20120620) to version 2.1 (2.1-b1111-20131010) and experienced an issue with using glEnable(GL_FRAMEBUFFER_SRGB) on both Mac and Windows. GLJPanel used to respect this setting and no longer does (though GLCanvas does respect it in both versions).

*** Example program below ***

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.
public class SrgbDemo extends JFrame implements GLEventListener
{
    public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                new SrgbDemo();
            }
        });
    }
   
        public SrgbDemo() {
        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) {}
}


*****