Reply – GLJPanel on JInternalFrame
Your Name
Subject
Message
or Cancel
In Reply To
GLJPanel on JInternalFrame
— by JensZ 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);

                   }  
}