GLJPanel on JInternalFrame

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

GLJPanel on JInternalFrame

JensZ
Hi,

i trying to use the GLJPanel on JInternalFrame which is placed on a JDesktopPane. Everthing works fine so far.
But resizing the JInternalFrame causes some problems. To be more precise: If JInternalFrame is relatively small everything works fine and GLJPanel is resized correctly. But reaching some critical dimension, the GLJPanel is no longer resized in the right way. It seems to me that a part of the GLJPanel is not repainted any more. I have checked the dimension given to the reshape-method of the GLEventListener and they seem to be correct. Is it a bug in GLJPanel or am I doing something wrong?
Can anyone help me please?

Here are some snippets of my code:


public class openGLModeFrame extends JInternalFrame {
                  private openGLModePanel = new openGLModePanel();

                  public openGLModeFrame() {
                           this.add(plot);
                           this.setLayout(new BorderLayout());
                  }
}


public class openGLModePanel extends GLJPanel {
         
                  private openGLMode plotter = new openGLMode();

                  public openGLModePanel() {
                          this.addGLEventListener(this.plotter);
                  }

}


public class openGLMode implements GLEventListener {

            @Override
        public synchronized void display(GLAutoDrawable drawable) {
                GL2 gl = drawable.getGL().getGL2();
                gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);

                        //do some GL drawings

                        gl.glFlush();
           }

            @Override
  public void init(GLAutoDrawable drawable) {
                GL2 gl = drawable.getGL().getGL2();
               
                gl.setSwapInterval(1);
               

                gl.glClearColor(0f, 0f, 0f, 0f);
               

                gl.glShadeModel(GL2.GL_SMOOTH);
               

                gl.glEnable(GL2.GL_NORMALIZE);
                       

                gl.glLineWidth(2f);
                gl.glPointSize(2f);
               

                gl.glPolygonMode(GL.GL_FRONT, GL2GL3.GL_LINES);
                gl.glPolygonMode(GL.GL_BACK, GL2GL3.GL_LINES);
               

                gl.glEnableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
                gl.glEnableClientState(GLPointerFunc.GL_NORMAL_ARRAY);
                gl.glEnableClientState(GLPointerFunc.GL_COLOR_ARRAY);
               

                gl.glEnable(GL.GL_DEPTH_TEST);
               

                gl.glEnable(GL2.GL_BLEND);
                gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
               

                gl.glEnable(GL2.GL_LINE_SMOOTH);
                gl.glHint(GL2.GL_LINE_SMOOTH_HINT, GL2.GL_DONT_CARE);
                gl.glEnable(GL2.GL_POLYGON_SMOOTH);
                gl.glHint(GL2.GL_POLYGON_SMOOTH_HINT, GL2.GL_DONT_CARE);
               
                               
        }

            @Override
        public void reshape(GLAutoDrawable drawable, int xstart, int ystart, int width,
                        int height) {
                GL2 gl = drawable.getGL().getGL2();
               
               
                gl.glViewport(0, 0, width-1, height-1);
                gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
                gl.glLoadIdentity();
                gl.glOrthof(-2f, 2f, -2f, 2f, 2f, -2f); //looking from negative -2 (z) to positive 2 (z)
                gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
                gl.glLoadIdentity();


                this.createLights(gl);

                   }  
}
Reply | Threaded
Open this post in threaded view
|

Re: GLJPanel on JInternalFrame

Sven Gothel
Administrator
On Friday, June 25, 2010 02:32:52 pm JensZ [via jogamp] wrote:

>
> Hi,
>
> i trying to use the GLJPanel on JInternalFrame which is placed on a
> JDesktopPane. Everthing works fine so far.
> But resizing the JInternalFrame causes some problems. To be more precise: If
> JInternalFrame is relatively small everything works fine and GLJPanel is
> resized correctly. But reaching some critical dimension, the GLJPanel is no
> longer resized in the right way. It seems to me that a part of the GLJPanel
> is not repainted any more. I have checked the dimension given to the
> reshape-method of the GLEventListener and they seem to be correct. Is it a
> bug in GLJPanel or am I doing something wrong?
> Can anyone help me please?

Maybe .. just maybe this is related to lightweight/heavyweight mixing
introduced with 6u14 ? (Just had this issue lately)

 /**
 * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6776743
 * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6788954
 * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6797587
 *
 * Bug 6788954:
 * If an existing application embedds a heavyweight component in a frame,
 * and at the same time installs a custom glass pane,
 * the heavyweight component will disappear.
 * This regression is not very serious since we never supported mixing of hw and lw components
 * in general. The developer will have two options to resolve the problem:
 * 1. By modifying the software to tag the glass pane properly, or
 * 2. To suggest users to use the sun.awt.disableMixing system property
 * to disable the hw/lw mixing code at all.
 */

