I switched to using GLJPanel from GLCanvas to avoid some flickering problems, however this created some unforeseen consequences for this.
From what I got so far, GLJPanel calls GLEventListener.init () with every resize, which either discards the various openGL functions that I included in init () (checking depth, lighting, etc.) if I Iโm lucky, or completely erases my model, if I donโt.
I tried to debug it, but I cannot fix this behavior. This is my init () function:
gl.glShadeModel( GL.GL_SMOOTH ); gl.glEnable( GL.GL_DEPTH_TEST ); gl.glDepthFunc( GL.GL_LEQUAL ); gl.glDepthRange( zNear, zFar ); gl.glDisable( GL.GL_LINE_SMOOTH ); gl.glEnable(GL.GL_NORMALIZE); gl.glEnable( GL.GL_BLEND ); gl.glBlendFunc( GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA ); // set up the background color gl.glClearColor( ((float)backColor.getRed () / 255.0f), ((float)backColor.getGreen() / 255.0f), ((float)backColor.getBlue () / 255.0f), 1.0f); gl.glEnable ( GL.GL_LIGHTING ); gl.glLightfv( GL.GL_LIGHT0, GL.GL_AMBIENT, Constants.AMBIENT_LIGHT, 0 ); gl.glLightfv( GL.GL_LIGHT0, GL.GL_DIFFUSE, Constants.DIFFUSE_LIGHT, 0 ); gl.glEnable ( GL.GL_LIGHT0 ); gl.glTexEnvf( GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_MODULATE ); gl.glHint( GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST ); // code to generate model
Is there any way around this, other than removing everything from init () by adding it to my display () function? Given the behavior of init () and reshape () for GLJPanel, I'm not sure if this will fix this.
source share