Login  Register

Re: GL_FRAMEBUFFER_SRGB and GLJPanel

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

Sorry I'm still having trouble understanding how to do this correctly. I now have both glEnable and glDisable statements in my test program, and the GLJPanel still appears dark. Can you please suggest what might be wrong with my modified test 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.
@SuppressWarnings("serial")
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();
                GL2GL3 gl2gl3 = gl.getGL2GL3();
                // This next line should raise the brightness of the image
                gl2gl3.glEnable(GL2GL3.GL_FRAMEBUFFER_SRGB);
                gl.glClear(GL.GL_COLOR_BUFFER_BIT);
                gl2gl3.glDisable(GL2GL3.GL_FRAMEBUFFER_SRGB);
        }

        @Override
        public void dispose(GLAutoDrawable arg0) {}

        @Override
        public void init(GLAutoDrawable gad) {
                GL gl = gad.getGL();
                gl.glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
        }

        @Override
        public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4)
        {}
}

*******************