What worked for us was using: -Dsun.awt.disableMixing=true

~Sven

>
> Here are some snippets of my code:
>
>
> public class openGLModeFrame extends JInternalFrame {
>                   private openGLModePanel = new openGLModePanel();
>
>                   public openGLModeFrame() {
>                            this.add(plot);
>                            this.setLayout(new BorderLayout());
>                   }
> }
>
>
> public class openGLModePanel extends GLJPanel {
>          
>                   private openGLMode plotter = new openGLMode();
>
>                   public openGLModePanel() {
>                           this.addGLEventListener(this.plotter);
>                   }
>
> }
>
>
> public class openGLMode implements GLEventListener {
>
>             @Override
> public synchronized void display(GLAutoDrawable drawable) {
> GL2 gl = drawable.getGL().getGL2();
> gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
>
>                         //do some GL drawings
>
>                         gl.glFlush();
>            }
>
>             @Override
>   public void init(GLAutoDrawable drawable) {
> GL2 gl = drawable.getGL().getGL2();
>
> gl.setSwapInterval(1);
>
>
> gl.glClearColor(0f, 0f, 0f, 0f);
>
>
> gl.glShadeModel(GL2.GL_SMOOTH);
>
>
> gl.glEnable(GL2.GL_NORMALIZE);
>
>
> gl.glLineWidth(2f);
> gl.glPointSize(2f);
>
>
> gl.glPolygonMode(GL.GL_FRONT, GL2GL3.GL_LINES);
> gl.glPolygonMode(GL.GL_BACK, GL2GL3.GL_LINES);
>
>
> gl.glEnableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
> gl.glEnableClientState(GLPointerFunc.GL_NORMAL_ARRAY);
> gl.glEnableClientState(GLPointerFunc.GL_COLOR_ARRAY);
>
>
> gl.glEnable(GL.GL_DEPTH_TEST);
>
>
> gl.glEnable(GL2.GL_BLEND);
> gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
>
>
> gl.glEnable(GL2.GL_LINE_SMOOTH);
> gl.glHint(GL2.GL_LINE_SMOOTH_HINT, GL2.GL_DONT_CARE);
> gl.glEnable(GL2.GL_POLYGON_SMOOTH);
> gl.glHint(GL2.GL_POLYGON_SMOOTH_HINT, GL2.GL_DONT_CARE);
>
>
> }
>
>             @Override
> public void reshape(GLAutoDrawable drawable, int xstart, int ystart, int
> width,
> int height) {
> GL2 gl = drawable.getGL().getGL2();
>
>
> gl.glViewport(0, 0, width-1, height-1);
> gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
> gl.glLoadIdentity();
> gl.glOrthof(-2f, 2f, -2f, 2f, 2f, -2f); //looking from negative -2 (z) to
> positive 2 (z)
> gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
> gl.glLoadIdentity();
>
>
> this.createLights(gl);
>
>                    }  
> }
>
>
> ______________________________________
> View message @ http://jogamp.762907.n3.nabble.com/GLJPanel-on-JInternalFrame-tp921862p921862.html
> To start a new topic under jogamp, email [hidden email]
> To unsubscribe from jogamp, click http://jogamp.762907.n3.nabble.com/subscriptions/Unsubscribe.jtp?code=c2dvdGhlbEBqYXVzb2Z0LmNvbXw3NjI5MDd8MzkxNDI4MzU5
>
Reply | Threaded
Open this post in threaded view
|

Re: GLJPanel on JInternalFrame

Cyrille
I experience the same issue than JensZ with my GLJPanel. I noticed that depending on its size, the width of the properly painted GLJPanel's portion is 512 or 1024. Don't know if it can help.

I tried to disable hw/lw components mixing with -Dsun.awt.disableMixing=true but that did not change anything.

OS : Windows XP
Jogl version http://jogamp.org/deployment/archive/jogl-latest/build/jogl-2.0-pre-20100611-windows-i586.zip

Thanks,
Cyrille
Reply | Threaded
Open this post in threaded view
|

Re: GLJPanel on JInternalFrame

Cyrille
I just wanted to point out the fact that I reproduced this painting issue with a GLJPanel in a top level JFrame. This is the proof that the bug is not related to the use of JInternalFrame.

Here is a very simple application that reproduces the bug:

public final class TestApp implements GLEventListener
{
        private TestApp()
        {
        }

        public static void main(final String[] inArguments)
        {
                JFrame frame = new JFrame();
                javax.media.opengl.awt.GLJPanel canvas = new javax.media.opengl.awt.GLJPanel();
                canvas.addGLEventListener(new TestApp());
                frame.add(canvas);

                // Give frame the screen size as initial size.
                Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
                frame.setSize(screenSize);
                frame.setVisible(true);
        }

        @Override
        public void display(GLAutoDrawable arg0)
        {
                GL2 gl = arg0.getGL().getGL2();

                // Simply draw something: a green triangle on a red background.
                gl.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
                gl.glClear(GL.GL_COLOR_BUFFER_BIT);

                gl.glColor3f(0.0f, 1.0f, 0.0f);
                gl.glBegin(GL2.GL_LINES);
                gl.glVertex2d(0.0, 0.0);
                gl.glVertex2d(1.0, 0.0);
                gl.glVertex2d(1.0, 1.0);
                gl.glVertex2d(0.0, 0.0);
                gl.glEnd();

                gl.glFlush();
        }

        @Override
        public void dispose(GLAutoDrawable arg0)
        {
        }

        @Override
        public void init(GLAutoDrawable arg0)
        {
        }

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

On my computer, here is what I witness on my 1680x1050 screen:
-at startup the GLJPanel is properly painted from its left bound til the 1024th pixel. At the right of this limit, the panel is black.
-when I reduce panel's height below 400 pixels, the properly painted portion's width lowers to 512 pixels. From that point, when I increase panel's height again, the portion's becomes 1024 pixel wide again when panel's height exceeds 512 pixels.
-if I keep on reducing panel's height, the painted portion's width reduces to 256, then 128, then 64 pixels, etc...

I hope this code sample will help. I would be happy to file a bug in Bugzilla or to perform other investigation if you feel like it could be useful.

Thanks again for your help.
Cyrille
Reply | Threaded
Open this post in threaded view
|

Re: GLJPanel on JInternalFrame

Michael Bien
thank you for the test case and the good description.

I'll take a look at it after SIGGRAPH.
sure, feel free to file a bug report.

regards,
michael

On 07/18/2010 12:17 PM, Cyrille [via jogamp] wrote:
I just wanted to point out the fact that I reproduced this painting issue with a GLJPanel in a top level JFrame. This is the proof that the bug is not related to the use of JInternalFrame.

Here is a very simple application that reproduces the bug:

public final class TestApp implements GLEventListener
{
        private TestApp()
        {
        }

        public static void main(final String[] inArguments)
        {
                JFrame frame = new JFrame();
                javax.media.opengl.awt.GLJPanel canvas = new javax.media.opengl.awt.GLJPanel();
                canvas.addGLEventListener(new TestApp());
                frame.add(canvas);

                // Give frame the screen size as initial size.
                Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
                frame.setSize(screenSize);
                frame.setVisible(true);
        }

        @Override
        public void display(GLAutoDrawable arg0)
        {
                GL2 gl = arg0.getGL().getGL2();

                // Simply draw something: a green triangle on a red background.
                gl.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
                gl.glClear(GL.GL_COLOR_BUFFER_BIT);

                gl.glColor3f(0.0f, 1.0f, 0.0f);
                gl.glBegin(GL2.GL_LINES);
                gl.glVertex2d(0.0, 0.0);
                gl.glVertex2d(1.0, 0.0);
                gl.glVertex2d(1.0, 1.0);
                gl.glVertex2d(0.0, 0.0);
                gl.glEnd();

                gl.glFlush();
        }

        @Override
        public void dispose(GLAutoDrawable arg0)
        {
        }

        @Override
        public void init(GLAutoDrawable arg0)
        {
        }

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

On my computer, here is what I witness on my 1680x1050 screen:
-at startup the GLJPanel is properly painted from its left bound til the 1024th pixel. At the right of this limit, the panel is black.
-when I reduce panel's height below 400 pixels, the properly painted portion's width lowers to 512 pixels. From that point, when I increase panel's height again, the portion's becomes 1024 pixel wide again when panel's height exceeds 512 pixels.
-if I keep on reducing panel's height, the painted portion's width reduces to 256, then 128, then 64 pixels, etc...

I hope this code sample will help. I would be happy to file a bug in Bugzilla or to perform other investigation if you feel like it could be useful.

Thanks again for your help.
Cyrille


View message @ http://jogamp.762907.n3.nabble.com/GLJPanel-on-JInternalFrame-tp921862p976183.html
To start a new topic under jogamp, email [hidden email]
To unsubscribe from jogamp, click here.


Reply | Threaded
Open this post in threaded view
|

Re: GLJPanel on JInternalFrame

Cyrille